From 60034be06aa30ebf630150f86aa28805fa4fed18 Mon Sep 17 00:00:00 2001 From: bbedward Date: Mon, 29 Dec 2025 10:52:33 -0500 Subject: [PATCH] dankbar: copy high-dpi scrolling logic from DankListView --- quickshell/Modules/DankBar/DankBarWindow.qml | 14 +++++++--- .../DankBar/Widgets/WorkspaceSwitcher.qml | 26 +++++++++++-------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/quickshell/Modules/DankBar/DankBarWindow.qml b/quickshell/Modules/DankBar/DankBarWindow.qml index abba2fe5..08e4201e 100644 --- a/quickshell/Modules/DankBar/DankBarWindow.qml +++ b/quickshell/Modules/DankBar/DankBarWindow.qml @@ -708,18 +708,22 @@ PanelWindow { const deltaY = wheel.angleDelta.y; const deltaX = wheel.angleDelta.x; + const hasPixelY = wheel.pixelDelta && wheel.pixelDelta.y !== 0; + const hasPixelX = wheel.pixelDelta && wheel.pixelDelta.x !== 0; const xBehavior = barConfig?.scrollXBehavior ?? "column"; const yBehavior = barConfig?.scrollYBehavior ?? "workspace"; if (CompositorService.isNiri && xBehavior !== "none" && Math.abs(deltaX) > Math.abs(deltaY)) { - const isMouseWheel = Math.abs(deltaX) >= 120 && (Math.abs(deltaX) % 120) === 0; + const isTraditionalMouse = !hasPixelX && Math.abs(deltaX) >= 120 && (Math.abs(deltaX) % 120) === 0; + const isHighDpiMouse = !hasPixelX && !isTraditionalMouse && deltaX !== 0; const reverse = SettingsData.reverseScrolling ? -1 : 1; const direction = deltaX * reverse < 0 ? 1 : -1; - if (isMouseWheel) { + if (isTraditionalMouse || isHighDpiMouse) { if (handleScrollAction(xBehavior, direction)) { actionInProgress = true; cooldownTimer.restart(); + scrollAccumulatorX = 0; } } else { scrollAccumulatorX += deltaX; @@ -741,14 +745,16 @@ PanelWindow { return; } - const isMouseWheel = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0; + const isTraditionalMouse = !hasPixelY && Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0; + const isHighDpiMouse = !hasPixelY && !isTraditionalMouse && deltaY !== 0; const reverse = SettingsData.reverseScrolling ? -1 : 1; const direction = deltaY * reverse < 0 ? 1 : -1; - if (isMouseWheel) { + if (isTraditionalMouse || isHighDpiMouse) { if (handleScrollAction(yBehavior, direction)) { actionInProgress = true; cooldownTimer.restart(); + scrollAccumulatorY = 0; } } else { scrollAccumulatorY += deltaY; diff --git a/quickshell/Modules/DankBar/Widgets/WorkspaceSwitcher.qml b/quickshell/Modules/DankBar/Widgets/WorkspaceSwitcher.qml index eeed04dd..a2b2643d 100644 --- a/quickshell/Modules/DankBar/Widgets/WorkspaceSwitcher.qml +++ b/quickshell/Modules/DankBar/Widgets/WorkspaceSwitcher.qml @@ -674,23 +674,27 @@ Item { return; const delta = wheel.angleDelta.y; - const isMouseWheel = Math.abs(delta) >= 120 && (Math.abs(delta) % 120) === 0; + 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 reverse = SettingsData.reverseScrolling ? -1 : 1; const direction = delta * reverse < 0 ? 1 : -1; - if (isMouseWheel) { + if (isTraditionalMouse || isHighDpiMouse) { 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; - } + scrollAccumulator = 0; + return; + } + + scrollAccumulator += delta; + if (Math.abs(scrollAccumulator) >= touchpadThreshold) { + const touchDirection = scrollAccumulator < 0 ? 1 : -1; + root.switchWorkspace(touchDirection); + scrollInProgress = true; + scrollCooldown.restart(); + scrollAccumulator = 0; } } }