[gnome-shell/gnome-42] ControlsManagerLayout: Cache workAreaBox
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-42] ControlsManagerLayout: Cache workAreaBox
- Date: Thu, 11 Aug 2022 12:43:05 +0000 (UTC)
commit dc933779681fc630ee2baf87fbbc72d162d68ec6
Author: Ivan Molodetskikh <yalterz gmail com>
Date: Sat Jul 30 21:59:33 2022 -0700
ControlsManagerLayout: Cache workAreaBox
Allocation runs every frame during the overview animations, so we want
to do as little work there as possible. Cache the work area box
computation.
Part-of:
<https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2395>
(cherry picked from commit 8562606ad11b05435df78015ee4e8f6c4caff53a)
js/ui/overviewControls.js | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
---
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index 2d58be7bb0..828463ef99 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -45,19 +45,34 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
this._postAllocationCallbacks = [];
stateAdjustment.connect('notify::value', () => this.layout_changed());
+
+ this._workAreaBox = new Clutter.ActorBox();
+ global.display.connectObject(
+ 'workareas-changed', () => this._updateWorkAreaBox(),
+ this);
+ this._updateWorkAreaBox();
}
- _computeWorkspacesBoxForState(state, box, workAreaBox, searchHeight, dashHeight, thumbnailsHeight) {
+ _updateWorkAreaBox() {
+ const monitor = Main.layoutManager.primaryMonitor;
+ const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor.index);
+ const startX = workArea.x - monitor.x;
+ const startY = workArea.y - monitor.y;
+ this._workAreaBox.set_origin(startX, startY);
+ this._workAreaBox.set_size(workArea.width, workArea.height);
+ }
+
+ _computeWorkspacesBoxForState(state, box, searchHeight, dashHeight, thumbnailsHeight) {
const workspaceBox = box.copy();
const [width, height] = workspaceBox.get_size();
- const { y1: startY } = workAreaBox;
+ const { y1: startY } = this._workAreaBox;
const { spacing } = this;
const { expandFraction } = this._workspacesThumbnails;
switch (state) {
case ControlsState.HIDDEN:
- workspaceBox.set_origin(...workAreaBox.get_origin());
- workspaceBox.set_size(...workAreaBox.get_size());
+ workspaceBox.set_origin(...this._workAreaBox.get_origin());
+ workspaceBox.set_size(...this._workAreaBox.get_size());
break;
case ControlsState.WINDOW_PICKER:
workspaceBox.set_origin(0,
@@ -80,9 +95,9 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
return workspaceBox;
}
- _getAppDisplayBoxForState(state, box, workAreaBox, searchHeight, dashHeight, appGridBox) {
+ _getAppDisplayBoxForState(state, box, searchHeight, dashHeight, appGridBox) {
const [width, height] = box.get_size();
- const { y1: startY } = workAreaBox;
+ const { y1: startY } = this._workAreaBox;
const appDisplayBox = new Clutter.ActorBox();
const { spacing } = this;
@@ -135,13 +150,7 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
const { spacing } = this;
- const monitor = Main.layoutManager.primaryMonitor;
- const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor.index);
- const startX = workArea.x - monitor.x;
- const startY = workArea.y - monitor.y;
- const workAreaBox = new Clutter.ActorBox();
- workAreaBox.set_origin(startX, startY);
- workAreaBox.set_size(workArea.width, workArea.height);
+ const startY = this._workAreaBox.y1;
box.y1 += startY;
const [width, height] = box.get_size();
let availableHeight = height;
@@ -181,7 +190,7 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
}
// Workspaces
- let params = [box, workAreaBox, searchHeight, dashHeight, thumbnailsHeight];
+ let params = [box, searchHeight, dashHeight, thumbnailsHeight];
const transitionParams = this._stateAdjustment.getStateTransitionParams();
// Update cached boxes
@@ -206,7 +215,7 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
const workspaceAppGridBox =
this._cachedWorkspaceBoxes.get(ControlsState.APP_GRID);
- params = [box, workAreaBox, searchHeight, dashHeight, workspaceAppGridBox];
+ params = [box, searchHeight, dashHeight, workspaceAppGridBox];
let appDisplayBox;
if (!transitionParams.transitioning) {
appDisplayBox =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]