qs: fix workspaces scroll with trackpad

This commit is contained in:
outfoxxed 2025-07-24 19:05:17 -07:00
parent 406ffd6c15
commit 26b35a8e50
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E

View file

@ -18,13 +18,21 @@ FullwidthMouseArea {
fillWindowWidth: true fillWindowWidth: true
acceptedButtons: Qt.NoButton acceptedButtons: Qt.NoButton
property int scrollAccumulator: 0
onWheel: event => { onWheel: event => {
event.accepted = true; event.accepted = true;
const step = -Math.sign(event.angleDelta.y); let acc = scrollAccumulator - event.angleDelta.y;
const targetWs = currentIndex + step; const sign = Math.sign(acc);
acc = Math.abs(acc);
if (targetWs >= wsBaseIndex && targetWs < wsBaseIndex + wsCount) { const offset = sign * Math.floor(acc / 120);
Hyprland.dispatch(`workspace ${targetWs}`) 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}`);
} }
} }