x11: 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 allow moving the X11 focus to a Window when no grab is
in place, just like commit 50e89e376
did for the stage focus.
But particularly the updating of x11_display->focus_xwindow is not
prevented. Since it's more consistent to the MetaDisplay/MetaX11Display
dual focus tracking and across Wayland/X11 backends, ensure the X11
input focus is actually set on the last focus Window after the
grabs are gone and windows became interactable again.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2832>
This commit is contained in:

committed by
Marge Bot

parent
df16cb9fb7
commit
a68b8e9595
@ -2011,6 +2011,10 @@ meta_x11_display_set_input_focus_internal (MetaX11Display *x11_display,
|
||||
Window xwindow,
|
||||
uint32_t timestamp)
|
||||
{
|
||||
if (xwindow != None &&
|
||||
!meta_display_windows_are_interactable (x11_display->display))
|
||||
return;
|
||||
|
||||
meta_x11_error_trap_push (x11_display);
|
||||
|
||||
/* In order for mutter to know that the focus request succeeded, we track
|
||||
@ -2083,6 +2087,22 @@ meta_x11_display_set_input_focus_xwindow (MetaX11Display *x11_display,
|
||||
x11_display->display->last_focus_time = timestamp;
|
||||
}
|
||||
|
||||
void
|
||||
meta_x11_display_sync_input_focus (MetaX11Display *x11_display)
|
||||
{
|
||||
guint timestamp;
|
||||
|
||||
if (!meta_display_windows_are_interactable (x11_display->display))
|
||||
return;
|
||||
|
||||
meta_x11_error_trap_push (x11_display);
|
||||
timestamp = meta_display_get_current_time (x11_display->display);
|
||||
meta_x11_display_set_input_focus_internal (x11_display,
|
||||
x11_display->focus_xwindow,
|
||||
timestamp);
|
||||
meta_x11_error_trap_pop (x11_display);
|
||||
}
|
||||
|
||||
static MetaX11DisplayLogicalMonitorData *
|
||||
get_x11_display_logical_monitor_data (MetaLogicalMonitor *logical_monitor)
|
||||
{
|
||||
|
Reference in New Issue
Block a user