Blame SOURCES/0001-workspace-Focus-only-ancestors-that-are-focusable.patch

657d8e
From eca25ab6a12770a2a767458d9b0129d4fde3995c Mon Sep 17 00:00:00 2001
657d8e
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
657d8e
Date: Tue, 13 Nov 2018 08:31:52 +0100
657d8e
Subject: [PATCH 1/2] workspace: Focus only ancestors that are focusable
657d8e
657d8e
When destroying a window that has a parent, we initially try to focus one of
657d8e
its ancestors. However if no ancestor can be focused, then we should instead
657d8e
focus the default focus window instead of trying to request focus for a window
657d8e
that can't get focus anyways.
657d8e
657d8e
Fixes https://gitlab.gnome.org/GNOME/mutter/issues/308
657d8e
(cherry picked from commit eccc791f3b3451216f957e67fec47a73b65ed2b2)
657d8e
---
657d8e
 src/core/workspace.c | 37 +++++++++++++++++++++++++++----------
657d8e
 1 file changed, 27 insertions(+), 10 deletions(-)
657d8e
657d8e
diff --git a/src/core/workspace.c b/src/core/workspace.c
657d8e
index f2b2c2c48..58fcfa78c 100644
657d8e
--- a/src/core/workspace.c
657d8e
+++ b/src/core/workspace.c
657d8e
@@ -85,6 +85,12 @@ typedef struct _MetaWorkspaceLogicalMonitorData
657d8e
   MetaRectangle logical_monitor_work_area;
657d8e
 } MetaWorkspaceLogicalMonitorData;
657d8e
 
657d8e
+typedef struct _MetaWorkspaceFocusableAncestorData
657d8e
+{
657d8e
+  MetaWorkspace *workspace;
657d8e
+  MetaWindow *out_window;
657d8e
+} MetaWorkspaceFocusableAncestorData;
657d8e
+
657d8e
 static MetaWorkspaceLogicalMonitorData *
657d8e
 meta_workspace_get_logical_monitor_data (MetaWorkspace      *workspace,
657d8e
                                          MetaLogicalMonitor *logical_monitor)
657d8e
@@ -1322,13 +1328,20 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace,
657d8e
 }
657d8e
 
657d8e
 static gboolean
657d8e
-record_ancestor (MetaWindow *window,
657d8e
-                 void       *data)
657d8e
+find_focusable_ancestor (MetaWindow *window,
657d8e
+                         gpointer    user_data)
657d8e
 {
657d8e
-  MetaWindow **result = data;
657d8e
+  MetaWorkspaceFocusableAncestorData *data = user_data;
657d8e
+
657d8e
+  if (!window->unmanaging && meta_window_is_focusable (window) &&
657d8e
+      meta_window_located_on_workspace (window, data->workspace) &&
657d8e
+      meta_window_showing_on_its_workspace (window))
657d8e
+    {
657d8e
+      data->out_window = window;
657d8e
+      return FALSE;
657d8e
+    }
657d8e
 
657d8e
-  *result = window;
657d8e
-  return FALSE; /* quit with the first ancestor we find */
657d8e
+  return TRUE;
657d8e
 }
657d8e
 
657d8e
 /* Focus ancestor of not_this_one if there is one */
657d8e
@@ -1350,11 +1363,15 @@ focus_ancestor_or_top_window (MetaWorkspace *workspace,
657d8e
   if (not_this_one)
657d8e
     {
657d8e
       MetaWindow *ancestor;
657d8e
-      ancestor = NULL;
657d8e
-      meta_window_foreach_ancestor (not_this_one, record_ancestor, &ancestor);
657d8e
-      if (ancestor != NULL &&
657d8e
-          meta_window_located_on_workspace (ancestor, workspace) &&
657d8e
-          meta_window_showing_on_its_workspace (ancestor))
657d8e
+      MetaWorkspaceFocusableAncestorData data;
657d8e
+
657d8e
+      data = (MetaWorkspaceFocusableAncestorData) {
657d8e
+        .workspace = workspace,
657d8e
+      };
657d8e
+      meta_window_foreach_ancestor (not_this_one, find_focusable_ancestor, &data);
657d8e
+      ancestor = data.out_window;
657d8e
+
657d8e
+      if (ancestor)
657d8e
         {
657d8e
           meta_topic (META_DEBUG_FOCUS,
657d8e
                       "Focusing %s, ancestor of %s\n",
657d8e
-- 
657d8e
2.21.0
657d8e