mutter/0001-x11-Avoid-updating-focus-on-wayland-compositor.patch
2023-03-05 13:09:23 -05:00

103 lines
3.9 KiB
Diff

From faa003812c10ab14bc69d6add078ff10528dc78b Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Mon, 13 Feb 2023 20:12:38 +0100
Subject: [PATCH 1/3] x11: Avoid updating focus on wayland compositor
Reading upon the history of this code branch (commits 6891ce95dce
and 7a4c808e43d4 are most relevant), it seems this code is meant to
synchronize Mutter focus state taking the Xserver state as true.
That is, if Mutter tried to change the focus but something truncated
that action, Mutter focus will be changed to be in sync with the
Xserver again.
This sounds backwards in a Wayland session. Mutter focus should be
the canonical source, and not second-guessed from the current Xserver
focus window. These race conditions might still apply between X11
clients, so make these paths only apply in that case.
An example of this breaking can be reproduced with a Spotify and
Firefox window, moving the focus from the first to the second by
going to the GNOME Shell overview in between, and clicking the
Firefox window from there. The Firefox window will be raised, but
refuse to take focus.
It's unclear what made this an issue recently, perhaps commit
0e6395d9328 since the now possibly ignored XI_FocusIn/Out events
affect this accounting of the Xserver focused window. Anyhow it
sounds better to ignore these paths for Wayland/native altogether.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2841>
---
src/x11/events.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/x11/events.c b/src/x11/events.c
index fd0f84c4a..89733ba33 100644
--- a/src/x11/events.c
+++ b/src/x11/events.c
@@ -1928,60 +1928,61 @@ meta_x11_display_handle_xevent (MetaX11Display *x11_display,
bypass_gtk = bypass_compositor = TRUE;
goto out;
}
#ifdef HAVE_XWAYLAND
wayland_compositor = meta_context_get_wayland_compositor (context);
if (meta_is_wayland_compositor () &&
meta_xwayland_manager_handle_xevent (&wayland_compositor->xwayland_manager,
event))
{
bypass_gtk = bypass_compositor = TRUE;
goto out;
}
#endif
if (process_selection_event (x11_display, event))
{
bypass_gtk = bypass_compositor = TRUE;
goto out;
}
display->current_time = event_get_time (x11_display, event);
if (META_IS_BACKEND_X11 (backend))
meta_backend_x11_handle_event (META_BACKEND_X11 (backend), event);
if (x11_display->focused_by_us &&
event->xany.serial > x11_display->focus_serial &&
display->focus_window &&
+ display->focus_window->client_type == META_WINDOW_CLIENT_TYPE_X11 &&
!window_has_xwindow (display->focus_window, x11_display->server_focus_window) &&
meta_display_windows_are_interactable (display))
{
meta_topic (META_DEBUG_FOCUS, "Earlier attempt to focus %s failed",
display->focus_window->desc);
meta_x11_display_update_focus_window (x11_display,
x11_display->server_focus_window,
x11_display->server_focus_serial,
FALSE);
meta_display_update_focus_window (display,
meta_x11_display_lookup_x_window (x11_display,
x11_display->server_focus_window));
}
if (event->xany.window == x11_display->xroot)
{
cursor_tracker = meta_backend_get_cursor_tracker (backend);
if (META_IS_CURSOR_TRACKER_X11 (cursor_tracker))
{
MetaCursorTrackerX11 *cursor_tracker_x11 =
META_CURSOR_TRACKER_X11 (cursor_tracker);
if (meta_cursor_tracker_x11_handle_xevent (cursor_tracker_x11, event))
{
bypass_gtk = bypass_compositor = TRUE;
goto out;
}
}
}
--
2.39.2