1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-05 05:12:05 -04:00

workspace: update scroll accumulator logic

This commit is contained in:
bbedward
2025-12-29 12:11:21 -05:00
parent 5f77d69dd8
commit d5c7b5c0cc
2 changed files with 57 additions and 61 deletions

View File

@@ -649,8 +649,8 @@ Item {
anchors.fill: parent
acceptedButtons: Qt.RightButton
property real scrollAccumulator: 0
property real touchpadThreshold: 500
property real touchpadAccumulator: 0
property real mouseAccumulator: 0
property bool scrollInProgress: false
Timer {
@@ -674,28 +674,29 @@ Item {
return;
const delta = wheel.angleDelta.y;
const hasPixel = wheel.pixelDelta && wheel.pixelDelta.y !== 0;
const isTraditionalMouse = !hasPixel && Math.abs(delta) >= 120 && (Math.abs(delta) % 120) === 0;
const isHighDpiMouse = !hasPixel && !isTraditionalMouse && delta !== 0;
const isTouchpad = wheel.pixelDelta && wheel.pixelDelta.y !== 0;
const reverse = SettingsData.reverseScrolling ? -1 : 1;
const direction = delta * reverse < 0 ? 1 : -1;
if (isTraditionalMouse || isHighDpiMouse) {
if (isTouchpad) {
touchpadAccumulator += delta;
if (Math.abs(touchpadAccumulator) < 500)
return;
const direction = touchpadAccumulator * reverse < 0 ? 1 : -1;
root.switchWorkspace(direction);
scrollInProgress = true;
scrollCooldown.restart();
scrollAccumulator = 0;
touchpadAccumulator = 0;
return;
}
scrollAccumulator += delta;
if (Math.abs(scrollAccumulator) >= touchpadThreshold) {
const touchDirection = scrollAccumulator < 0 ? 1 : -1;
root.switchWorkspace(touchDirection);
scrollInProgress = true;
scrollCooldown.restart();
scrollAccumulator = 0;
}
mouseAccumulator += delta;
if (Math.abs(mouseAccumulator) < 120)
return;
const direction = mouseAccumulator * reverse < 0 ? 1 : -1;
root.switchWorkspace(direction);
scrollInProgress = true;
scrollCooldown.restart();
mouseAccumulator = 0;
}
}