display: Do not move X11 input focus during grabs

On X11, the stage itself is backed by an XWindow, and moving the
input focus elsewhere will bypass any Clutter-level grabs.

This effectively allows newly opened windows to steal the focus
from gnome-shell itself, which is clearly undesirable. To prevent
that, only move the X11 focus when no grab is in place, just like
commit 50e89e376 did for the stage focus.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5932

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2776>
This commit is contained in:
Florian Müllner 2022-12-20 20:22:40 +01:00 committed by Marge Bot
parent 24f796a30c
commit 7531669b4f

View File

@ -1553,7 +1553,9 @@ meta_display_set_input_focus (MetaDisplay *display,
if (meta_display_timestamp_too_old (display, &timestamp))
return;
if (display->x11_display)
if (display->x11_display &&
meta_display_windows_are_interactable (display))
{
meta_x11_display_set_input_focus (display->x11_display, window,
focus_frame, timestamp);