From 2c9feb7544a3c3e226f5db4ef8cfd68642c5d781 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 9 Jul 2025 23:53:01 +1000 Subject: internal: fix scrolling for high res devices Implements first part of #202 --- modules/bar/Bar.qml | 4 ++-- modules/bar/components/ActiveWindow.qml | 8 ++++---- modules/dashboard/Tabs.qml | 5 +++-- widgets/CustomMouseArea.qml | 21 +++++++++++++++++++++ widgets/StyledScrollBar.qml | 5 +++-- 5 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 widgets/CustomMouseArea.qml diff --git a/modules/bar/Bar.qml b/modules/bar/Bar.qml index 5a8f598..13eb7ba 100644 --- a/modules/bar/Bar.qml +++ b/modules/bar/Bar.qml @@ -96,12 +96,12 @@ Item { implicitWidth: workspacesInner.implicitWidth + Appearance.padding.small * 2 implicitHeight: workspacesInner.implicitHeight + Appearance.padding.small * 2 - MouseArea { + CustomMouseArea { anchors.fill: parent anchors.leftMargin: -Config.border.thickness anchors.rightMargin: -Config.border.thickness - onWheel: event => { + function onWheel(event: WheelEvent): void { const activeWs = Hyprland.activeToplevel?.workspace?.name; if (activeWs?.startsWith("special:")) Hyprland.dispatch(`togglespecialworkspace ${activeWs.slice(8)}`); diff --git a/modules/bar/components/ActiveWindow.qml b/modules/bar/components/ActiveWindow.qml index fc0c303..632148e 100644 --- a/modules/bar/components/ActiveWindow.qml +++ b/modules/bar/components/ActiveWindow.qml @@ -16,13 +16,13 @@ Item { implicitWidth: child.implicitWidth implicitHeight: child.implicitHeight - MouseArea { + CustomMouseArea { anchors.top: parent.top anchors.bottom: child.top anchors.left: parent.left anchors.right: parent.right - onWheel: event => { + function onWheel(event: WheelEvent): void { if (event.angleDelta.y > 0) Audio.setVolume(Audio.volume + 0.1); else if (event.angleDelta.y < 0) @@ -30,13 +30,13 @@ Item { } } - MouseArea { + CustomMouseArea { anchors.top: child.bottom anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right - onWheel: event => { + function onWheel(event: WheelEvent): void { const monitor = root.monitor; if (event.angleDelta.y > 0) monitor.setBrightness(monitor.brightness + 0.1); diff --git a/modules/dashboard/Tabs.qml b/modules/dashboard/Tabs.qml index 05f574a..b17dc71 100644 --- a/modules/dashboard/Tabs.qml +++ b/modules/dashboard/Tabs.qml @@ -103,7 +103,7 @@ Item { background: null - contentItem: MouseArea { + contentItem: CustomMouseArea { id: mouse implicitWidth: Math.max(icon.width, label.width) @@ -123,7 +123,8 @@ Item { rippleAnim.restart(); } - onWheel: event => { + + function onWheel(event: WheelEvent): void { if (event.angleDelta.y < 0) root.state.currentTab = Math.min(root.state.currentTab + 1, bar.count - 1); else if (event.angleDelta.y > 0) diff --git a/widgets/CustomMouseArea.qml b/widgets/CustomMouseArea.qml new file mode 100644 index 0000000..7c973c2 --- /dev/null +++ b/widgets/CustomMouseArea.qml @@ -0,0 +1,21 @@ +import QtQuick + +MouseArea { + property int scrollAccumulatedY: 0 + + function onWheel(event: WheelEvent): void { + } + + onWheel: event => { + // Update accumulated scroll + if (Math.sign(event.angleDelta.y) !== Math.sign(scrollAccumulatedY)) + scrollAccumulatedY = 0; + scrollAccumulatedY += event.angleDelta.y; + + // Trigger handler and reset if above threshold + if (Math.abs(scrollAccumulatedY) >= 120) { + onWheel(event); + scrollAccumulatedY = 0; + } + } +} diff --git a/widgets/StyledScrollBar.qml b/widgets/StyledScrollBar.qml index c655536..6fc80a9 100644 --- a/widgets/StyledScrollBar.qml +++ b/widgets/StyledScrollBar.qml @@ -21,10 +21,11 @@ ScrollBar { } } - MouseArea { + CustomMouseArea { z: -1 anchors.fill: parent - onWheel: event => { + + function onWheel(event: WheelEvent): void { if (event.angleDelta.y > 0) root.decrease(); else if (event.angleDelta.y < 0) -- cgit v1.2.3-freya