From 81778a16bb9fddc59c89b659b329ed6be9cd24d5 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Wed, 4 Feb 2026 11:41:28 -0500 Subject: [PATCH] xwayland: flush X11 connection after focus/activate This mitigates a race where the XWayland server may generate an unwanted FocusOut event for the newly activated window, if it receives mouse/ pointer events over the parallel wayland connection first. In particular, this fixes an issue with certain fullscreen applications (such as Minecraft) that self-minimize when receiving FocusOut. Also limit a previous similar workaround to apply only to XWayland views. Fixes: #3344 See also: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/4044 --- src/view.c | 4 +++- src/xwayland.c | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/view.c b/src/view.c index 40f047b2..1a622bc3 100644 --- a/src/view.c +++ b/src/view.c @@ -2242,7 +2242,9 @@ view_move_to_front(struct view *view) * to an incorrect X window depending on timing. To mitigate the * race, perform an explicit flush after restacking. */ - xwayland_flush(view->server); + if (view->type == LAB_XWAYLAND_VIEW) { + xwayland_flush(view->server); + } #endif cursor_update_focus(view->server); desktop_update_top_layer_visibility(view->server); diff --git a/src/xwayland.c b/src/xwayland.c index 5984a31b..2f07adb5 100644 --- a/src/xwayland.c +++ b/src/xwayland.c @@ -946,6 +946,14 @@ xwayland_view_set_activated(struct view *view, bool activated) } wlr_xwayland_surface_activate(xwayland_surface, activated); + /* + * Make sure that the X11-protocol messages (SetInputFocus etc.) + * are sent immediately. This mitigates a race where the XWayland + * server may generate an unwanted FocusOut event for the newly + * activated window, if it receives mouse/pointer events over the + * parallel wayland connection first. + */ + xwayland_flush(view->server); } static void