[gnome-shell/gnome-41] workspace: Scale slots to current workspace size when layout is frozen



commit e028db0440de8bbc6caa0661e33bcbd0d4bc894d
Author: Sebastian Keller <skeller gnome org>
Date:   Sat Sep 18 17:01:21 2021 +0200

    workspace: Scale slots to current workspace size when layout is frozen
    
    The transition from the overview freezes the workspace layout at the
    start of the animation, which means that the calculated window slots
    remain the same while the workspace itslef grows. This causes the
    windows to appear slightly shrunk in comparison to the workspace and
    shifted to the top left. This is especially noticeable during the
    beginning of the animation when there is more weight on the slots than
    the original window position and if there are not that many open
    windows.
    
    Unfreezing the layout for this transition is not possible, because it
    would cause issues with newly opened windows abruptly changing the
    layout when the animation happens after starting a new app.
    
    This change instead tries to scale the frozen layout to the current
    workspace size. While this is not entirely correct, because this scales
    the spacing between the slots as well, it is still more accurate than
    the completely unscaled slots.
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4616
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1980>
    (cherry picked from commit 6d3df381b38a43efb4f0f0a7dc48dfaa9a286c36)

 js/ui/workspace.js | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index afe5a518b6..912753c13a 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -670,10 +670,13 @@ var WorkspaceLayout = GObject.registerClass({
                 layoutChanged = true;
             }
 
-            if (layoutChanged || containerAllocationChanged)
-                this._windowSlots = this._getWindowSlots(box.copy());
+            if (layoutChanged || containerAllocationChanged) {
+                this._windowSlotsBox = box.copy();
+                this._windowSlots = this._getWindowSlots(this._windowSlotsBox);
+            }
         }
 
+        const slotsScale = box.get_width() / this._windowSlotsBox.get_width();
         const workareaX = this._workarea.x;
         const workareaY = this._workarea.y;
         const workareaWidth = this._workarea.width;
@@ -689,6 +692,11 @@ var WorkspaceLayout = GObject.registerClass({
             if (!child.visible)
                 continue;
 
+            x *= slotsScale;
+            y *= slotsScale;
+            width *= slotsScale;
+            height *= slotsScale;
+
             const windowInfo = this._windows.get(child);
 
             let workspaceBoxX, workspaceBoxY;


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