mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-30 00:12:50 -05:00
workspaces: add scroll handler to widget itself
This commit is contained in:
@@ -649,6 +649,16 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.RightButton
|
acceptedButtons: Qt.RightButton
|
||||||
|
|
||||||
|
property real scrollAccumulator: 0
|
||||||
|
property real touchpadThreshold: 500
|
||||||
|
property bool scrollInProgress: false
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: scrollCooldown
|
||||||
|
interval: 100
|
||||||
|
onTriggered: parent.scrollInProgress = false
|
||||||
|
}
|
||||||
|
|
||||||
onClicked: mouse => {
|
onClicked: mouse => {
|
||||||
if (mouse.button === Qt.RightButton) {
|
if (mouse.button === Qt.RightButton) {
|
||||||
if (CompositorService.isNiri) {
|
if (CompositorService.isNiri) {
|
||||||
@@ -658,6 +668,30 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onWheel: wheel => {
|
||||||
|
if (scrollInProgress)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const delta = wheel.angleDelta.y;
|
||||||
|
const isMouseWheel = Math.abs(delta) >= 120 && (Math.abs(delta) % 120) === 0;
|
||||||
|
const direction = delta < 0 ? 1 : -1;
|
||||||
|
|
||||||
|
if (isMouseWheel) {
|
||||||
|
root.switchWorkspace(direction);
|
||||||
|
scrollInProgress = true;
|
||||||
|
scrollCooldown.restart();
|
||||||
|
} else {
|
||||||
|
scrollAccumulator += delta;
|
||||||
|
if (Math.abs(scrollAccumulator) >= touchpadThreshold) {
|
||||||
|
const touchDirection = scrollAccumulator < 0 ? 1 : -1;
|
||||||
|
root.switchWorkspace(touchDirection);
|
||||||
|
scrollInProgress = true;
|
||||||
|
scrollCooldown.restart();
|
||||||
|
scrollAccumulator = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Flow {
|
Flow {
|
||||||
|
|||||||
Reference in New Issue
Block a user