internal: fix scrolling for high res devices
Implements first part of #202
This commit is contained in:
parent
17812d0322
commit
2c9feb7544
5 changed files with 33 additions and 10 deletions
|
|
@ -96,12 +96,12 @@ Item {
|
||||||
implicitWidth: workspacesInner.implicitWidth + Appearance.padding.small * 2
|
implicitWidth: workspacesInner.implicitWidth + Appearance.padding.small * 2
|
||||||
implicitHeight: workspacesInner.implicitHeight + Appearance.padding.small * 2
|
implicitHeight: workspacesInner.implicitHeight + Appearance.padding.small * 2
|
||||||
|
|
||||||
MouseArea {
|
CustomMouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.leftMargin: -Config.border.thickness
|
anchors.leftMargin: -Config.border.thickness
|
||||||
anchors.rightMargin: -Config.border.thickness
|
anchors.rightMargin: -Config.border.thickness
|
||||||
|
|
||||||
onWheel: event => {
|
function onWheel(event: WheelEvent): void {
|
||||||
const activeWs = Hyprland.activeToplevel?.workspace?.name;
|
const activeWs = Hyprland.activeToplevel?.workspace?.name;
|
||||||
if (activeWs?.startsWith("special:"))
|
if (activeWs?.startsWith("special:"))
|
||||||
Hyprland.dispatch(`togglespecialworkspace ${activeWs.slice(8)}`);
|
Hyprland.dispatch(`togglespecialworkspace ${activeWs.slice(8)}`);
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@ Item {
|
||||||
implicitWidth: child.implicitWidth
|
implicitWidth: child.implicitWidth
|
||||||
implicitHeight: child.implicitHeight
|
implicitHeight: child.implicitHeight
|
||||||
|
|
||||||
MouseArea {
|
CustomMouseArea {
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: child.top
|
anchors.bottom: child.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
onWheel: event => {
|
function onWheel(event: WheelEvent): void {
|
||||||
if (event.angleDelta.y > 0)
|
if (event.angleDelta.y > 0)
|
||||||
Audio.setVolume(Audio.volume + 0.1);
|
Audio.setVolume(Audio.volume + 0.1);
|
||||||
else if (event.angleDelta.y < 0)
|
else if (event.angleDelta.y < 0)
|
||||||
|
|
@ -30,13 +30,13 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
CustomMouseArea {
|
||||||
anchors.top: child.bottom
|
anchors.top: child.bottom
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
onWheel: event => {
|
function onWheel(event: WheelEvent): void {
|
||||||
const monitor = root.monitor;
|
const monitor = root.monitor;
|
||||||
if (event.angleDelta.y > 0)
|
if (event.angleDelta.y > 0)
|
||||||
monitor.setBrightness(monitor.brightness + 0.1);
|
monitor.setBrightness(monitor.brightness + 0.1);
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ Item {
|
||||||
|
|
||||||
background: null
|
background: null
|
||||||
|
|
||||||
contentItem: MouseArea {
|
contentItem: CustomMouseArea {
|
||||||
id: mouse
|
id: mouse
|
||||||
|
|
||||||
implicitWidth: Math.max(icon.width, label.width)
|
implicitWidth: Math.max(icon.width, label.width)
|
||||||
|
|
@ -123,7 +123,8 @@ Item {
|
||||||
|
|
||||||
rippleAnim.restart();
|
rippleAnim.restart();
|
||||||
}
|
}
|
||||||
onWheel: event => {
|
|
||||||
|
function onWheel(event: WheelEvent): void {
|
||||||
if (event.angleDelta.y < 0)
|
if (event.angleDelta.y < 0)
|
||||||
root.state.currentTab = Math.min(root.state.currentTab + 1, bar.count - 1);
|
root.state.currentTab = Math.min(root.state.currentTab + 1, bar.count - 1);
|
||||||
else if (event.angleDelta.y > 0)
|
else if (event.angleDelta.y > 0)
|
||||||
|
|
|
||||||
21
widgets/CustomMouseArea.qml
Normal file
21
widgets/CustomMouseArea.qml
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -21,10 +21,11 @@ ScrollBar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
CustomMouseArea {
|
||||||
z: -1
|
z: -1
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onWheel: event => {
|
|
||||||
|
function onWheel(event: WheelEvent): void {
|
||||||
if (event.angleDelta.y > 0)
|
if (event.angleDelta.y > 0)
|
||||||
root.decrease();
|
root.decrease();
|
||||||
else if (event.angleDelta.y < 0)
|
else if (event.angleDelta.y < 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue