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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1771>
This commit is contained in:
Sebastian Keller 2021-03-16 21:26:33 +01:00
parent a08355931f
commit 234024c4f4

View File

@ -413,9 +413,6 @@ var WorkspaceLayout = GObject.registerClass({
this._metaWorkspace = metaWorkspace; this._metaWorkspace = metaWorkspace;
this._monitorIndex = monitorIndex; this._monitorIndex = monitorIndex;
this._workarea = metaWorkspace
? metaWorkspace.get_work_area_for_monitor(this._monitorIndex)
: Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex);
this._overviewAdjustment = overviewAdjustment; this._overviewAdjustment = overviewAdjustment;
this._container = null; this._container = null;
@ -435,6 +432,9 @@ var WorkspaceLayout = GObject.registerClass({
this.syncOverlays(); this.syncOverlays();
this.layout_changed(); this.layout_changed();
}); });
this._workarea = null;
this._workareasChangedId = 0;
} }
_isBetterScaleAndSpace(oldScale, oldSpace, scale, space) { _isBetterScaleAndSpace(oldScale, oldSpace, scale, space) {
@ -563,8 +563,25 @@ var WorkspaceLayout = GObject.registerClass({
return workarea; 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) { vfunc_set_container(container) {
this._container = container; this._container = container;
this._syncWorkareaTracking();
this._stateAdjustment.actor = container; this._stateAdjustment.actor = container;
} }