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




commit 5b66b14127d740506a171d2bc48bbe72a02832af
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.
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4858

 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..d3e509ea75 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]