workspace: Don't freeze the layout when there's no layout yet

On some touchpads/laptops, the swipe gesture to open the overview can be
performed so fast, that it starts and ends in between two frames. Now
when this happens, and the gesture ended with too little movement to
confidently say the user intended to open the overview, we'll close the
overview again.

While closing the overview, we freeze the layout of the Workspace in
order to avoid changes to windows messing with the animation. This means
that in the case described above, we freeze the layout even before the
first frame of the opening animation happens. No frames being drawn also
means no allocations happening, and since we create this._layout in
vfunc_allocate(), this means that on the first allocation cycle of the
overview we'll see this._layoutFrozen = true, but will also not have
a this._layout nor this._windowSlots.

This creates an annoying visual glitch where for a split second all
the windows disappear (overview is visible but no WindowPreviews get
allocated).

To fix this, force creating a layout on the first allocation cycle, even
if the layout is currently frozen.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2203>
This commit is contained in:
Jonas Dreßler 2022-01-31 21:13:18 +01:00 committed by Marge Bot
parent c5cba77a5c
commit ba23279f1f

View File

@ -424,6 +424,8 @@ var WorkspaceLayout = GObject.registerClass({
this._windowSlots = [];
this._layout = null;
this._needsLayout = true;
this._stateAdjustment = new St.Adjustment({
value: 0,
lower: 0,
@ -663,9 +665,10 @@ var WorkspaceLayout = GObject.registerClass({
}
let layoutChanged = false;
if (!this._layoutFrozen) {
if (this._layout === null) {
if (!this._layoutFrozen || this._needsLayout) {
if (this._needsLayout) {
this._layout = this._createBestLayout(this._workarea);
this._needsLayout = false;
layoutChanged = true;
}
@ -787,7 +790,7 @@ var WorkspaceLayout = GObject.registerClass({
this._windows.set(window, {
metaWindow,
sizeChangedId: metaWindow.connect('size-changed', () => {
this._layout = null;
this._needsLayout = true;
this.layout_changed();
}),
destroyId: window.connect('destroy', () =>
@ -807,7 +810,7 @@ var WorkspaceLayout = GObject.registerClass({
this._syncOverlay(window);
this._container.add_child(window);
this._layout = null;
this._needsLayout = true;
this.layout_changed();
}
@ -842,7 +845,7 @@ var WorkspaceLayout = GObject.registerClass({
if (window.get_parent() === this._container)
this._container.remove_child(window);
this._layout = null;
this._needsLayout = true;
this.layout_changed();
}
@ -861,7 +864,7 @@ var WorkspaceLayout = GObject.registerClass({
lastWindow = window;
}
this._layout = null;
this._needsLayout = true;
this.layout_changed();
}
@ -906,7 +909,7 @@ var WorkspaceLayout = GObject.registerClass({
this._spacing = s;
this._layout = null;
this._needsLayout = true;
this.notify('spacing');
this.layout_changed();
}