[gnome-shell] workspaceThumbnails: allow requesting size at any time



commit 101daf6791d9900e2c15ca6ad3a9c2998613780e
Author: Carlos Soriano <carlos soriano89 gmail com>
Date:   Thu Jul 31 17:35:27 2014 +0200

    workspaceThumbnails: allow requesting size at any time
    
    The slide of thumbnailWorkspace is shown when entering overview,
    connecting to the same signal that creates the thumbnails, the showing
    signal of overview, but, to make the slide animation we need to know how
    much width the slider has.  To do that we ask the thumbnailsWorkspace
    about its width, but given that it connects to the same signal it could
    ask the width without having created the thumbnails yet, so reporting a
    width of 0 and confusing the slide animation.
    
    Currently it works because gjs calls the callbacks following the order
    of the clients connecting that signal, and the thumbnailsWorskpace is
    connected before the slide ones.
    
    To avoid that we allow to request the preferred size of the
    thumbnailsBox at any time with any number of thumbnails. The only thing
    required is to make sure the porthole is accessible when requesting the
    preferred size.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732901

 js/ui/workspaceThumbnail.js |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js
index 14091a5..c11d13b 100644
--- a/js/ui/workspaceThumbnail.js
+++ b/js/ui/workspaceThumbnail.js
@@ -878,9 +878,6 @@ const ThumbnailsBox = new Lang.Class({
         for (let key in ThumbnailState)
             this._stateCounts[ThumbnailState[key]] = 0;
 
-        // The "porthole" is the portion of the screen that we show in the workspaces
-        this._porthole = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex);
-
         this.addThumbnails(0, global.screen.n_workspaces);
 
         this._updateSwitcherVisibility();
@@ -904,6 +901,7 @@ const ThumbnailsBox = new Lang.Class({
         for (let w = 0; w < this._thumbnails.length; w++)
             this._thumbnails[w].destroy();
         this._thumbnails = [];
+        this._porthole = null;
     },
 
     _workspacesChanged: function() {
@@ -934,6 +932,7 @@ const ThumbnailsBox = new Lang.Class({
     },
 
     addThumbnails: function(start, count) {
+        this._ensurePorthole();
         for (let k = start; k < start + count; k++) {
             let metaWorkspace = global.screen.get_workspace_by_index(k);
             let thumbnail = new WorkspaceThumbnail(metaWorkspace);
@@ -1121,9 +1120,7 @@ const ThumbnailsBox = new Lang.Class({
         // the size request to our children because we know how big they are and know
         // that the actors aren't depending on the virtual functions being called.
 
-        if (this._thumbnails.length == 0)
-            return;
-
+        this._ensurePorthole();
         let themeNode = this.actor.get_theme_node();
 
         let spacing = themeNode.get_length('spacing');
@@ -1135,8 +1132,7 @@ const ThumbnailsBox = new Lang.Class({
     },
 
     _getPreferredWidth: function(actor, forHeight, alloc) {
-        if (this._thumbnails.length == 0)
-            return;
+        this._ensurePorthole();
 
         let themeNode = this.actor.get_theme_node();
 
@@ -1154,6 +1150,13 @@ const ThumbnailsBox = new Lang.Class({
         alloc.natural_size = width;
     },
 
+    // The "porthole" is the portion of the screen that we show in the
+    // workspaces
+    _ensurePorthole: function() {
+        if (!this._porthole)
+            this._porthole = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex);
+    },
+
     _allocate: function(actor, box, flags) {
         let rtl = (Clutter.get_default_text_direction () == Clutter.TextDirection.RTL);
 


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