[metacity] stack: Flatten and simplify the default focus window logic



commit 8ca270311c26b6587043344b0fb6774bf9157971
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Mar 18 10:17:34 2014 -0400

    stack: Flatten and simplify the default focus window logic

 src/core/stack.c |   79 +++++++++++++++++++++++++++--------------------------
 1 files changed, 40 insertions(+), 39 deletions(-)
---
diff --git a/src/core/stack.c b/src/core/stack.c
index 3e90bd0..9a229e0 100644
--- a/src/core/stack.c
+++ b/src/core/stack.c
@@ -1392,7 +1392,7 @@ get_default_focus_window (MetaStack     *stack,
   MetaWindow *topmost_in_group;
   MetaWindow *topmost_overall;
   MetaGroup *not_this_one_group;
-  GList *link;
+  GList *l;
 
   transient_parent = NULL;
   topmost_in_group = NULL;
@@ -1405,49 +1405,50 @@ get_default_focus_window (MetaStack     *stack,
   stack_ensure_sorted (stack);
 
   /* top of this layer is at the front of the list */
-  link = stack->sorted;
-
-  while (link)
+  for (l = stack->sorted; l != NULL; l = l->next)
     {
-      MetaWindow *window = link->data;
+      MetaWindow *window = l->data;
 
-      if (window &&
-          window != not_this_one &&
-          (window->unmaps_pending == 0) &&
-          !window->minimized &&
-          (window->input || window->take_focus) &&
-          (workspace == NULL ||
-           meta_window_located_on_workspace (window, workspace)))
-        {
-          if (not_this_one != NULL)
-            {
-              if (transient_parent == NULL &&
-                  not_this_one->xtransient_for != None &&
-                  not_this_one->xtransient_for == window->xwindow &&
-                  (!must_be_at_point ||
-                   window_contains_point (window, root_x, root_y)))
-                transient_parent = window;
-
-              if (topmost_in_group == NULL &&
-                  not_this_one_group != NULL &&
-                  not_this_one_group == meta_window_get_group (window) &&
-                  (!must_be_at_point ||
-                   window_contains_point (window, root_x, root_y)))
-                topmost_in_group = window;
-            }
+      if (!window)
+        continue;
 
-          if (topmost_overall == NULL &&
-              window->type != META_WINDOW_DOCK &&
-              (!must_be_at_point ||
-               window_contains_point (window, root_x, root_y)))
-            topmost_overall = window;
+      if (window == not_this_one)
+        continue;
 
-          /* We could try to bail out early here for efficiency in
-           * some cases, but it's just not worth the code.
-           */
+      if (window->unmaps_pending > 0)
+        continue;
+
+      if (window->minimized)
+        continue;
+
+      if (!(window->input || window->take_focus))
+        continue;
+
+      if (workspace != NULL && !meta_window_located_on_workspace (window, workspace))
+        continue;
+
+      if (must_be_at_point && !window_contains_point (window, root_x, root_y))
+        continue;
+
+      if (not_this_one != NULL)
+        {
+          if (transient_parent == NULL &&
+              not_this_one->xtransient_for != None &&
+              not_this_one->xtransient_for == window->xwindow)
+            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;
         }
 
-      link = link->next;
+      if (topmost_overall == NULL && window->type != META_WINDOW_DOCK)
+        topmost_overall = window;
+
+      /* We could try to bail out early here for efficiency in
+       * some cases, but it's just not worth the code.
+       */
     }
 
   if (transient_parent)


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