Blob Blame History Raw
From 8c97b4bc745dea0d15fcaf0e9e08093e172c882d Mon Sep 17 00:00:00 2001
From: "Jasper St. Pierre" <jstpierre@mecheye.net>
Date: Sun, 5 Jul 2015 14:31:17 -0700
Subject: [PATCH] stack: Don't prefer windows in the same group as not_this_one

The only time we ever execute this code is when we're minimizing or
hiding a window, in which case we should respect stacking order.

This fixes weird "bugs" where windows from the same app magically pop up
over other windows.
---
 src/core/stack.c | 43 ++++---------------------------------------
 1 file changed, 4 insertions(+), 39 deletions(-)

diff --git a/src/core/stack.c b/src/core/stack.c
index f618ef2..32e252e 100644
--- a/src/core/stack.c
+++ b/src/core/stack.c
@@ -1238,24 +1238,10 @@ get_default_focus_window (MetaStack     *stack,
 {
   /* Find the topmost, focusable, mapped, window.
    * not_this_one is being unfocused or going away, so exclude it.
-   * Also, prefer to focus transient parent of not_this_one,
-   * or top window in same group as not_this_one.
    */
 
-  MetaWindow *transient_parent;
-  MetaWindow *topmost_in_group;
-  MetaWindow *topmost_overall;
-  MetaGroup *not_this_one_group;
   GList *l;
 
-  transient_parent = NULL;
-  topmost_in_group = NULL;
-  topmost_overall = NULL;
-  if (not_this_one)
-    not_this_one_group = meta_window_get_group (not_this_one);
-  else
-    not_this_one_group = NULL;
-
   stack_ensure_sorted (stack);
 
   /* top of this layer is at the front of the list */
@@ -1284,34 +1270,13 @@ get_default_focus_window (MetaStack     *stack,
       if (must_be_at_point && !window_contains_point (window, root_x, root_y))
         continue;
 
-      if (not_this_one != NULL)
-        {
-          if (transient_parent == NULL &&
-              meta_window_get_transient_for (not_this_one) == window)
-            transient_parent = window;
-
-          if (topmost_in_group == NULL &&
-              not_this_one_group != NULL &&
-              not_this_one_group == meta_window_get_group (window))
-            topmost_in_group = window;
-        }
-
-      if (topmost_overall == NULL && window->type != META_WINDOW_DOCK)
-        topmost_overall = window;
+      if (window->type == META_WINDOW_DOCK)
+        continue;
 
-      /* We could try to bail out early here for efficiency in
-       * some cases, but it's just not worth the code.
-       */
+      return window;
     }
 
-  if (transient_parent)
-    return transient_parent;
-  else if (topmost_in_group)
-    return topmost_in_group;
-  else if (topmost_overall)
-    return topmost_overall;
-  else
-    return NULL;
+  return NULL;
 }
 
 MetaWindow*
-- 
2.7.4