[mutter/wip/carlosg/ignore-focus-on-grabs: 3/3] core: Avoid focusing window in presence of Clutter grabs




commit 50e89e37600509676fb4e284316e275864505460
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri May 27 14:14:31 2022 +0200

    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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2433>

 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 95ea18f2c8..95a8e33e04 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))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]