[gnome-shell] workspaceThumbnail: Do not update scale while collapsing



commit d3a15578642a0754dd7af0ad9c4ce11580ffd114
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Feb 17 20:13:22 2021 +0100

    workspaceThumbnail: Do not update scale while collapsing
    
    The scale property tracks the relative size at which we display thumbnails
    given the space we have available.
    
    That assumes that the allocation represents that available space, but it will
    actually be smaller while the minimap itself is collapsing.
    
    Luckily we have an easy option to avoid a distorted scale: Just don't update
    it while collapsing. We expect scale changes when adding or removing thumbnails,
    but as we freeze those during transitions, we can do the same with the scale.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3739
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1696>

 js/ui/workspaceThumbnail.js | 42 +++++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 19 deletions(-)
---
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js
index 03e97f1752..6f009b8a08 100644
--- a/js/ui/workspaceThumbnail.js
+++ b/js/ui/workspaceThumbnail.js
@@ -1288,27 +1288,31 @@ var ThumbnailsBox = GObject.registerClass({
         const portholeHeight = this._porthole.height;
         const spacing = themeNode.get_length('spacing');
 
-        // Compute the scale we'll need once everything is updated
         const nWorkspaces = this._thumbnails.length;
-        let totalSpacing = (nWorkspaces - 1) * spacing;
-        const availableWidth = (box.get_width() - totalSpacing) / nWorkspaces;
-
-        const hScale = availableWidth / portholeWidth;
-        const vScale = box.get_height() / portholeHeight;
-        const newScale = Math.min(hScale, vScale);
-
-        if (newScale != this._targetScale) {
-            if (this._targetScale > 0) {
-                // We don't do the tween immediately because we need to observe the ordering
-                // in queueUpdateStates - if workspaces have been removed we need to slide them
-                // out as the first thing.
-                this._targetScale = newScale;
-                this._pendingScaleUpdate = true;
-            } else {
-                this._targetScale = this._scale = newScale;
-            }
 
-            this._queueUpdateStates();
+        // Compute the scale we'll need once everything is updated,
+        // unless we are currently transitioning
+        if (this._expandFraction === 1) {
+            const totalSpacing = (nWorkspaces - 1) * spacing;
+            const availableWidth = (box.get_width() - totalSpacing) / nWorkspaces;
+
+            const hScale = availableWidth / portholeWidth;
+            const vScale = box.get_height() / portholeHeight;
+            const newScale = Math.min(hScale, vScale);
+
+            if (newScale !== this._targetScale) {
+                if (this._targetScale > 0) {
+                    // We don't ease immediately because we need to observe the
+                    // ordering in queueUpdateStates - if workspaces have been
+                    // removed we need to slide them out as the first thing.
+                    this._targetScale = newScale;
+                    this._pendingScaleUpdate = true;
+                } else {
+                    this._targetScale = this._scale = newScale;
+                }
+
+                this._queueUpdateStates();
+            }
         }
 
         const ratio = portholeWidth / portholeHeight;


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