I have attached two patches to make the restack functions immediately
reorder list, so that calling multiple raise, lower or restack* functions
will result in the expected behaviour.

Incase they don't send properly (again), I have also uploaded them here:

http://joel.bosveld.googlepages.com/0001-Restack-window-list-immediately-whe
http://joel.bosveld.googlepages.com/0002-Restack-windows-in-reverse-and-stac

-----

>From b4c3f63b143698d64046aa1fcd82dea47d261d11 Mon Sep 17 00:00:00 2001
From: Joel Bosveld <[email protected]>
Date: Tue, 7 Apr 2009 07:33:42 +0800
Subject: [PATCH] Restack window list immediately when calling
reconfigureXWindow

Previously, trying to restack multiple windows wouldn't work as expected, as
the window list wasn't restacked until the configureNotify was recieved,
which lead to it stacking the window above the wrong window
---
 src/privatewindow.h |    7 +++++--
 src/window.cpp      |   47 +++++++++++++++++++++++++++++++++--------------
 2 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/src/privatewindow.h b/src/privatewindow.h
index e54c096..1f2c600 100644
--- a/src/privatewindow.h
+++ b/src/privatewindow.h
@@ -84,9 +84,12 @@ class PrivateWindow {

     static bool stackTransients (CompWindow     *w,
                      CompWindow     *avoid,
-                     XWindowChanges *xwc);
+                     XWindowChanges *xwc,
+                     CompWindowList &updateList);

-    static void stackAncestors (CompWindow *w, XWindowChanges *xwc);
+    static void stackAncestors (CompWindow *w,
+                    XWindowChanges *xwc,
+                    CompWindowList &updateList);

     static bool isAncestorTo (CompWindow *transient,
                   CompWindow *ancestor);
