From 26602d08e2c59deb77a2e22b451b903377b85e15 Mon Sep 17 00:00:00 2001
From: Joel Bosveld <Joel.Bosveld@gmail.com>
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

