From d33a9f8eaaeaf2e7a6bbf0c9f9d57c3334544a2b Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Mon, 23 Oct 2017 08:59:55 -0400 Subject: wlr-seat: keyboard redesign --- include/rootston/input.h | 1 + include/wlr/types/wlr_seat.h | 49 ++++++++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 25 deletions(-) (limited to 'include') diff --git a/include/rootston/input.h b/include/rootston/input.h index ddd5a05d..b55288c9 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -16,6 +16,7 @@ struct roots_keyboard { struct roots_input *input; struct wlr_input_device *device; struct wl_listener key; + struct wl_listener modifiers; struct wl_list link; xkb_keysym_t pressed_keysyms[ROOTS_KEYBOARD_PRESSED_KEYSYMS_CAP]; diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index d267924c..6fda89b9 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -14,7 +14,6 @@ struct wlr_seat_handle { struct wl_resource *wl_resource; struct wlr_seat *wlr_seat; - struct wlr_seat_keyboard *seat_keyboard; struct wl_resource *pointer; struct wl_resource *keyboard; @@ -82,21 +81,16 @@ struct wlr_seat_pointer_state { struct wlr_seat_pointer_grab *default_grab; }; -struct wlr_seat_keyboard { - struct wlr_seat *seat; - struct wlr_keyboard *keyboard; - struct wl_listener key; - struct wl_listener modifiers; - struct wl_listener keymap; - struct wl_listener destroy; - struct wl_list link; -}; - struct wlr_seat_keyboard_state { struct wlr_seat *wlr_seat; + struct wlr_keyboard *keyboard; + struct wlr_seat_handle *focused_handle; struct wlr_surface *focused_surface; + struct wl_listener keyboard_destroy; + struct wl_listener keyboard_keymap; + struct wl_listener surface_destroy; struct wl_listener resource_destroy; @@ -108,7 +102,6 @@ struct wlr_seat { struct wl_global *wl_global; struct wl_display *display; struct wl_list handles; - struct wl_list keyboards; char *name; uint32_t capabilities; struct wlr_data_device *data_device; @@ -254,18 +247,9 @@ void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time, enum wlr_axis_orientation orientation, double value); /** - * Attaches this keyboard to the seat. Key events from this keyboard will be - * propegated to the focused client. - */ -void wlr_seat_attach_keyboard(struct wlr_seat *seat, - struct wlr_input_device *dev); - -/** - * Detaches this keyboard from the seat. This is done automatically when the - * keyboard is destroyed; you only need to use this if you want to remove it for - * some other reason. + * Set this keyboard as the active keyboard for the seat. */ -void wlr_seat_detach_keyboard(struct wlr_seat *seat, struct wlr_keyboard *kb); +void wlr_seat_set_keyboard(struct wlr_seat *seat, struct wlr_input_device *dev); /** * Start a grab of the keyboard of this seat. The grabber is responsible for @@ -282,19 +266,34 @@ void wlr_seat_keyboard_end_grab(struct wlr_seat *wlr_seat); /** * Send the keyboard key to focused keyboard resources. Compositors should use - * `wlr_seat_attach_keyboard()` to automatically handle keyboard events. + * `wlr_seat_notify_key()` to respect keyboard grabs. */ void wlr_seat_keyboard_send_key(struct wlr_seat *seat, uint32_t time, uint32_t key, uint32_t state); +/** + * Notify the seat that a key has been pressed on the keyboard. Defers to any + * keyboard grabs. + */ +void wlr_seat_keyboard_notify_key(struct wlr_seat *seat, uint32_t time, + uint32_t key, uint32_t state); + /** * Send the modifier state to focused keyboard resources. Compositors should use - * `wlr_seat_attach_keyboard()` to automatically handle keyboard events. + * `wlr_seat_keyboard_notify_modifiers()` to respect any keyboard grabs. */ void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group); +/** + * Notify the seat that the modifiers for the keyboard have changed. Defers to + * any keyboard grabs. + */ +void wlr_seat_keyboard_notify_modifiers(struct wlr_seat *seat, + uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, + uint32_t group); + /** * Notify the seat that the keyboard focus has changed and request it to be the * focused surface for this keyboard. Defers to any current grab of the seat's -- cgit v1.2.3 From 50e86a0efa43fa72bd7d8c2dfc2d124052f74823 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 28 Oct 2017 15:32:08 -0400 Subject: Allow configuring output mode in rootston Fixes #336 --- include/rootston/config.h | 4 ++++ rootston/config.c | 16 ++++++++++++++++ rootston/output.c | 23 +++++++++++++++++++++++ 3 files changed, 43 insertions(+) (limited to 'include') diff --git a/include/rootston/config.h b/include/rootston/config.h index ecbdd88b..75c04619 100644 --- a/include/rootston/config.h +++ b/include/rootston/config.h @@ -9,6 +9,10 @@ struct output_config { enum wl_output_transform transform; int x, y; struct wl_list link; + struct { + int width, height; + float refresh_rate; + } mode; }; struct device_config { diff --git a/rootston/config.c b/rootston/config.c index 6f81170b..b3fd4f01 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -1,6 +1,7 @@ #ifndef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200809L #endif +#include #include #include #include @@ -244,6 +245,21 @@ static int config_ini_handler(void *user, const char *section, const char *name, } else { wlr_log(L_ERROR, "got unknown transform value: %s", value); } + } else if (strcmp(name, "mode") == 0) { + char *end; + oc->mode.width = strtol(value, &end, 10); + assert(*end == 'x'); + ++end; + oc->mode.height = strtol(end, &end, 10); + if (*end) { + assert(*end == '@'); + ++end; + oc->mode.refresh_rate = strtof(end, &end); + assert(strcmp("Hz", end) == 0); + } + wlr_log(L_DEBUG, "Configured output %s with mode %dx%d@%f", + oc->name, oc->mode.width, oc->mode.height, + oc->mode.refresh_rate); } } else if (strcmp(section, "cursor") == 0) { if (strcmp(name, "map-to-output") == 0) { diff --git a/rootston/output.c b/rootston/output.c index 5fcd02a2..6bc28996 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -165,6 +165,26 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { output->last_frame = desktop->last_frame = now; } +static void set_mode(struct wlr_output *output, struct output_config *oc) { + struct wlr_output_mode *mode, *best = NULL; + int mhz = (int)(oc->mode.refresh_rate * 1000); + wl_list_for_each(mode, &output->modes, link) { + if (mode->width == oc->mode.width && mode->height == oc->mode.height) { + if (mode->refresh == mhz) { + best = mode; + break; + } + best = mode; + } + } + if (!best) { + wlr_log(L_ERROR, "Configured mode for %s not available", output->name); + } else { + wlr_log(L_DEBUG, "Assigning configured mode to %s", output->name); + wlr_output_set_mode(output, best); + } +} + void output_add_notify(struct wl_listener *listener, void *data) { struct wlr_output *wlr_output = data; struct roots_desktop *desktop = wl_container_of(listener, desktop, output_add); @@ -191,6 +211,9 @@ void output_add_notify(struct wl_listener *listener, void *data) { struct output_config *output_config = config_get_output(config, wlr_output); if (output_config) { + if (output_config->mode.width) { + set_mode(wlr_output, output_config); + } wlr_output_transform(wlr_output, output_config->transform); wlr_output_layout_add(desktop->layout, wlr_output, output_config->x, output_config->y); -- cgit v1.2.3