forked from Shinonome/dots-hyprland
fix(touchpad): differentiate scroll speed between touchpad and mouse wheel
This commit is contained in:
@@ -1,6 +1,24 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
|
id: root
|
||||||
maximumFlickVelocity: 3500
|
maximumFlickVelocity: 3500
|
||||||
boundsBehavior: Flickable.DragOverBounds
|
boundsBehavior: Flickable.DragOverBounds
|
||||||
|
|
||||||
|
property real touchpadScrollFactor: 100
|
||||||
|
property real mouseScrollFactor: 50
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.NoButton
|
||||||
|
onWheel: function(wheelEvent) {
|
||||||
|
var delta = wheelEvent.angleDelta.y / 120;
|
||||||
|
// The angleDelta.y of a touchpad is usually small and continuous,
|
||||||
|
// while that of a mouse wheel is typically in multiples of ±120.
|
||||||
|
var scrollFactor = Math.abs(wheelEvent.angleDelta.y) >= 120 ? root.mouseScrollFactor : root.touchpadScrollFactor;
|
||||||
|
var targetY = root.contentY - delta * scrollFactor;
|
||||||
|
targetY = Math.max(0, Math.min(targetY, root.contentHeight - root.height));
|
||||||
|
root.contentY = targetY;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ ListView {
|
|||||||
property real dragDistance: 0
|
property real dragDistance: 0
|
||||||
property bool popin: true
|
property bool popin: true
|
||||||
|
|
||||||
|
property real touchpadScrollFactor: 100
|
||||||
|
property real mouseScrollFactor: 50
|
||||||
|
|
||||||
function resetDrag() {
|
function resetDrag() {
|
||||||
root.dragIndex = -1
|
root.dragIndex = -1
|
||||||
root.dragDistance = 0
|
root.dragDistance = 0
|
||||||
@@ -23,6 +26,20 @@ ListView {
|
|||||||
maximumFlickVelocity: 3500
|
maximumFlickVelocity: 3500
|
||||||
boundsBehavior: Flickable.DragOverBounds
|
boundsBehavior: Flickable.DragOverBounds
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.NoButton
|
||||||
|
onWheel: function(wheelEvent) {
|
||||||
|
var delta = wheelEvent.angleDelta.y / 120;
|
||||||
|
// The angleDelta.y of a touchpad is usually small and continuous,
|
||||||
|
// while that of a mouse wheel is typically in multiples of ±120.
|
||||||
|
var scrollFactor = Math.abs(wheelEvent.angleDelta.y) >= 120 ? root.mouseScrollFactor : root.touchpadScrollFactor;
|
||||||
|
var targetY = root.contentY - delta * scrollFactor;
|
||||||
|
targetY = Math.max(0, Math.min(targetY, root.contentHeight - root.height));
|
||||||
|
root.contentY = targetY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
add: Transition {
|
add: Transition {
|
||||||
animations: [
|
animations: [
|
||||||
Appearance?.animation.elementMove.numberAnimation.createObject(this, {
|
Appearance?.animation.elementMove.numberAnimation.createObject(this, {
|
||||||
|
|||||||
@@ -282,6 +282,9 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\)
|
|||||||
spacing: 10
|
spacing: 10
|
||||||
popin: false
|
popin: false
|
||||||
|
|
||||||
|
touchpadScrollFactor: 600
|
||||||
|
mouseScrollFactor: 200
|
||||||
|
|
||||||
property int lastResponseLength: 0
|
property int lastResponseLength: 0
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
|
|||||||
@@ -137,6 +137,9 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
|
touchpadScrollFactor: 600
|
||||||
|
mouseScrollFactor: 200
|
||||||
|
|
||||||
property int lastResponseLength: 0
|
property int lastResponseLength: 0
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
|
|||||||
Reference in New Issue
Block a user