mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-18 07:34:54 +00:00
workspaceAnimation: Compute the base distance only when needed
This value is used during animation to get the progress, but it can be easily cached since it does not depend on any variable value. So let's just compute when required and avoid further JS->C calls while animating.
This commit is contained in:
parent
41fd8ed688
commit
3293820d67
1 changed files with 14 additions and 6 deletions
|
|
@ -190,6 +190,12 @@ export const MonitorGroup = GObject.registerClass({
|
|||
const workspaceManager = global.workspace_manager;
|
||||
const activeWorkspace = workspaceManager.get_active_workspace();
|
||||
|
||||
this._updateBaseDistance();
|
||||
St.ThemeContext.get_for_stage(global.stage).connectObject(
|
||||
'notify::scale-factor', () => this._updateBaseDistance(), this);
|
||||
Main.layoutManager.connectObject('monitors-changed',
|
||||
() => this._updateBaseDistance(), this);
|
||||
|
||||
this.setWorkspaceIndices(workspaceIndices);
|
||||
|
||||
this.progress = this.getWorkspaceProgress(activeWorkspace);
|
||||
|
|
@ -214,6 +220,13 @@ export const MonitorGroup = GObject.registerClass({
|
|||
}
|
||||
}
|
||||
|
||||
_updateBaseDistance() {
|
||||
this._baseDistance = global.workspace_manager.layout_rows === -1
|
||||
? this._monitor.height : this._monitor.width;
|
||||
this._baseDistance += WORKSPACE_SPACING *
|
||||
St.ThemeContext.get_for_stage(global.stage).scaleFactor;
|
||||
}
|
||||
|
||||
setWorkspaceIndices(workspaceIndices) {
|
||||
const {workspaceManager} = global;
|
||||
const vertical = workspaceManager.layout_rows === -1;
|
||||
|
|
@ -297,12 +310,7 @@ export const MonitorGroup = GObject.registerClass({
|
|||
}
|
||||
|
||||
get baseDistance() {
|
||||
const spacing = WORKSPACE_SPACING * St.ThemeContext.get_for_stage(global.stage).scale_factor;
|
||||
|
||||
if (global.workspace_manager.layout_rows === -1)
|
||||
return this._monitor.height + spacing;
|
||||
else
|
||||
return this._monitor.width + spacing;
|
||||
return this._baseDistance;
|
||||
}
|
||||
|
||||
get progress() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue