[gnome-shell/workspace-thumbnails] Fix stacking of windows in workspace thumbnails



commit 3328b523b06797a8ea8851b8031951353e96a1da
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Tue Jan 25 13:31:22 2011 -0500

    Fix stacking of windows in workspace thumbnails
    
    Hook up syncStacking function for workspace thumbnails; this makes restacking
    after DND snapback work correctly.

 js/ui/workspaceThumbnail.js |   19 +++++++++++++------
 js/ui/workspacesView.js     |   39 ++++++++++++++++++++++++---------------
 2 files changed, 37 insertions(+), 21 deletions(-)
---
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js
index 3588627..83341a9 100644
--- a/js/ui/workspaceThumbnail.js
+++ b/js/ui/workspaceThumbnail.js
@@ -43,6 +43,14 @@ WindowClone.prototype = {
         this._selected = false;
     },
 
+    setStackAbove: function (actor) {
+        this._stackAbove = actor;
+        if (this._stackAbove == null)
+            this.actor.lower_bottom();
+        else
+            this.actor.raise(this._stackAbove);
+    },
+
     destroy: function () {
         this.actor.destroy();
     },
@@ -152,16 +160,15 @@ WorkspaceThumbnail.prototype = {
     },
 
     syncStacking: function(stackIndices) {
-        let visibleClones = this._getVisibleClones();
-        visibleClones.sort(function (a, b) { return stackIndices[a.metaWindow.get_stable_sequence()] - stackIndices[b.metaWindow.get_stable_sequence()]; });
+        this._windows.sort(function (a, b) { return stackIndices[a.metaWindow.get_stable_sequence()] - stackIndices[b.metaWindow.get_stable_sequence()]; });
 
-        for (let i = 0; i < visibleClones.length; i++) {
-            let clone = visibleClones[i];
+        for (let i = 0; i < this._windows.length; i++) {
+            let clone = this._windows[i];
             let metaWindow = clone.metaWindow;
             if (i == 0) {
-                clone.setStackAbove(null);
+                clone.setStackAbove(this._background);
             } else {
-                let previousClone = visibleClones[i - 1];
+                let previousClone = this._windows[i - 1];
                 clone.setStackAbove(previousClone.actor);
             }
         }
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 9323116..9a51139 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -78,7 +78,6 @@ WorkspacesView.prototype = {
         this._overviewShowingId =
             Main.overview.connect('showing',
                                  Lang.bind(this, function() {
-                this._onRestacked();
                 for (let w = 0; w < this._workspaces.length; w++)
                     this._workspaces[w].zoomToOverview();
         }));
@@ -100,9 +99,6 @@ WorkspacesView.prototype = {
         this._switchWorkspaceNotifyId =
             global.window_manager.connect('switch-workspace',
                                           Lang.bind(this, this._activeWorkspaceChanged));
-        this._restackedNotifyId =
-            global.screen.connect('restacked',
-                                  Lang.bind(this, this._onRestacked));
 
         this._itemDragBeginId = Main.overview.connect('item-drag-begin',
                                                       Lang.bind(this, this._dragBegin));
@@ -208,15 +204,7 @@ WorkspacesView.prototype = {
         return this._workspaces[0].scale;
     },
 
-    _onRestacked: function() {
-        let stack = global.get_window_actors();
-        let stackIndices = {};
-
-        for (let i = 0; i < stack.length; i++) {
-            // Use the stable sequence for an integer to use as a hash key
-            stackIndices[stack[i].get_meta_window().get_stable_sequence()] = i;
-        }
-
+    syncStacking: function(stackIndices) {
         for (let i = 0; i < this._workspaces.length; i++)
             this._workspaces[i].syncStacking(stackIndices);
     },
@@ -502,7 +490,6 @@ WorkspacesView.prototype = {
     _onDestroy: function() {
         Main.overview.disconnect(this._overviewShowingId);
         global.window_manager.disconnect(this._switchWorkspaceNotifyId);
-        global.screen.disconnect(this._restackedNotifyId);
 
         if (this._timeoutId) {
             Mainloop.source_remove(this._timeoutId);
@@ -928,6 +915,10 @@ WorkspacesDisplay.prototype = {
             global.window_manager.connect('switch-workspace',
                                           Lang.bind(this, this._activeWorkspaceChanged));
 
+        this._restackedNotifyId =
+            global.screen.connect('restacked',
+                                  Lang.bind(this, this._onRestacked));
+
         if (this._itemDragBeginId == 0)
             this._itemDragBeginId = Main.overview.connect('item-drag-begin',
                                                           Lang.bind(this, this._dragBegin));
@@ -941,6 +932,7 @@ WorkspacesDisplay.prototype = {
             this._windowDragEndId = Main.overview.connect('window-drag-end',
                                                           Lang.bind(this, this._dragEnd));
 
+        this._onRestacked();
         this._constrainThumbnailIndicator();
     },
 
@@ -955,7 +947,10 @@ WorkspacesDisplay.prototype = {
             global.window_manager.disconnect(this._switchWorkspaceNotifyId);
             this._switchWorkspaceNotifyId = 0;
         }
-
+        if (this._restackedNotifyId > 0){
+            global.screen.disconnect(this._restackedNotifyId);
+            this._restackedNotifyId = 0;
+        }
         if (this._itemDragBeginId > 0) {
             Main.overview.disconnect(this._itemDragBeginId);
             this._itemDragBeginId = 0;
@@ -1020,6 +1015,20 @@ WorkspacesDisplay.prototype = {
                          });
     },
 
+    _onRestacked: function() {
+        let stack = global.get_window_actors();
+        let stackIndices = {};
+
+        for (let i = 0; i < stack.length; i++) {
+            // Use the stable sequence for an integer to use as a hash key
+            stackIndices[stack[i].get_meta_window().get_stable_sequence()] = i;
+        }
+
+        this.workspacesView.syncStacking(stackIndices);
+        for (let i = 0; i < this._workspaceThumbnails.length; i++)
+            this._workspaceThumbnails[i].syncStacking(stackIndices);
+    },
+
     _workspacesChanged: function() {
         let oldNumWorkspaces = this._workspaces.length;
         let newNumWorkspaces = global.screen.n_workspaces;



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