From c46c70dac84a4b3030cd05b380f9f410536690fc Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Wed, 17 Jun 2020 01:43:57 +0300 Subject: [PATCH] libweston: Send wl_keyboard.modifiers after wl_keyboard.enter The core Wayland protocol explicitly states that wl_keyboard.modifiers must be send after wl_keyboard.enter. This commit also changes the behavior of `seat_get_keyboard` to not send `wl_keyboard.modifiers` in case where seat had pointer focus, but not keyboard one. Signed-off-by: Kirill Chibisov --- libweston/input.c | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/libweston/input.c b/libweston/input.c index e348a56b..b4e2c66f 100644 --- a/libweston/input.c +++ b/libweston/input.c @@ -1518,10 +1518,10 @@ send_enter_to_resource_list(struct wl_list *list, struct wl_resource *resource; wl_resource_for_each(resource, list) { - send_modifiers_to_resource(keyboard, resource, serial); wl_keyboard_send_enter(resource, serial, surface->resource, &keyboard->keys); + send_modifiers_to_resource(keyboard, resource, serial); } } @@ -2848,28 +2848,6 @@ static const struct wl_keyboard_interface keyboard_interface = { keyboard_release }; -static bool -should_send_modifiers_to_client(struct weston_seat *seat, - struct wl_client *client) -{ - struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat); - struct weston_pointer *pointer = weston_seat_get_pointer(seat); - - if (keyboard && - keyboard->focus && - keyboard->focus->resource && - wl_resource_get_client(keyboard->focus->resource) == client) - return true; - - if (pointer && - pointer->focus && - pointer->focus->surface->resource && - wl_resource_get_client(pointer->focus->surface->resource) == client) - return true; - - return false; -} - static void seat_get_keyboard(struct wl_client *client, struct wl_resource *resource, uint32_t id) @@ -2915,12 +2893,6 @@ seat_get_keyboard(struct wl_client *client, struct wl_resource *resource, weston_keyboard_send_keymap(keyboard, cr); - if (should_send_modifiers_to_client(seat, client)) { - send_modifiers_to_resource(keyboard, - cr, - keyboard->focus_serial); - } - if (keyboard->focus && keyboard->focus->resource && wl_resource_get_client(keyboard->focus->resource) == client) { struct weston_surface *surface = @@ -2934,6 +2906,10 @@ seat_get_keyboard(struct wl_client *client, struct wl_resource *resource, surface->resource, &keyboard->keys); + send_modifiers_to_resource(keyboard, + cr, + keyboard->focus_serial); + /* If this is the first keyboard resource for this * client... */ if (keyboard->focus_resource_list.prev ==