diff --git a/src/window.cpp b/src/window.cpp
index 2303ccd..21dd708 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -2253,6 +2253,14 @@ PrivateWindow::reconfigureXWindow (unsigned int
valueMask,
     if (valueMask & CWBorderWidth)
     serverGeometry.setBorder (xwc->border_width);

+    if (valueMask & (CWSibling | CWStackMode))
+    {
+    if (xwc->stack_mode == Above)
+        restack (xwc->sibling);
+    else
+        compLogMessage ("core", CompLogLevelWarn, "restack_mode not
Above");
+    }
+
     if (frame)
     {
     XWindowChanges wc = *xwc;
@@ -2279,7 +2287,8 @@ PrivateWindow::reconfigureXWindow (unsigned int
valueMask,
 bool
 PrivateWindow::stackTransients (CompWindow    *w,
                 CompWindow    *avoid,
-                XWindowChanges *xwc)
+                XWindowChanges *xwc,
+                CompWindowList &updateList)
 {
     CompWindow *t;
     Window     clientLeader = w->priv->clientLeader;
@@ -2299,7 +2308,7 @@ PrivateWindow::stackTransients (CompWindow    *w,
         if (!(t->priv->type & CompWindowTypeDockMask))
             return false;

-        if (!stackTransients (t, avoid, xwc))
+        if (!stackTransients (t, avoid, xwc, updateList))
         return false;

         if (xwc->sibling == t->priv->id ||
@@ -2307,7 +2316,7 @@ PrivateWindow::stackTransients (CompWindow    *w,
         return false;

         if (t->priv->mapNum || t->priv->pendingMaps)
-        t->priv->reconfigureXWindow (CWSibling | CWStackMode, xwc);
+        updateList.push_back (t);
     }
     }

@@ -2316,7 +2325,8 @@ PrivateWindow::stackTransients (CompWindow    *w,

 void
 PrivateWindow::stackAncestors (CompWindow     *w,
-                   XWindowChanges *xwc)
+                   XWindowChanges *xwc,
+                   CompWindowList &updateList)
 {
     CompWindow *transient = NULL;

@@ -2332,7 +2342,7 @@ PrivateWindow::stackAncestors (CompWindow     *w,
     ancestor = screen->findWindow (w->priv->transientFor);
     if (ancestor)
     {
-        if (!stackTransients (ancestor, w, xwc))
+        if (!stackTransients (ancestor, w, xwc, updateList))
         return;

         if (ancestor->priv->type & CompWindowTypeDesktopMask)
@@ -2343,10 +2353,9 @@ PrivateWindow::stackAncestors (CompWindow     *w,
             return;

         if (ancestor->priv->mapNum || ancestor->priv->pendingMaps)
-        ancestor->priv->reconfigureXWindow (CWSibling | CWStackMode,
-                            xwc);
+        updateList.push_back (ancestor);

-        stackAncestors (ancestor, xwc);
+        stackAncestors (ancestor, xwc, updateList);
     }
     }
     else if (w->priv->isGroupTransient (w->priv->clientLeader))
@@ -2363,7 +2372,7 @@ PrivateWindow::stackAncestors (CompWindow     *w,
             (a->priv->frame && xwc->sibling == a->priv->frame))
             break;

-        if (!stackTransients (a, w, xwc))
+        if (!stackTransients (a, w, xwc, updateList))
             break;

         if (a->priv->type & CompWindowTypeDesktopMask)
@@ -2374,7 +2383,7 @@ PrivateWindow::stackAncestors (CompWindow     *w,
             break;

         if (a->priv->mapNum || a->priv->pendingMaps)
-            a->priv->reconfigureXWindow (CWSibling | CWStackMode, xwc);
+            updateList.push_back (a);
         }
     }
     }
@@ -2386,13 +2395,22 @@ CompWindow::configureXWindow (unsigned int
valueMask,
 {
     if (priv->managed && (valueMask & (CWSibling | CWStackMode)))
     {
+    CompWindowList transients;
+    CompWindowList ancestors;
+
     /* transient children above */
-    if (PrivateWindow::stackTransients (this, NULL, xwc))
+    if (PrivateWindow::stackTransients (this, NULL, xwc, transients))
     {
-        priv->reconfigureXWindow (valueMask, xwc);
-
         /* ancestors, siblings and sibling transients below */
-        PrivateWindow::stackAncestors (this, xwc);
+        PrivateWindow::stackAncestors (this, xwc, ancestors);
+
+        foreach (CompWindow *w, transients)
+        w->priv->reconfigureXWindow (CWSibling | CWStackMode, xwc);
+
+        this->priv->reconfigureXWindow (valueMask, xwc);
+
+        foreach (CompWindow *w, ancestors)
+        w->priv->reconfigureXWindow (CWSibling | CWStackMode, xwc);
     }
     }
     else
@@ -2868,6 +2886,7 @@ PrivateWindow::addWindowStackChanges (XWindowChanges
*xwc,
         XLowerWindow (screen->dpy (), id);
         if (frame)
             XLowerWindow (screen->dpy (), frame);
+        restack (0);
         }
         else if (sibling->priv->id != window->prev->priv->id)
         {
-- 
1.6.0.3


>From 26602d08e2c59deb77a2e22b451b903377b85e15 Mon Sep 17 00:00:00 2001
From: Joel Bosveld <[email protected]>
Date: Tue, 7 Apr 2009 08:02:50 +0800
Subject: [PATCH] Restack windows in reverse, and stack above correct window.

Previously this worked due to the order that the events arived in, however,
now we want it to be stacked above correct window straight away so that we
do not restack it again when configureNotify event comes through
---
 src/window.cpp |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/window.cpp b/src/window.cpp
index 21dd708..fea610c 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -2404,13 +2404,22 @@ CompWindow::configureXWindow (unsigned int
valueMask,
         /* ancestors, siblings and sibling transients below */
         PrivateWindow::stackAncestors (this, xwc, ancestors);

-        foreach (CompWindow *w, transients)
-        w->priv->reconfigureXWindow (CWSibling | CWStackMode, xwc);
+        for (CompWindowList::reverse_iterator w = ancestors.rbegin ();
+         w != ancestors.rend (); w++)
+        {
+        (*w)->priv->reconfigureXWindow (CWSibling | CWStackMode, xwc);
+        xwc->sibling = (*w)->frame ();
+        }

         this->priv->reconfigureXWindow (valueMask, xwc);
+        xwc->sibling = this->frame ();

-        foreach (CompWindow *w, ancestors)
-        w->priv->reconfigureXWindow (CWSibling | CWStackMode, xwc);
+        for (CompWindowList::reverse_iterator w = transients.rbegin ();
+         w != transients.rend (); w++)
+        {
+        (*w)->priv->reconfigureXWindow (CWSibling | CWStackMode, xwc);
+        xwc->sibling = (*w)->frame ();
+        }
     }
     }
     else
-- 
1.6.0.3

Attachment: 0001-Restack-window-list-immediately-when-calling-reconfi.patch
Description: Binary data

Attachment: 0002-Restack-windows-in-reverse-and-stack-above-correct.patch
Description: Binary data

_______________________________________________
Dev mailing list
[email protected]
http://lists.compiz-fusion.org/mailman/listinfo/dev

Reply via email to