[gtk+] [broadway] More complete handling of transient parent



commit 4bbc45380b772aea148e81259dc5da9d778d2553
Author: Alexander Larsson <alexl redhat com>
Date:   Mon Apr 11 17:48:21 2011 +0200

    [broadway] More complete handling of transient parent
    
    We now handle any order of transient being set and windows shown/created

 gdk/broadway/broadway.js |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js
index 97858fd..b75bcf6 100644
--- a/gdk/broadway/broadway.js
+++ b/gdk/broadway/broadway.js
@@ -318,7 +318,7 @@ function unregisterWindow(win)
 
 function getTransientToplevel(surface)
 {
-    while (surface.transientParent != 0) {
+    while (surface && surface.transientParent != 0) {
 	surface = surfaces[surface.transientParent];
 	if (surface && surface.window)
 	    return surface;
@@ -522,8 +522,12 @@ function cmdSetTransientFor(id, parentId)
 	return;
 
     surface.transientParent = parentId;
-    if (surface.visible && surface.isTemp) {
-	alert("TODO: move temps between transient parents when visible");
+    if (parentId != 0 && surfaces[parentId]) {
+	moveToHelper(surface, stackingOrder.indexOf(surfaces[parentId])+1);
+    }
+
+    if (surface.visible) {
+	restackWindows();
     }
 }
 
@@ -534,20 +538,23 @@ function restackWindows() {
     }
 }
 
-function moveToTopHelper(surface) {
+function moveToHelper(surface, position) {
     var i = stackingOrder.indexOf(surface);
     stackingOrder.splice(i, 1);
-    stackingOrder.push(surface);
+    if (position != undefined)
+	stackingOrder.splice(position, 0, surface);
+    else
+	stackingOrder.push(surface);
 
     for (var cid in surfaces) {
 	var child = surfaces[cid];
 	if (child.transientParent == surface.id)
-	    moveToTopHelper(child);
+	    moveToHelper(child, stackingOrder.indexOf(surface) + 1);
     }
 }
 
 function moveToTop(surface) {
-    moveToTopHelper(surface);
+    moveToHelper(surface);
     restackWindows();
 }
 



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