diff options
author | emersion <contact@emersion.fr> | 2017-12-14 20:31:18 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2017-12-14 20:31:18 +0100 |
commit | 466e86b7b2cbefa55ad5b85a97ee8257c24cb81b (patch) | |
tree | cc1691ec5abefdffcb8ac6312574ffa03bc4049a /rootston | |
parent | eb763439f75d3c9174280d0c75ef44941dd99340 (diff) | |
parent | a9fb071d49b244b72846b384a9e2ef2d9b03a05f (diff) |
Merge branch 'master' into surface-transform
Diffstat (limited to 'rootston')
-rw-r--r-- | rootston/config.c | 23 | ||||
-rw-r--r-- | rootston/cursor.c | 20 | ||||
-rw-r--r-- | rootston/desktop.c | 9 | ||||
-rw-r--r-- | rootston/keyboard.c | 13 | ||||
-rw-r--r-- | rootston/meson.build | 1 | ||||
-rw-r--r-- | rootston/output.c | 26 | ||||
-rw-r--r-- | rootston/seat.c | 22 | ||||
-rw-r--r-- | rootston/wl_shell.c | 3 | ||||
-rw-r--r-- | rootston/xcursor.c | 28 | ||||
-rw-r--r-- | rootston/xwayland.c | 28 |
10 files changed, 86 insertions, 87 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 8cede819..c9fc0dc6 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -13,7 +13,6 @@ #include <wlr/types/wlr_xcursor_manager.h> #include <wlr/types/wlr_xdg_shell_v6.h> #include <wlr/util/log.h> -#include <server-decoration-protocol.h> #include "rootston/server.h" #include "rootston/seat.h" #include "rootston/xcursor.h" @@ -407,10 +406,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, @@ -448,7 +451,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, @@ -466,7 +469,7 @@ struct roots_desktop *desktop_create(struct roots_server *server, wlr_server_decoration_manager_create(server->wl_display); wlr_server_decoration_manager_set_default_mode( desktop->server_decoration_manager, - ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT); + WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT); return desktop; } 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 996f819d..e510be71 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> @@ -283,8 +282,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) { @@ -310,7 +316,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) { @@ -333,22 +339,16 @@ void output_add_notify(struct wl_listener *listener, void *data) { if (output_config->mode.width) { set_mode(wlr_output, output_config); } - wlr_output->scale = output_config->scale; - wlr_output_transform(wlr_output, output_config->transform); - wlr_output_layout_add(desktop->layout, - wlr_output, output_config->x, output_config->y); + wlr_output_set_scale(wlr_output, output_config->scale); + wlr_output_set_transform(wlr_output, output_config->transform); + wlr_output_layout_add(desktop->layout, wlr_output, output_config->x, + output_config->y); } else { wlr_output_layout_add_auto(desktop->layout, wlr_output); } 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/wl_shell.c b/rootston/wl_shell.c index 5fd6352d..d0aad407 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -150,8 +150,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { roots_surface->set_state.notify = handle_set_state; wl_signal_add(&surface->events.set_state, &roots_surface->set_state); roots_surface->surface_commit.notify = handle_surface_commit; - wl_signal_add(&surface->surface->events.commit, - &roots_surface->surface_commit); + wl_signal_add(&surface->events.commit, &roots_surface->surface_commit); struct roots_view *view = calloc(1, sizeof(struct roots_view)); if (!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 -} diff --git a/rootston/xwayland.c b/rootston/xwayland.c index 2b17ee3f..5f677116 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -11,8 +11,7 @@ static void activate(struct roots_view *view, bool active) { assert(view->type == ROOTS_XWAYLAND_VIEW); - struct wlr_xwayland *xwayland = view->desktop->xwayland; - wlr_xwayland_surface_activate(xwayland, view->xwayland_surface, active); + wlr_xwayland_surface_activate(view->xwayland_surface, active); } static void move(struct roots_view *view, double x, double y) { @@ -20,8 +19,8 @@ static void move(struct roots_view *view, double x, double y) { struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface; view->x = x; view->y = y; - wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface, - x, y, xwayland_surface->width, xwayland_surface->height); + wlr_xwayland_surface_configure(xwayland_surface, x, y, + xwayland_surface->width, xwayland_surface->height); } static void apply_size_constraints( @@ -56,9 +55,8 @@ static void resize(struct roots_view *view, uint32_t width, uint32_t height) { apply_size_constraints(xwayland_surface, width, height, &constrained_width, &constrained_height); - wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface, - xwayland_surface->x, xwayland_surface->y, constrained_width, - constrained_height); + wlr_xwayland_surface_configure(xwayland_surface, xwayland_surface->x, + xwayland_surface->y, constrained_width, constrained_height); } static void move_resize(struct roots_view *view, double x, double y, @@ -87,27 +85,25 @@ static void move_resize(struct roots_view *view, double x, double y, view->pending_move_resize.width = constrained_width; view->pending_move_resize.height = constrained_height; - wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface, - x, y, constrained_width, constrained_height); + wlr_xwayland_surface_configure(xwayland_surface, x, y, constrained_width, + constrained_height); } static void close(struct roots_view *view) { assert(view->type == ROOTS_XWAYLAND_VIEW); - wlr_xwayland_surface_close(view->desktop->xwayland, view->xwayland_surface); + wlr_xwayland_surface_close(view->xwayland_surface); } static void maximize(struct roots_view *view, bool maximized) { assert(view->type == ROOTS_XWAYLAND_VIEW); - wlr_xwayland_surface_set_maximized(view->desktop->xwayland, - view->xwayland_surface, maximized); + wlr_xwayland_surface_set_maximized(view->xwayland_surface, maximized); } static void set_fullscreen(struct roots_view *view, bool fullscreen) { assert(view->type == ROOTS_XWAYLAND_VIEW); - wlr_xwayland_surface_set_fullscreen(view->desktop->xwayland, - view->xwayland_surface, fullscreen); + wlr_xwayland_surface_set_fullscreen(view->xwayland_surface, fullscreen); } static void handle_destroy(struct wl_listener *listener, void *data) { @@ -139,8 +135,8 @@ static void handle_request_configure(struct wl_listener *listener, void *data) { roots_surface->view->x = (double)event->x; roots_surface->view->y = (double)event->y; - wlr_xwayland_surface_configure(roots_surface->view->desktop->xwayland, - xwayland_surface, event->x, event->y, event->width, event->height); + wlr_xwayland_surface_configure(xwayland_surface, event->x, event->y, + event->width, event->height); } static struct roots_seat *guess_seat_for_view(struct roots_view *view) { |