qs: fix workspaces scroll with trackpad
This commit is contained in:
parent
406ffd6c15
commit
26b35a8e50
1 changed files with 16 additions and 8 deletions
|
@ -18,15 +18,23 @@ FullwidthMouseArea {
|
||||||
fillWindowWidth: true
|
fillWindowWidth: true
|
||||||
acceptedButtons: Qt.NoButton
|
acceptedButtons: Qt.NoButton
|
||||||
|
|
||||||
onWheel: event => {
|
property int scrollAccumulator: 0
|
||||||
event.accepted = true;
|
|
||||||
const step = -Math.sign(event.angleDelta.y);
|
|
||||||
const targetWs = currentIndex + step;
|
|
||||||
|
|
||||||
if (targetWs >= wsBaseIndex && targetWs < wsBaseIndex + wsCount) {
|
onWheel: event => {
|
||||||
Hyprland.dispatch(`workspace ${targetWs}`)
|
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);
|
readonly property HyprlandMonitor monitor: Hyprland.monitorFor(bar.screen);
|
||||||
property int currentIndex: 0;
|
property int currentIndex: 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue