workspacesView: Don't invalidate allocation before using it for gesture

Calling startTouchGesture() on the workspacesViews can change the
visibility of the workspaces if not all of them are already shown, such
as when there are more than 3 workspaces or for 3 workspaces if we are
not on the central one. This invalidates the allocation and the width
used as distance for the gesture would become 0, resulting in drag
gestures immediately jumping to the first or last workspace due to a
division by 0.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3721

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1682>
This commit is contained in:
Sebastian Keller 2021-02-16 03:50:52 +01:00
parent 629b7394f7
commit 8d5fb73695

View File

@ -716,12 +716,12 @@ class WorkspacesDisplay extends St.Widget {
? Clutter.Orientation.HORIZONTAL ? Clutter.Orientation.HORIZONTAL
: Clutter.Orientation.VERTICAL; : Clutter.Orientation.VERTICAL;
const distance = global.workspace_manager.layout_rows === -1
? this.height : this.width;
for (let i = 0; i < this._workspacesViews.length; i++) for (let i = 0; i < this._workspacesViews.length; i++)
this._workspacesViews[i].startTouchGesture(); this._workspacesViews[i].startTouchGesture();
let distance = global.workspace_manager.layout_rows === -1
? this.height : this.width;
let progress = adjustment.value / adjustment.page_size; let progress = adjustment.value / adjustment.page_size;
let points = Array.from( let points = Array.from(
{ length: workspaceManager.n_workspaces }, (v, i) => i); { length: workspaceManager.n_workspaces }, (v, i) => i);