diff options
Diffstat (limited to 'rootston')
-rw-r--r-- | rootston/config.c | 23 | ||||
-rw-r--r-- | rootston/cursor.c | 20 | ||||
-rw-r--r-- | rootston/desktop.c | 6 | ||||
-rw-r--r-- | rootston/keyboard.c | 13 | ||||
-rw-r--r-- | rootston/meson.build | 1 | ||||
-rw-r--r-- | rootston/output.c | 18 | ||||
-rw-r--r-- | rootston/seat.c | 22 | ||||
-rw-r--r-- | rootston/xcursor.c | 28 |
8 files changed, 68 insertions, 63 deletions
diff --git a/rootston/config.c b/rootston/config.c index 466ad16a..db77506f 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -120,7 +120,7 @@ void add_binding_config(struct wl_list *bindings, const char* combination, xkb_keysym_t keysyms[ROOTS_KEYBOARD_PRESSED_KEYSYMS_CAP]; char *symnames = strdup(combination); - char* symname = strtok(symnames, "+"); + char *symname = strtok(symnames, "+"); while (symname) { uint32_t modifier = parse_modifier(symname); if (modifier != 0) { @@ -176,6 +176,9 @@ static void config_handle_cursor(struct roots_config *config, } else if (strcmp(name, "theme") == 0) { free(cc->theme); cc->theme = strdup(value); + } else if (strcmp(name, "default-image") == 0) { + free(cc->default_image); + cc->default_image = strdup(value); } else { wlr_log(L_ERROR, "got unknown cursor config: %s", name); } @@ -213,6 +216,10 @@ static void config_handle_keyboard(struct roots_config *config, kc->variant = strdup(value); } else if (strcmp(name, "options") == 0) { kc->options = strdup(value); + } else if (strcmp(name, "repeat-rate") == 0) { + kc->repeat_rate = strtol(value, NULL, 10); + } else if (strcmp(name, "repeat-delay") == 0) { + kc->repeat_delay = strtol(value, NULL, 10); } else { wlr_log(L_ERROR, "got unknown keyboard config: %s", name); } @@ -450,6 +457,7 @@ void roots_config_destroy(struct roots_config *config) { free(cc->mapped_output); free(cc->mapped_box); free(cc->theme); + free(cc->default_image); free(cc); } @@ -466,10 +474,15 @@ void roots_config_destroy(struct roots_config *config) { struct roots_output_config *roots_config_get_output(struct roots_config *config, struct wlr_output *output) { - struct roots_output_config *o_config; - wl_list_for_each(o_config, &config->outputs, link) { - if (strcmp(o_config->name, output->name) == 0) { - return o_config; + char name[83]; + snprintf(name, sizeof(name), "%s %s %s", output->make, output->model, + output->serial); + + struct roots_output_config *oc; + wl_list_for_each(oc, &config->outputs, link) { + if (strcmp(oc->name, output->name) == 0 || + strcmp(oc->name, name) == 0) { + return oc; } } diff --git a/rootston/cursor.c b/rootston/cursor.c index f0e3d70d..95e8ce2a 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -8,6 +8,7 @@ #endif #include <wlr/types/wlr_xcursor_manager.h> #include <wlr/util/log.h> +#include <wlr/util/edges.h> #include "rootston/xcursor.h" #include "rootston/cursor.h" @@ -21,6 +22,7 @@ struct roots_cursor *roots_cursor_create(struct roots_seat *seat) { free(cursor); return NULL; } + cursor->default_xcursor = ROOTS_XCURSOR_DEFAULT; return cursor; } @@ -47,7 +49,7 @@ static void roots_cursor_update_position(struct roots_cursor *cursor, } if (set_compositor_cursor) { wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, - ROOTS_XCURSOR_DEFAULT, cursor->cursor); + cursor->default_xcursor, cursor->cursor); cursor->cursor_client = NULL; } if (view) { @@ -75,22 +77,22 @@ static void roots_cursor_update_position(struct roots_cursor *cursor, double y = view->y; int width = cursor->view_width; int height = cursor->view_height; - if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) { + if (cursor->resize_edges & WLR_EDGE_TOP) { y = cursor->view_y + dy; height -= dy; if (height < 1) { y += height; } - } else if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_BOTTOM) { + } else if (cursor->resize_edges & WLR_EDGE_BOTTOM) { height += dy; } - if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { + if (cursor->resize_edges & WLR_EDGE_LEFT) { x = cursor->view_x + dx; width -= dx; if (width < 1) { x += width; } - } else if (cursor->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { + } else if (cursor->resize_edges & WLR_EDGE_RIGHT) { width += dx; } @@ -147,14 +149,14 @@ static void roots_cursor_press_button(struct roots_cursor *cursor, case BTN_RIGHT: edges = 0; if (sx < view->wlr_surface->current->width/2) { - edges |= ROOTS_CURSOR_RESIZE_EDGE_LEFT; + edges |= WLR_EDGE_LEFT; } else { - edges |= ROOTS_CURSOR_RESIZE_EDGE_RIGHT; + edges |= WLR_EDGE_RIGHT; } if (sy < view->wlr_surface->current->height/2) { - edges |= ROOTS_CURSOR_RESIZE_EDGE_TOP; + edges |= WLR_EDGE_TOP; } else { - edges |= ROOTS_CURSOR_RESIZE_EDGE_BOTTOM; + edges |= WLR_EDGE_BOTTOM; } roots_seat_begin_resize(seat, view, edges); break; diff --git a/rootston/desktop.c b/rootston/desktop.c index 244f7c94..ef459e69 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -408,10 +408,14 @@ struct roots_desktop *desktop_create(struct roots_server *server, desktop->config = config; const char *cursor_theme = NULL; + const char *cursor_default = ROOTS_XCURSOR_DEFAULT; struct roots_cursor_config *cc = roots_config_get_cursor(config, ROOTS_CONFIG_DEFAULT_SEAT_NAME); if (cc != NULL) { cursor_theme = cc->theme; + if (cc->default_image != NULL) { + cursor_default = cc->default_image; + } } desktop->xcursor_manager = wlr_xcursor_manager_create(cursor_theme, @@ -449,7 +453,7 @@ struct roots_desktop *desktop_create(struct roots_server *server, wlr_log(L_ERROR, "Cannot load XWayland XCursor theme"); } struct wlr_xcursor *xcursor = wlr_xcursor_manager_get_xcursor( - desktop->xcursor_manager, ROOTS_XCURSOR_DEFAULT, 1); + desktop->xcursor_manager, cursor_default, 1); if (xcursor != NULL) { struct wlr_xcursor_image *image = xcursor->images[0]; wlr_xwayland_set_cursor(desktop->xwayland, image->buffer, diff --git a/rootston/keyboard.c b/rootston/keyboard.c index 85033613..4aaf2d48 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -306,6 +306,12 @@ static void keyboard_config_merge(struct roots_keyboard_config *config, if (config->name == NULL) { config->name = fallback->name; } + if (config->repeat_rate <= 0) { + config->repeat_rate = fallback->repeat_rate; + } + if (config->repeat_delay <= 0) { + config->repeat_delay = fallback->repeat_delay; + } } struct roots_keyboard *roots_keyboard_create(struct wlr_input_device *device, @@ -337,8 +343,7 @@ struct roots_keyboard *roots_keyboard_create(struct wlr_input_device *device, keyboard_config_merge(config, &env_config); keyboard->config = config; - struct xkb_rule_names rules; - memset(&rules, 0, sizeof(rules)); + struct xkb_rule_names rules = { 0 }; rules.rules = config->rules; rules.model = config->model; rules.layout = config->layout; @@ -353,6 +358,10 @@ struct roots_keyboard *roots_keyboard_create(struct wlr_input_device *device, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS)); xkb_context_unref(context); + int repeat_rate = (config->repeat_rate > 0) ? config->repeat_rate : 25; + int repeat_delay = (config->repeat_delay > 0) ? config->repeat_delay : 600; + wlr_keyboard_set_repeat_info(device->keyboard, repeat_rate, repeat_delay); + return keyboard; } diff --git a/rootston/meson.build b/rootston/meson.build index 9c543c4f..36b6241a 100644 --- a/rootston/meson.build +++ b/rootston/meson.build @@ -8,7 +8,6 @@ sources = [ 'main.c', 'output.c', 'seat.c', - 'xcursor.c', 'xdg_shell_v6.c', 'wl_shell.c', ] diff --git a/rootston/output.c b/rootston/output.c index d0f4a378..b2d6554d 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -6,7 +6,6 @@ #include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_wl_shell.h> -#include <wlr/types/wlr_xcursor_manager.h> #include <wlr/types/wlr_xdg_shell_v6.h> #include <wlr/render/matrix.h> #include <wlr/util/log.h> @@ -264,8 +263,15 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { static void set_mode(struct wlr_output *output, struct roots_output_config *oc) { - struct wlr_output_mode *mode, *best = NULL; int mhz = (int)(oc->mode.refresh_rate * 1000); + + if (wl_list_empty(&output->modes)) { + // Output has no mode, try setting a custom one + wlr_output_set_custom_mode(output, oc->mode.width, oc->mode.height, mhz); + return; + } + + struct wlr_output_mode *mode, *best = NULL; wl_list_for_each(mode, &output->modes, link) { if (mode->width == oc->mode.width && mode->height == oc->mode.height) { if (mode->refresh == mhz) { @@ -291,7 +297,7 @@ void output_add_notify(struct wl_listener *listener, void *data) { struct roots_config *config = desktop->config; wlr_log(L_DEBUG, "Output '%s' added", wlr_output->name); - wlr_log(L_DEBUG, "%s %s %s %"PRId32"mm x %"PRId32"mm", wlr_output->make, + wlr_log(L_DEBUG, "'%s %s %s' %"PRId32"mm x %"PRId32"mm", wlr_output->make, wlr_output->model, wlr_output->serial, wlr_output->phys_width, wlr_output->phys_height); if (wl_list_length(&wlr_output->modes) > 0) { @@ -324,12 +330,6 @@ void output_add_notify(struct wl_listener *listener, void *data) { struct roots_seat *seat; wl_list_for_each(seat, &input->seats, link) { - if (wlr_xcursor_manager_load(seat->cursor->xcursor_manager, - wlr_output->scale)) { - wlr_log(L_ERROR, "Cannot load xcursor theme for output '%s' " - "with scale %d", wlr_output->name, wlr_output->scale); - } - roots_seat_configure_cursor(seat); roots_seat_configure_xcursor(seat); } diff --git a/rootston/seat.c b/rootston/seat.c index 737bbd67..8a581157 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -442,14 +442,19 @@ void roots_seat_configure_xcursor(struct roots_seat *seat) { roots_config_get_cursor(seat->input->config, seat->seat->name); if (cc != NULL) { cursor_theme = cc->theme; + if (cc->default_image != NULL) { + seat->cursor->default_xcursor = cc->default_image; + } } - seat->cursor->xcursor_manager = - wlr_xcursor_manager_create(cursor_theme, ROOTS_XCURSOR_SIZE); - if (seat->cursor->xcursor_manager == NULL) { - wlr_log(L_ERROR, "Cannot create XCursor manager for theme %s", - cursor_theme); - return; + if (!seat->cursor->xcursor_manager) { + seat->cursor->xcursor_manager = + wlr_xcursor_manager_create(cursor_theme, ROOTS_XCURSOR_SIZE); + if (seat->cursor->xcursor_manager == NULL) { + wlr_log(L_ERROR, "Cannot create XCursor manager for theme %s", + cursor_theme); + return; + } } struct roots_output *output; @@ -463,7 +468,7 @@ void roots_seat_configure_xcursor(struct roots_seat *seat) { } wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager, - ROOTS_XCURSOR_DEFAULT, seat->cursor->cursor); + seat->cursor->default_xcursor, seat->cursor->cursor); wlr_cursor_warp(seat->cursor->cursor, NULL, seat->cursor->cursor->x, seat->cursor->cursor->y); } @@ -661,8 +666,9 @@ void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view, view_maximize(view, false); wlr_seat_pointer_clear_focus(seat->seat); + const char *resize_name = wlr_xcursor_get_resize_name(edges); wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager, - roots_xcursor_get_resize_name(edges), seat->cursor->cursor); + resize_name, seat->cursor->cursor); } void roots_seat_begin_rotate(struct roots_seat *seat, struct roots_view *view) { diff --git a/rootston/xcursor.c b/rootston/xcursor.c deleted file mode 100644 index 74e732c9..00000000 --- a/rootston/xcursor.c +++ /dev/null @@ -1,28 +0,0 @@ -#define _POSIX_C_SOURCE 200809L -#include <stdlib.h> -#include <string.h> -#include "rootston/xcursor.h" -#include "rootston/input.h" - -const char *roots_xcursor_get_resize_name(uint32_t edges) { - if (edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) { - if (edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { - return "ne-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { - return "nw-resize"; - } - return "n-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_BOTTOM) { - if (edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { - return "se-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { - return "sw-resize"; - } - return "s-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { - return "e-resize"; - } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { - return "w-resize"; - } - return "se-resize"; // fallback -} |