workspacesView: Don't update scroll position when allocating
Updating scroll position may have significant side effects, e.g. switching workspace; this should never happen during allocation, as we're in the middle of painting a frame. So, put it in an idle callback if we're doing it from an allocation to have the side effects happen the right time. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1527>
This commit is contained in:
parent
4e57119f40
commit
78d6b13c29
@ -78,6 +78,7 @@ class WorkspacesView extends WorkspacesViewBase {
|
|||||||
|
|
||||||
this._animating = false; // tweening
|
this._animating = false; // tweening
|
||||||
this._gestureActive = false; // touch(pad) gestures
|
this._gestureActive = false; // touch(pad) gestures
|
||||||
|
this._updateScrollPositionId = 0;
|
||||||
|
|
||||||
this._scrollAdjustment = scrollAdjustment;
|
this._scrollAdjustment = scrollAdjustment;
|
||||||
this._onScrollId = this._scrollAdjustment.connect('notify::value',
|
this._onScrollId = this._scrollAdjustment.connect('notify::value',
|
||||||
@ -124,7 +125,14 @@ class WorkspacesView extends WorkspacesViewBase {
|
|||||||
child.allocate_available_size(x, y, box.get_width(), box.get_height());
|
child.allocate_available_size(x, y, box.get_width(), box.get_height());
|
||||||
});
|
});
|
||||||
|
|
||||||
this._updateScrollPosition();
|
// Update scroll position in an idle callback to avoid unintended
|
||||||
|
// side effects (e.g. workspace switch) during layout.
|
||||||
|
this._updateScrollPositionId =
|
||||||
|
GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
|
||||||
|
this._updateScrollPositionId = 0;
|
||||||
|
this._updateScrollPosition();
|
||||||
|
return GLib.SOURCE_REMOVE;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getActiveWorkspace() {
|
getActiveWorkspace() {
|
||||||
@ -227,6 +235,8 @@ class WorkspacesView extends WorkspacesViewBase {
|
|||||||
_onDestroy() {
|
_onDestroy() {
|
||||||
super._onDestroy();
|
super._onDestroy();
|
||||||
|
|
||||||
|
if (this._updateScrollPositionId)
|
||||||
|
GLib.source_remove(this._updateScrollPositionId);
|
||||||
this._scrollAdjustment.disconnect(this._onScrollId);
|
this._scrollAdjustment.disconnect(this._onScrollId);
|
||||||
global.window_manager.disconnect(this._switchWorkspaceNotifyId);
|
global.window_manager.disconnect(this._switchWorkspaceNotifyId);
|
||||||
let workspaceManager = global.workspace_manager;
|
let workspaceManager = global.workspace_manager;
|
||||||
@ -254,6 +264,11 @@ class WorkspacesView extends WorkspacesViewBase {
|
|||||||
if (!this.has_allocation())
|
if (!this.has_allocation())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (this._updateScrollPositionId) {
|
||||||
|
GLib.source_remove(this._updateScrollPositionId);
|
||||||
|
this._updateScrollPositionId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
const adj = this._scrollAdjustment;
|
const adj = this._scrollAdjustment;
|
||||||
const allowSwitch =
|
const allowSwitch =
|
||||||
adj.get_transition('value') === null && !this._gestureActive;
|
adj.get_transition('value') === null && !this._gestureActive;
|
||||||
|
Loading…
Reference in New Issue
Block a user