[gnome-shell/wip/rewindow: 12/17] workspace: Don't relayout windows when zooming workspace thumbnails



commit 907f409f2e6bbccfff1b57a4aa61126a474572b6
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Aug 8 16:47:05 2012 -0300

    workspace: Don't relayout windows when zooming workspace thumbnails
    
    It looks ugly and busy to have windows shuffle around when I just wanted
    to look at my workspaces.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=582650

 js/ui/workspace.js |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index dd500b1..11258dd 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -947,6 +947,8 @@ const Workspace = new Lang.Class({
 
         this._positionWindowsFlags = 0;
         this._positionWindowsId = 0;
+
+        this._currentLayout = null;
     },
 
     setGeometry: function(x, y, width, height) {
@@ -994,6 +996,8 @@ const Workspace = new Lang.Class({
             this._reservedSlot = clone;
         else
             this._reservedSlot = null;
+
+        this._currentLayout = null;
         this.positionWindows(WindowPositionFlags.ANIMATE);
     },
 
@@ -1217,6 +1221,7 @@ const Workspace = new Lang.Class({
         this._cursorX = x;
         this._cursorY = y;
 
+        this._currentLayout = null;
         this._repositionWindowsId = Mainloop.timeout_add(750,
             Lang.bind(this, this._delayedWindowRepositioning));
     },
@@ -1269,6 +1274,7 @@ const Workspace = new Lang.Class({
             clone.actor.set_position (this._x, this._y);
         }
 
+        this._currentLayout = null;
         this.positionWindows(WindowPositionFlags.ANIMATE);
     },
 
@@ -1306,6 +1312,8 @@ const Workspace = new Lang.Class({
 
     // Animate the full-screen to Overview transition.
     zoomToOverview : function() {
+        this._currentLayout = null;
+
         // Position and scale the windows.
         if (Main.overview.animationInProgress)
             this.positionWindows(WindowPositionFlags.ANIMATE | WindowPositionFlags.INITIAL);
@@ -1513,7 +1521,7 @@ const Workspace = new Lang.Class({
             let strategyClass = numRows > 2 ? GridLayoutStrategy : UnalignedLayoutStrategy;
             let strategy = new strategyClass(this._monitor, rowSpacing, columnSpacing, bottomPadding);
 
-            let layout = { strategy: strategy, numRows: numRows, numColumns: numColumns };
+            let layout = { area: area, strategy: strategy, numRows: numRows, numColumns: numColumns };
             strategy.computeLayout(windows, layout);
             strategy.computeScaleAndRatio(layout, area);
 
@@ -1527,6 +1535,16 @@ const Workspace = new Lang.Class({
         return lastLayout;
     },
 
+    _rectEqual: function(one, two) {
+        if (one == two)
+            return false;
+
+        return (one.x == two.x &&
+                one.y == two.y &&
+                one.width == two.width &&
+                one.height == two.height);
+    },
+
     _computeAllWindowSlots: function(windows) {
         let totalWindows = windows.length;
         let node = this.actor.get_theme_node();
@@ -1554,9 +1572,18 @@ const Workspace = new Lang.Class({
         area.y += maxCloseButtonHeight;
         area.height -= maxCloseButtonHeight;
 
-        let layout = this._computeLayout(windows, area, rowSpacing, columnSpacing, maxCaptionHeight);
+        if (!this._currentLayout) {
+            this._currentLayout = this._computeLayout(windows, area, rowSpacing, columnSpacing, maxCaptionHeight);
+        }
+
+        let layout = this._currentLayout;
         let strategy = layout.strategy;
 
+        if (!this._rectEqual(area, layout.area)) {
+            strategy.computeScaleAndRatio(layout, area);
+            layout.area = area;
+        }
+
         return strategy.computeWindowSlots(layout, area);
     },
 



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