keyboard: put modifier/key listeners in keyboard struct

...so that it can be determined what wlr_keyboard events come from.

This is required to manage virtual keyboards alongside the keyboard_group
of physical keyboards.
This commit is contained in:
Johan Malm 2022-09-26 07:17:19 +01:00 committed by Johan Malm
parent 76d5fb1dda
commit f2277c37c3
3 changed files with 94 additions and 64 deletions

View file

@ -76,6 +76,20 @@ struct input {
struct wl_list link; /* seat::inputs */
};
/*
* Virtual keyboards should not belong to seat->keyboard_group. As a result we
* need to be able to ascertain which wlr_keyboard key/modifer events come from
* and we achieve that by using `struct keyboard` which inherits `struct input`
* and adds keybord specific listeners and a wlr_keyboard pointer.
*/
struct keyboard {
struct input base;
struct wlr_keyboard *wlr_keyboard;
bool is_virtual;
struct wl_listener modifier;
struct wl_listener key;
};
struct seat {
struct wlr_seat *seat;
struct server *server;
@ -144,9 +158,6 @@ struct seat {
struct wl_listener request_set_selection;
struct wl_listener request_set_primary_selection;
struct wl_listener keyboard_key;
struct wl_listener keyboard_modifiers;
struct wl_listener touch_down;
struct wl_listener touch_up;
struct wl_listener touch_motion;
@ -516,6 +527,8 @@ struct view *desktop_focused_view(struct server *server);
void desktop_focus_topmost_mapped_view(struct server *server);
bool isfocusable(struct view *view);
void keyboard_key_notify(struct wl_listener *listener, void *data);
void keyboard_modifiers_notify(struct wl_listener *listener, void *data);
void keyboard_init(struct seat *seat);
bool keyboard_any_modifiers_pressed(struct wlr_keyboard *keyboard);
void keyboard_finish(struct seat *seat);