[gnome-shell] workspacesView: Calculate the workspaces geometry ourselves



commit f0c2ad00f8674fa3d0a3e9097f07b4b1968e6ad1
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Feb 25 18:11:59 2013 -0500

    workspacesView: Calculate the workspaces geometry ourselves
    
    To ensure that we don't recalculate window layouts when zooming
    in or out, we need to always pass the full geometry. This will
    break window repositioning when we zoom back in; for the purposes
    of commit clarity, this breaks this feature for now. It will be
    added back soon.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=694469

 js/ui/overviewControls.js | 22 ++++++++++++++++++++++
 js/ui/viewSelector.js     |  4 ++++
 js/ui/workspacesView.js   | 16 +++++++++-------
 3 files changed, 35 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index ba1cf27..7563975 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -520,6 +520,8 @@ const ControlsManager = new Lang.Class({
                                                    expand: true });
         this._group.add_actor(this._thumbnailsSlider.actor);
 
+        this._group.connect('notify::allocation', Lang.bind(this, this._updateWorkspacesGeometry));
+
         Main.overview.connect('showing', Lang.bind(this, this._updateSpacerVisibility));
         Main.overview.connect('item-drag-begin', Lang.bind(this,
             function() {
@@ -537,6 +539,26 @@ const ControlsManager = new Lang.Class({
             }));
     },
 
+    _updateWorkspacesGeometry: function() {
+        let [x, y] = this.actor.get_transformed_position();
+        let [width, height] = this.actor.get_transformed_size();
+        let geometry = { x: x, y: y, width: width, height: height };
+
+        let spacing = this.actor.get_theme_node().get_length('spacing');
+        let dashWidth = this._dashSlider.getVisibleWidth() + spacing;
+        let thumbnailsWidth = this._thumbnailsSlider.getNonExpandedWidth() + spacing;
+
+        geometry.width -= dashWidth;
+        geometry.width -= thumbnailsWidth;
+
+        if (this.actor.get_text_direction() == Clutter.TextDirection.LTR)
+            geometry.x += dashWidth;
+        else
+            geometry.x += thumbnailsWidth;
+
+        this.viewSelector.setWorkspacesGeometry(geometry);
+    },
+
     _setVisibility: function() {
         // Ignore the case when we're leaving the overview, since
         // actors will be made visible again when entering the overview
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 639acf3..a7ad1b5 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -186,6 +186,10 @@ const ViewSelector = new Lang.Class({
             Main.overview.fadeInDesktop();
     },
 
+    setWorkspacesGeometry: function(geom) {
+        this._workspacesDisplay.setWorkspacesGeometry(geom);
+    },
+
     hide: function() {
         this._workspacesDisplay.hide();
     },
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 9400d24..7cb3b7e 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -429,7 +429,6 @@ const WorkspacesDisplay = new Lang.Class({
 
     _init: function() {
         this.actor = new St.Widget({ clip_to_allocation: true });
-        this.actor.connect('notify::allocation', Lang.bind(this, this._updateWorkspacesGeometry));
         this.actor.connect('parent-set', Lang.bind(this, this._parentSet));
 
         let clickAction = new Clutter.ClickAction()
@@ -631,20 +630,23 @@ const WorkspacesDisplay = new Lang.Class({
         }));
     },
 
+    // This geometry should always be the fullest geometry
+    // the workspaces switcher can ever be allocated, as if
+    // the sliding controls were never slid in at all.
+    setWorkspacesGeometry: function(geom) {
+        this._geometry = geom;
+        this._updateWorkspacesGeometry();
+    },
+
     _updateWorkspacesGeometry: function() {
         if (!this._workspacesViews.length)
             return;
 
-        let width = this.actor.allocation.x2 - this.actor.allocation.x1;
-        let height = this.actor.allocation.y2 - this.actor.allocation.y1;
-
-        let [x, y] = this.actor.get_transformed_position();
-
         let monitors = Main.layoutManager.monitors;
         let m = 0;
         for (let i = 0; i < monitors.length; i++) {
             if (i == this._primaryIndex) {
-                this._workspacesViews[m].setGeometry({ x: x, y: y, width: width, height: height });
+                this._workspacesViews[m].setGeometry(this._geometry);
                 m++;
             } else if (!this._workspacesOnlyOnPrimary) {
                 this._workspacesViews[m].setGeometry(monitors[i]);


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