From 33bf5319baec86e6caef5b94c71db8101fb94343 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Fri, 25 May 2018 20:18:23 +0200
Subject: [PATCH 1/2] window: Don't refuse to move focus to the grab window

We refuse to move focus while a grab operation is in place. While this
generally makes sense, there's no reason why the window that owns the
grab shouldn't be given the regular input focus as well - we pretty
much assume that the grab window is also the focus window anyway.

In fact there's a strong reason for allowing the focus change here:
If the grab window isn't the focus window, it probably has a modal
transient that is focused instead, and a likely reason for the focus
request is that the transient is being unmanaged and we must move
the focus elsewhere.

https://gitlab.gnome.org/GNOME/mutter/issues/15
---
 src/core/window.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/core/window.c b/src/core/window.c
index 743326c60..5b1eb5b68 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -4620,6 +4620,7 @@ meta_window_focus (MetaWindow  *window,
               window->desc, window->input, window->take_focus);
 
   if (window->display->grab_window &&
+      window->display->grab_window != window &&
       window->display->grab_window->all_keys_grabbed &&
       !window->display->grab_window->unmanaging)
     {
-- 
2.17.1


From 149ae05df628480e8226f035044e6020305a8aeb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Fri, 25 May 2018 21:24:17 +0200
Subject: [PATCH 2/2] window: Explicitly exclude unmanaging window from focus
 again

Since commit b3b9d9e16 we no longer have to pass the unmanaging window
to make sure we don't try to focus it again, however the parameter also
influences the focus policy by giving ancestors preference over the normal
stack order.

https://gitlab.gnome.org/GNOME/mutter/issues/15
---
 src/core/window.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/core/window.c b/src/core/window.c
index 5b1eb5b68..cc0813ac4 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -1469,7 +1469,9 @@ meta_window_unmanage (MetaWindow  *window,
       meta_topic (META_DEBUG_FOCUS,
                   "Focusing default window since we're unmanaging %s\n",
                   window->desc);
-      meta_workspace_focus_default_window (window->screen->active_workspace, NULL, timestamp);
+      meta_workspace_focus_default_window (window->screen->active_workspace,
+                                           window,
+                                           timestamp);
     }
   else
     {
-- 
2.17.1

