From 0f07f98ae22cc769a57e85c19ecb5397c2084488 Mon Sep 17 00:00:00 2001
From: markt <markt>
Date: Thu, 25 Jan 2007 18:09:11 +0000
Subject: don't raise windows above OverrideRedirect windows, or else they
 eventually get restacked on the bottom

---
 ChangeLog          |  3 +++
 src/FbTk/XLayer.cc | 42 ++++++++++++++----------------------------
 2 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d889d42..1c9ea69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
  (Format: Year/Month/Day)
 Changes for 1.0rc3:
+*07/01/25:
+   * Don't raise any windows above OverrideRedirect windows, otherwise they
+     eventually get pushed to the bottomm, bug #1447583 (Mark)
 *07/01/24:
    * Detect user's shell from environment rather than assuming /bin/sh (Mark)
      FbCommands.cc
diff --git a/src/FbTk/XLayer.cc b/src/FbTk/XLayer.cc
index 0341563..8e1dfc1 100644
--- a/src/FbTk/XLayer.cc
+++ b/src/FbTk/XLayer.cc
@@ -90,38 +90,24 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) {
     if (!m_manager.isUpdatable())
         return;
 
-    Window *winlist;
-    size_t winnum, size, num = item->numWindows();
-
     // if there are no windows provided for above us,
-    // then we must have to go right to the top of the stack
+    // then we must restack the entire layer
+    // we can't do XRaiseWindow because a restack then causes OverrideRedirect
+    // windows to get pushed to the bottom
     if (!above) { // must need to go right to top
-        if (item->getWindows().front()->window())
-            XRaiseWindow(FbTk::App::instance()->display(), item->getWindows().front()->window());
-
-        // if this XLayerItem has more than one window,
-        // then we'll stack the rest in under the front one too
-        // our size needs to be the number of windows in the group, since there isn't one above.
-        if (num > 1) {
-            winnum = 0;
-            // stack relative to top one (just raised)
-            size = num;
-            winlist = new Window[size];
-        } else {
-            // we've raised the window, nothing else to do
-            return;
-        }
-    } else {
-        // We do have a window to stack below
-
-        // so we put it on top, and fill the rest of the array with the ones to go below it.
-        winnum = 1;
-        size = num+1;
-        winlist = new Window[size];
-        // assume that above's window exists
-        winlist[0] = above->getWindows().back()->window();
+        restack();
+        return;
     }
 
+    Window *winlist;
+    size_t winnum = 1, size = item->numWindows()+1;
+
+    // We do have a window to stack below
+    // so we put it on top, and fill the rest of the array with the ones to go below it.
+    winlist = new Window[size];
+    // assume that above's window exists
+    winlist[0] = above->getWindows().back()->window();
+
     // fill the rest of the array
     XLayerItem::Windows::iterator it = item->getWindows().begin();
     XLayerItem::Windows::iterator it_end = item->getWindows().end();
-- 
cgit v0.11.2