[mutter] stack-tracker: Keep override redirect windows on top



commit e3d5bc077d0ee5dc0368f99d22ce352c696644b9
Author: Rui Matos <tiagomatos gmail com>
Date:   Fri May 19 17:11:19 2017 +0200

    stack-tracker: Keep override redirect windows on top
    
    Since commit 6b5cf2e, we keep override redirect windows on a layer
    above regular windows in the clutter actor scene graph. In the X
    server, and thus for input purposes, these windows might end up being
    stacked below regular windows though, e.g. because a new regular
    window is mapped after an OR window.
    
    Fix this disconnect by re-stacking OR windows on top when syncing the
    window stack with the compositor.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780485

 src/core/stack-tracker.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/src/core/stack-tracker.c b/src/core/stack-tracker.c
index a76b42c..82afd64 100644
--- a/src/core/stack-tracker.c
+++ b/src/core/stack-tracker.c
@@ -168,6 +168,9 @@ struct _MetaStackTracker
   guint sync_stack_later;
 };
 
+static void
+meta_stack_tracker_keep_override_redirect_on_top (MetaStackTracker *tracker);
+
 static inline const char *
 get_window_desc (MetaStackTracker *tracker,
                  guint64           window)
@@ -835,6 +838,8 @@ meta_stack_tracker_sync_stack (MetaStackTracker *tracker)
       tracker->sync_stack_later = 0;
     }
 
+  meta_stack_tracker_keep_override_redirect_on_top (tracker);
+
   meta_stack_tracker_get_stack (tracker, &windows, &n_windows);
 
   meta_windows = NULL;
@@ -1040,6 +1045,37 @@ meta_stack_tracker_lower (MetaStackTracker *tracker,
   meta_stack_tracker_raise_above (tracker, window, None);
 }
 
+static void
+meta_stack_tracker_keep_override_redirect_on_top (MetaStackTracker *tracker)
+{
+  MetaWindow *window;
+  guint64 *stack;
+  int n_windows, i;
+  int topmost_non_or;
+
+  meta_stack_tracker_get_stack (tracker, &stack, &n_windows);
+
+  for (i = n_windows - 1; i >= 0; i--)
+    {
+      window = meta_display_lookup_stack_id (tracker->screen->display, stack[i]);
+      if (window && window->layer != META_LAYER_OVERRIDE_REDIRECT)
+        break;
+    }
+
+  topmost_non_or = i;
+
+  for (i -= 1; i >= 0; i--)
+    {
+      window = meta_display_lookup_stack_id (tracker->screen->display, stack[i]);
+      if (window && window->layer == META_LAYER_OVERRIDE_REDIRECT)
+        {
+          meta_stack_tracker_raise_above (tracker, stack[i], stack[topmost_non_or]);
+          meta_stack_tracker_get_stack (tracker, &stack, &n_windows);
+          topmost_non_or -= 1;
+        }
+    }
+}
+
 void
 meta_stack_tracker_restack_managed (MetaStackTracker *tracker,
                                     const guint64    *managed,


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