[metacity/wip/muktupavels/issue-31: 2/2] workspace: focus only ancestors that are focusable




commit 398fa63cff7b791e78c0a7b7e2234b0344959819
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Oct 3 20:19:38 2022 +0300

    workspace: focus only ancestors that are focusable
    
    Based on mutter commit:
    https://gitlab.gnome.org/GNOME/mutter/-/commit/eccc791f3b3451216f957e67fec47a73b65ed2b2

 src/core/workspace.c | 39 ++++++++++++++++++++++++++++++++-------
 1 file changed, 32 insertions(+), 7 deletions(-)
---
diff --git a/src/core/workspace.c b/src/core/workspace.c
index 19e3a9a8..45306dd6 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -969,14 +969,30 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace,
     }
 }
 
+typedef struct
+{
+  MetaWorkspace *workspace;
+  MetaWindow    *ancestor;
+} FindFocusableAncestorData;
+
 static gboolean
-record_ancestor (MetaWindow *window,
-                 void       *data)
+find_focusable_ancestor (MetaWindow *window,
+                         gpointer    user_data)
 {
-  MetaWindow **result = data;
+  FindFocusableAncestorData *data;
 
-  *result = window;
-  return FALSE; /* quit with the first ancestor we find */
+  data = user_data;
+
+  if (!window->unmanaging &&
+      meta_window_is_focusable (window) &&
+      meta_window_located_on_workspace (window, data->workspace) &&
+      meta_window_showing_on_its_workspace (window))
+    {
+      data->ancestor = window;
+      return FALSE;
+    }
+
+  return TRUE;
 }
 
 /* Focus ancestor of not_this_one if there is one */
@@ -998,8 +1014,17 @@ focus_ancestor_or_top_window (MetaWorkspace *workspace,
   if (not_this_one)
     {
       MetaWindow *ancestor;
-      ancestor = NULL;
-      meta_window_foreach_ancestor (not_this_one, record_ancestor, &ancestor);
+      FindFocusableAncestorData data;
+
+      data.workspace = workspace;
+      data.ancestor = NULL;
+
+      meta_window_foreach_ancestor (not_this_one,
+                                    find_focusable_ancestor,
+                                    &data);
+
+      ancestor = data.ancestor;
+
       if (ancestor != NULL)
         {
           meta_topic (META_DEBUG_FOCUS,


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