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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3704>
This commit is contained in:
Carlos Garnacho 2024-04-15 18:29:08 +02:00 committed by Marge Bot
parent 3b5f467163
commit d214583aa2

View File

@ -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 *