From 3c1638195b33f9dfdd3df7847e88fab97188520a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 20 Feb 2024 17:39:49 +0100 Subject: [PATCH 20/28] workspace-indicator: Simplify scroll handling gnome-shell already includes a method for switching workspaces via scroll events. Use that instead of implementing our own. Part-of: --- .../workspace-indicator/workspaceIndicator.js | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js index 594a9e51..14dd81d0 100644 --- a/extensions/workspace-indicator/workspaceIndicator.js +++ b/extensions/workspace-indicator/workspaceIndicator.js @@ -300,8 +300,10 @@ export class WorkspaceIndicator extends PanelMenu.Button { 'notify::layout-rows', this._updateThumbnailVisibility.bind(this), this); - this.connect('scroll-event', this._onScrollEvent.bind(this)); - this._thumbnailsBox.connect('scroll-event', this._onScrollEvent.bind(this)); + this.connect('scroll-event', + (a, event) => Main.wm.handleWorkspaceScroll(event)); + this._thumbnailsBox.connect('scroll-event', + (a, event) => Main.wm.handleWorkspaceScroll(event)); this._inTopBar = false; this.connect('notify::realized', () => { @@ -445,19 +447,4 @@ export class WorkspaceIndicator extends PanelMenu.Button { metaWorkspace.activate(global.get_current_time()); } } - - _onScrollEvent(actor, event) { - let direction = event.get_scroll_direction(); - let diff = 0; - if (direction === Clutter.ScrollDirection.DOWN) - diff = 1; - else if (direction === Clutter.ScrollDirection.UP) - diff = -1; - else - return; - - - const newIndex = this._currentWorkspace + diff; - this._activate(newIndex); - } } -- 2.44.0