[gnome-shell/wip/jimmac/dash-icon-spacing: 46/72] workspacesView/workspacesDisplay: Handle smooth events
- From: Jakub Steiner <jimmac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/jimmac/dash-icon-spacing: 46/72] workspacesView/workspacesDisplay: Handle smooth events
- Date: Tue, 2 Feb 2021 11:58:18 +0000 (UTC)
commit e67ff43356404b3a8aef878133b8ba1cd16119ee
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Jan 8 18:12:52 2021 -0300
workspacesView/workspacesDisplay: Handle smooth events
On X11, the scroll handler can receive smooth events, which should
trigger a workspace switch. Handle smooth events by checking their
scroll delta, and adjusting the direction depending on these deltas.
js/ui/workspacesView.js | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index fa2d31d828..fbb5b56205 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -879,11 +879,27 @@ class WorkspacesDisplay extends St.Widget {
if (event.is_pointer_emulated())
return Clutter.EVENT_PROPAGATE;
+ let direction = event.get_scroll_direction();
+ if (direction === Clutter.ScrollDirection.SMOOTH) {
+ const [dx, dy] = event.get_scroll_delta();
+ if (dx > dy) {
+ direction = dx < 0
+ ? Clutter.ScrollDirection.RIGHT
+ : Clutter.ScrollDirection.LEFT;
+ } else if (dy > dx) {
+ direction = dy < 0
+ ? Clutter.ScrollDirection.UP
+ : Clutter.ScrollDirection.DOWN;
+ } else {
+ return Clutter.EVENT_PROPAGATE;
+ }
+ }
+
let workspaceManager = global.workspace_manager;
const vertical = workspaceManager.layout_rows === -1;
let activeWs = workspaceManager.get_active_workspace();
let ws;
- switch (event.get_scroll_direction()) {
+ switch (direction) {
case Clutter.ScrollDirection.UP:
if (vertical)
ws = activeWs.get_neighbor(Meta.MotionDirection.UP);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]