diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-29 09:48:44 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-29 09:48:44 +0100 |
| commit | 8ba0f00279cf5264c9aad4323afbc6887bf76f57 (patch) | |
| tree | 8303ac716076058f134ba86b6ee906751ef23898 /shared/WheelScroll.qml | |
| parent | 61467b2d35c9b78b352908f8236c0afea45cf635 (diff) | |
| download | quickshell-8ba0f00279cf5264c9aad4323afbc6887bf76f57.tar.gz quickshell-8ba0f00279cf5264c9aad4323afbc6887bf76f57.zip | |
The settings window's fix applied everywhere: under Wayland a mouse
notch carries pixelDelta 15, which Flickable trusts, so the drawer
tiles, notification list, clipboard, notes, assistant lists, steps
window, OBS scenes, hosts and bookmarks all crawled 15px a notch.
Bookmarks had its own handler that preferred a non-zero pixelDelta and
so carried the same bug at 30px.
WheelScroll.qml moves to shared/ and is linked from desktop/, hosts/
and bookmarks/, as Theme.qml is. Steps: a tile row for the drawer,
three card rows for bookmarks, 60px for the two small text boxes, 40px
for OBS scenes, 150px elsewhere. Its clamp now honours topMargin and
bottomMargin, which bookmarks' grid uses.
The animated step fires no movementStarted, which the assistant chat
used to stop following a streaming reply once the user scrolled up, so
WheelScroll gains a settled signal and the chat sets stick from atYEnd
on it.
games/ is untouched: its PathView steps one tile per notch on
angleDelta and never had the bug.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'shared/WheelScroll.qml')
| -rw-r--r-- | shared/WheelScroll.qml | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/shared/WheelScroll.qml b/shared/WheelScroll.qml new file mode 100644 index 0000000..d7e4b3f --- /dev/null +++ b/shared/WheelScroll.qml @@ -0,0 +1,61 @@ +// Copyright (C) 2026 Danilo M. <danix@danix.xyz> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +import QtQuick + +// Mouse wheel scrolling for a Flickable: a fixed distance per notch, +// animated, the same up and down. Qt's own wheel handling took a long +// list dozens of notches whatever maximumFlickVelocity said. Notches that arrive mid-animation add to its +// end point, so a fast spin travels further. +// +// angleDelta only. Under Wayland a mouse notch arrives as angleDelta 120 +// with pixelDelta 15 and a device typed touchpad (measured), so trusting +// a non-zero pixelDelta, as Flickable does, scrolled 15px a notch. +// ponytail: a real touchpad then scrolls by step too; tell the two apart +// (e.g. pixelDelta != angleDelta / 8) if one is ever used here. +// +// Takes no buttons, so clicks reach what is under it; wheel events that +// an inner item (a slider, a nested list) accepts never reach it. +MouseArea { + id: ws + property Flickable flick + // Pixels per notch. + property real step: 150 + // At the end of each animated step: a programmatic contentY change + // fires no movementStarted/Ended, so a view tracking user scrolls + // listens here instead (assistant/Card.qml). + signal settled() + + acceptedButtons: Qt.NoButton + + function clamp(y) { + const top = flick.originY - flick.topMargin; + return Math.max(top, Math.min(y, Math.max(top, + flick.originY + flick.contentHeight + flick.bottomMargin - flick.height))); + } + + NumberAnimation { + id: anim + target: ws.flick + property: "contentY" + duration: 180 + easing.type: Easing.OutCubic + onFinished: ws.settled() + } + + onWheel: wheel => { + flick.cancelFlick(); + const from = anim.running ? anim.to : flick.contentY; + anim.stop(); + anim.to = clamp(from - wheel.angleDelta.y / 120 * step); + anim.start(); + } +} |
