[gnome-shell/wip/rewindow: 8/17] workspace: Position windows only when needed



commit 3776c50986e48888a5c8357f8bf9e09e82b486bc
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Aug 8 14:16:28 2012 -0300

    workspace: Position windows only when needed
    
    Right now, when entering the overview, we compute the window slots about
    four or five times, from scratch each time. Move to a queued system where
    extraneous calls to positionWindows don't matter.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=582650

 js/ui/workspace.js |   36 +++++++++++++++++++++++++++---------
 1 files changed, 27 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index 8e75cd8..cff9a42 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -726,6 +726,9 @@ const Workspace = new Lang.Class({
         this._repositionWindowsId = 0;
 
         this.leavingOverview = false;
+
+        this._positionWindowsFlags = 0;
+        this._positionWindowsId = 0;
     },
 
     setGeometry: function(x, y, width, height) {
@@ -734,15 +737,13 @@ const Workspace = new Lang.Class({
         this._width = width;
         this._height = height;
 
-        // This is sometimes called during allocation, so we do this later
-        Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this,
-            function () {
-                this._dropRect.set_position(x, y);
-                this._dropRect.set_size(width, height);
-                this.positionWindows(WindowPositionFlags.ANIMATE);
-                return false;
-            }));
+        Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
+            this._dropRect.set_position(x, y);
+            this._dropRect.set_size(width, height);
+            return false;
+        }));
 
+        this.positionWindows(WindowPositionFlags.ANIMATE);
     },
 
     _lookupIndex: function (metaWindow) {
@@ -1003,7 +1004,21 @@ const Workspace = new Lang.Class({
      *  INITIAL - this is the initial positioning of the windows.
      *  ANIMATE - Indicates that we need animate changing position.
      */
-    positionWindows : function(flags) {
+    positionWindows: function(flags) {
+        this._positionWindowsFlags |= flags;
+
+        if (this._positionWindowsId > 0)
+            return;
+
+        this._positionWindowsId = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
+            this._realPositionWindows(this._positionWindowsFlags);
+            this._positionWindowsFlags = 0;
+            this._positionWindowsId = 0;
+            return false;
+        }));
+    },
+
+    _realPositionWindows : function(flags) {
         if (this._repositionWindowsId > 0) {
             Mainloop.source_remove(this._repositionWindowsId);
             this._repositionWindowsId = 0;
@@ -1372,6 +1387,9 @@ const Workspace = new Lang.Class({
         if (this._repositionWindowsId > 0)
             Mainloop.source_remove(this._repositionWindowsId);
 
+        if (this._positionWindowsId > 0)
+            Meta.later_remove(this._positionWindowsId);
+
         // Usually, the windows will be destroyed automatically with
         // their parent (this.actor), but we might have a zoomed window
         // which has been reparented to the stage - _windows[0] holds



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