kathenas / rpms / mutter

Forked from rpms/mutter 5 years ago
Clone

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

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