[gnome-shell] overviewControls: Cache workspaces boxes



commit 9c6d8e2aad6b66aec4f9159235d4dd7f6ca56c86
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Feb 10 18:09:04 2021 -0300

    overviewControls: Cache workspaces boxes
    
    Next commit will need to access the allocated workspaces boxes, so
    cache them at allocation time.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>

 js/ui/overviewControls.js | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index efb3fd9fbf..94cf2336ef 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -37,6 +37,8 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
         this._viewSelector = viewSelector;
         this._dash = dash;
 
+        this._cachedWorkspaceBoxes = new Map();
+
         stateAdjustment.connect('notify::value', () => this.layout_changed());
     }
 
@@ -140,15 +142,18 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
         let params = [box, searchHeight, dashHeight, thumbnailsHeight];
         const transitionParams = this._stateAdjustment.getStateTransitionParams();
 
+        // Update cached boxes
+        for (const state of Object.values(ControlsState)) {
+            this._cachedWorkspaceBoxes.set(
+                state, this._getWorkspacesBoxForState(state, ...params));
+        }
+
         let workspacesBox;
         if (!transitionParams.transitioning) {
-            workspacesBox =
-                this._getWorkspacesBoxForState(transitionParams.currentState, ...params);
+            workspacesBox = this._cachedWorkspaceBoxes.get(transitionParams.currentState);
         } else {
-            const initialBox =
-                this._getWorkspacesBoxForState(transitionParams.initialState, ...params);
-            const finalBox =
-                this._getWorkspacesBoxForState(transitionParams.finalState, ...params);
+            const initialBox = this._cachedWorkspaceBoxes.get(transitionParams.initialState);
+            const finalBox = this._cachedWorkspaceBoxes.get(transitionParams.finalState);
             workspacesBox = initialBox.interpolate(finalBox, transitionParams.progress);
         }
 
@@ -156,7 +161,7 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
 
         // AppDisplay
         const workspaceAppGridBox =
-            this._getWorkspacesBoxForState(ControlsState.APP_GRID, ...params);
+            this._cachedWorkspaceBoxes.get(ControlsState.APP_GRID);
 
         params = [box, searchHeight, dashHeight, workspaceAppGridBox];
         let appDisplayBox;


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