From 26b35a8e504910f35d45e21a815f6a4fe0224d4e Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Thu, 24 Jul 2025 19:05:17 -0700 Subject: [PATCH] qs: fix workspaces scroll with trackpad --- .../quickshell/shell/bar/Workspaces.qml | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/user/modules/quickshell/shell/bar/Workspaces.qml b/modules/user/modules/quickshell/shell/bar/Workspaces.qml index a7456e9..14e2ab3 100644 --- a/modules/user/modules/quickshell/shell/bar/Workspaces.qml +++ b/modules/user/modules/quickshell/shell/bar/Workspaces.qml @@ -18,15 +18,23 @@ FullwidthMouseArea { fillWindowWidth: true acceptedButtons: Qt.NoButton - onWheel: event => { - event.accepted = true; - const step = -Math.sign(event.angleDelta.y); - const targetWs = currentIndex + step; + property int scrollAccumulator: 0 - if (targetWs >= wsBaseIndex && targetWs < wsBaseIndex + wsCount) { - Hyprland.dispatch(`workspace ${targetWs}`) - } - } + onWheel: event => { + event.accepted = true; + let acc = scrollAccumulator - event.angleDelta.y; + const sign = Math.sign(acc); + acc = Math.abs(acc); + + const offset = sign * Math.floor(acc / 120); + scrollAccumulator = sign * (acc % 120); + + if (offset != 0) { + const targetWorkspace = currentIndex + offset; + const id = Math.max(1, Math.min(10, targetWorkspace)); + if (id != currentIndex) Hyprland.dispatch(`workspace ${id}`); + } + } readonly property HyprlandMonitor monitor: Hyprland.monitorFor(bar.screen); property int currentIndex: 0;