From 234024c4f4490b1cd8a3a0d797cb58fd013abd9f Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Tue, 16 Mar 2021 21:26:33 +0100 Subject: [PATCH] workspace: Update WorkspaceLayout workarea on changes Previously the workarea was only set on construction and then never updated. As a result the preferred width and height as well as the allocation were based on an outdated workarea size when it changed after construction. This for example was happening during the startup animation, for which the WorkspaceLayout is constructed before the panel is shown. This caused the workspace in the overview to be slightly smaller when it is first shown and the overview closing animation to not expand the workspace to the correct size the first time it is closed. Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3945 Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3816 Part-of: --- js/ui/workspace.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/js/ui/workspace.js b/js/ui/workspace.js index f8b0d40ed..75efe4d99 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -413,9 +413,6 @@ var WorkspaceLayout = GObject.registerClass({ this._metaWorkspace = metaWorkspace; this._monitorIndex = monitorIndex; - this._workarea = metaWorkspace - ? metaWorkspace.get_work_area_for_monitor(this._monitorIndex) - : Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex); this._overviewAdjustment = overviewAdjustment; this._container = null; @@ -435,6 +432,9 @@ var WorkspaceLayout = GObject.registerClass({ this.syncOverlays(); this.layout_changed(); }); + + this._workarea = null; + this._workareasChangedId = 0; } _isBetterScaleAndSpace(oldScale, oldSpace, scale, space) { @@ -563,8 +563,25 @@ var WorkspaceLayout = GObject.registerClass({ return workarea; } + _syncWorkareaTracking() { + if (this._container) { + if (this._workAreaChangedId) + return; + this._workarea = Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex); + this._workareasChangedId = + global.display.connect('workareas-changed', () => { + this._workarea = Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex); + this.layout_changed(); + }); + } else if (this._workareasChangedId) { + global.display.disconnect(this._workareasChangedId); + this._workareasChangedId = 0; + } + } + vfunc_set_container(container) { this._container = container; + this._syncWorkareaTracking(); this._stateAdjustment.actor = container; }