workspacesView: Add timeout for mouse scrolling
Prevent uncontrollably fast scrolling. Use the same duration as switching animation, but add a separate timeout to account for disabled animations. https://gitlab.gnome.org/GNOME/gnome-shell/issues/1338 https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/825
This commit is contained in:
parent
08ebfa1acf
commit
fc7bcf4761
@ -1,7 +1,7 @@
|
|||||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||||
/* exported WorkspacesView, WorkspacesDisplay */
|
/* exported WorkspacesView, WorkspacesDisplay */
|
||||||
|
|
||||||
const { Clutter, Gio, GObject, Meta, Shell, St } = imports.gi;
|
const { Clutter, Gio, GLib, GObject, Meta, Shell, St } = imports.gi;
|
||||||
|
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const WindowManager = imports.ui.windowManager;
|
const WindowManager = imports.ui.windowManager;
|
||||||
@ -487,11 +487,13 @@ class WorkspacesDisplay extends St.Widget {
|
|||||||
this._restackedNotifyId = 0;
|
this._restackedNotifyId = 0;
|
||||||
this._scrollEventId = 0;
|
this._scrollEventId = 0;
|
||||||
this._keyPressEventId = 0;
|
this._keyPressEventId = 0;
|
||||||
|
this._scrollTimeoutId = 0;
|
||||||
|
|
||||||
this._fullGeometry = null;
|
this._fullGeometry = null;
|
||||||
|
|
||||||
this._scrolling = false; // swipe-scrolling
|
this._scrolling = false; // swipe-scrolling
|
||||||
this._gestureActive = false; // touch(pad) gestures
|
this._gestureActive = false; // touch(pad) gestures
|
||||||
|
this._canScroll = true; // limiting scrolling speed
|
||||||
|
|
||||||
this.connect('destroy', this._onDestroy.bind(this));
|
this.connect('destroy', this._onDestroy.bind(this));
|
||||||
}
|
}
|
||||||
@ -509,6 +511,11 @@ class WorkspacesDisplay extends St.Widget {
|
|||||||
this._parentSetLater = 0;
|
this._parentSetLater = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._scrollTimeoutId !== 0) {
|
||||||
|
GLib.source_remove(this._scrollTimeoutId);
|
||||||
|
this._scrollTimeoutId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
global.window_manager.disconnect(this._switchWorkspaceId);
|
global.window_manager.disconnect(this._switchWorkspaceId);
|
||||||
global.workspace_manager.disconnect(this._reorderWorkspacesdId);
|
global.workspace_manager.disconnect(this._reorderWorkspacesdId);
|
||||||
}
|
}
|
||||||
@ -793,6 +800,9 @@ class WorkspacesDisplay extends St.Widget {
|
|||||||
this._getMonitorIndexForEvent(event) != this._primaryIndex)
|
this._getMonitorIndexForEvent(event) != this._primaryIndex)
|
||||||
return Clutter.EVENT_PROPAGATE;
|
return Clutter.EVENT_PROPAGATE;
|
||||||
|
|
||||||
|
if (!this._canScroll)
|
||||||
|
return Clutter.EVENT_PROPAGATE;
|
||||||
|
|
||||||
let workspaceManager = global.workspace_manager;
|
let workspaceManager = global.workspace_manager;
|
||||||
let activeWs = workspaceManager.get_active_workspace();
|
let activeWs = workspaceManager.get_active_workspace();
|
||||||
let ws;
|
let ws;
|
||||||
@ -813,6 +823,16 @@ class WorkspacesDisplay extends St.Widget {
|
|||||||
return Clutter.EVENT_PROPAGATE;
|
return Clutter.EVENT_PROPAGATE;
|
||||||
}
|
}
|
||||||
Main.wm.actionMoveWorkspace(ws);
|
Main.wm.actionMoveWorkspace(ws);
|
||||||
|
|
||||||
|
this._canScroll = false;
|
||||||
|
this._scrollTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
|
||||||
|
WORKSPACE_SWITCH_TIME, () => {
|
||||||
|
this._canScroll = true;
|
||||||
|
this._scrollTimeoutId = 0;
|
||||||
|
return GLib.SOURCE_REMOVE;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return Clutter.EVENT_STOP;
|
return Clutter.EVENT_STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user