x11: Defer ClutterStage focus actor change until window is focused

If we happen to be changing focus to a window *while* taking focus
away from Clutter widgetry, we would unintendedly trigger reentrance
in a way that the old focused window remained in focus, by asking
to focus the default focus window in an untimely manner.

To handle this reentrancy, delay dropping the Clutter key focus
until the window focus changed, so that the focus change will look
up the default focused window in the workspace, and find the up to
date one.

Fixes: ae102ee301 ("x11: Refactor ClutterStage key focus management")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3467>
This commit is contained in:
Carlos Garnacho 2023-12-19 13:52:28 +01:00
parent 5378b10a00
commit 54e4d1df79

View File

@ -2104,11 +2104,8 @@ meta_x11_display_set_input_focus (MetaX11Display *x11_display,
xwindow = window->frame->xwindow;
else
xwindow = meta_window_x11_get_xwindow (window);
#ifdef HAVE_X11
if (!meta_is_wayland_compositor ())
clutter_stage_set_key_focus (stage, NULL);
}
#ifdef HAVE_X11
else if (!meta_is_wayland_compositor () &&
stage_has_focus_actor (x11_display))
{
@ -2117,8 +2114,6 @@ meta_x11_display_set_input_focus (MetaX11Display *x11_display,
*/
xwindow = meta_x11_get_stage_window (stage);
}
#else
}
#endif
meta_topic (META_DEBUG_FOCUS, "Setting X11 input focus for window %s to 0x%lx",
@ -2129,6 +2124,11 @@ meta_x11_display_set_input_focus (MetaX11Display *x11_display,
serial = XNextRequest (x11_display->xdisplay);
meta_x11_display_update_focus_window (x11_display, xwindow, serial, TRUE);
mtk_x11_error_trap_pop (x11_display->xdisplay);
#ifdef HAVE_X11
if (window && !meta_is_wayland_compositor ())
clutter_stage_set_key_focus (stage, NULL);
#endif
}
static MetaX11DisplayLogicalMonitorData *