From d214583aa22074aaa0fd14539593b6db071088cd Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 15 Apr 2024 18:29:08 +0200 Subject: [PATCH] wayland: Do not bypass MetaWaylandInput changing keyboard focus In every other device and circumstance, we update the logical focus (i.e. the surface that would be focused, if no other circumstances applied) but let the MetaWaylandInput figure out the surface that should be effectively focused, if at all. This is where we apply the actual compositor state (e.g. grabs) and result in an effective focus window. The only exception to this is `meta_wayland_seat_set_input_focus()` where the logical focus for keyboards and related devices is set, but also applied as the effective surface. We should do the same as everywhere else, and let MetaWaylandInput focus determine whether the logical focus is also the effective focus. These replaced set_focus() internal calls will happen through the default MetaWaylandEventInterface.focus implementation in MetaWaylandSeat. This resulted in keyboard focus being set on windows in circumstances it ought not to, like in the overview. Actual key events were never sent in these circumstances, but changes to modifier state could. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7528 Part-of: --- src/wayland/meta-wayland-seat.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c index ebbe533c3..ea4d4608c 100644 --- a/src/wayland/meta-wayland-seat.c +++ b/src/wayland/meta-wayland-seat.c @@ -531,6 +531,8 @@ void meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat, MetaWaylandSurface *surface) { + ClutterSeat *clutter_seat; + if (seat->input_focus == surface) return; @@ -551,16 +553,10 @@ meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat, seat); } - if (meta_wayland_seat_has_keyboard (seat)) - { - meta_wayland_keyboard_set_focus (seat->keyboard, surface); - meta_wayland_data_device_set_keyboard_focus (&seat->data_device); - meta_wayland_data_device_primary_set_keyboard_focus (&seat->primary_data_device); - } - - meta_wayland_tablet_seat_set_pad_focus (seat->tablet_seat, surface); - - meta_wayland_text_input_set_focus (seat->text_input, surface); + clutter_seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); + meta_wayland_input_invalidate_focus (seat->input_handler, + clutter_seat_get_keyboard (clutter_seat), + NULL); } MetaWaylandSurface *