From 50e89e37600509676fb4e284316e275864505460 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 27 May 2022 14:14:31 +0200 Subject: [PATCH] core: Avoid focusing window in presence of Clutter grabs This is the same circumstance than the event_route not being NORMAL, since events may or may not eventually reach the window. It should not attempt to get focus out of the stage in that situation. This used to be covered by META_EVENT_ROUTE_COMPOSITOR_GRAB, but this is no longer set when ClutterGrab came in to replace it. Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4858 Part-of: --- src/core/window.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/window.c b/src/core/window.c index 95ea18f2c..95a8e33e0 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -4502,6 +4502,8 @@ meta_window_focus (MetaWindow *window, { MetaWorkspaceManager *workspace_manager = window->display->workspace_manager; MetaWindow *modal_transient; + MetaBackend *backend; + ClutterStage *stage; g_return_if_fail (!window->override_redirect); @@ -4548,12 +4550,12 @@ meta_window_focus (MetaWindow *window, META_WINDOW_GET_CLASS (window)->focus (window, timestamp); - if (window->display->event_route == META_EVENT_ROUTE_NORMAL) - { - MetaBackend *backend = meta_get_backend (); - ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend)); - clutter_stage_set_key_focus (stage, NULL); - } + backend = meta_get_backend (); + stage = CLUTTER_STAGE (meta_backend_get_stage (backend)); + + if (window->display->event_route == META_EVENT_ROUTE_NORMAL && + clutter_stage_get_grab_actor (stage) == NULL) + clutter_stage_set_key_focus (stage, NULL); if (window->close_dialog && meta_close_dialog_is_visible (window->close_dialog))