Better support for smooth scrolling trackpads and mice
Continuation of #6700. Many of the those things have already been fixed in other PRs since then.
Main issue
Scrolling in LMMS has not been designed for high-resolution trackpads and mice. It either violently reacts on every tiny movement, or completely ignores it. This PR introduces a Scroll class used to calculate scroll values. It handles high-resolution scrolling, natural scrolling and modifier keys that swap scroll direction.
Other small improvements
- Vertical scrolling in Automation Editor and Piano Roll is now relative to vertical zoom level
- Enable horizontal scrolling in Piano Roll's note edit area
- Enable scrolling on Piano in the bottom of instrument window
- Horizontal scrolling on LCD spinboxes and Knobs doesn't continuously decrease their value
- (Edit) Horizontal scroll speed in Song Editor is slightly slower.
Changes
- ~Remove Shift+scroll for horizontal scrolling in the editors~
- ~Alt+scroll already does the same thing and is built-in system-wide in Qt on Windows and Linux.~
- ~This PR brings Alt+scroll (Option+scroll) to macOS too.~
- (Edit) Shift+scroll is de-facto on many systems. Let's keep that, even if Alt+Scroll is built into Qt.
- Allow macOS to use natural scrolling on ComboBoxes (swipe up to move to next item)
- ~Is this how macOS does it on other drop down menus?~
- Native macOS drop down menus doesn't allow scrolling on them, so we can do whatever we want.
Things to test
Hey tester. There's a lot of widgets to test, I'm glad if you can help. If you have both a touchpad and mouse test if there's any difference. Here's some stuff you should look out for:
- [ ] Scroll speeds are the same as before.
- [x] Scroll directions are the same as before.
- [ ] Scroll directions for natural scrolling on macOS.
- [x] Scrolling on high-resolution trackpads.
- [x] Is it possible to scroll diagonally in the editors? (Are there trackpads that support this?)
- [ ] Press modifier keys when scrolling (see list below)
- [ ] Test that the point under the mouse does not change when scrolling to zoom
- [x] Test the scroll speed on logarithmic knobs
Widgets that have been edited and needs testing
| Where to scroll | Expected behavior | Modifier keys |
|---|---|---|
| AudioFileProcessor wave view | zoom | |
| Compressor | zoom | |
| Equalizer handle | change resonance | |
| Vectorscope | zoom | |
| Midi clip (in Pattern editor) | add note/change note volume | |
| Automation editor | scroll vertically | none |
| Automation editor | scroll horizontally | shift |
| Automation editor | scroll horizontally (Win/Lin) | alt |
| Automation editor | zoom | ctrl |
| Automation editor | zoom Y direction | ctrl+shift |
| Automation editor | change quantization | ctrl+alt |
| Piano roll | scroll vertically | none |
| Piano roll | scroll horizontally | shift |
| Piano roll | scroll horizontally (Win/Lin) | alt |
| Piano roll | zoom | ctrl |
| Piano roll | change quantization | ctrl+alt |
| Piano roll | change note length | ctrl+shift |
| Piano roll note edit area | change note volume | |
| Song editor | scroll vertically | none |
| Song editor | scroll horizontally | shift |
| Song editor | scroll horizontally (Win/Lin) | alt |
| Song editor | zoom | ctrl |
| Song editor | zoom slower | ctrl+shift |
| Piano in instrument window | scroll horizontally | |
| Track | resize height | ctrl+alt |
| Track | resize height faster | shift+alt |
| Combo box | change value | |
| Fader | change value | |
| Knob | change value (check the speed when it's set to logarithmic too) | |
| Knob | change value faster | shift |
| Knob | change value slower (on knobs with more than 1000 values) | ctrl |
| Knob | change value super slow (on knobs with more than 2000 values) | alt |
| LcdFloatSpinBox (in Scales and Keymaps) | change value | |
| LcdSpinBox | change value | |
| Envelope/FX tabs in instrument window | change tab |
Reported problems
- Alt scroll doesn't work on some Windows devices
- Alt scroll doesn't work on Wayland
- Ctrl or Shift scrolling is slower on some Windows devices
I tested this, and it works pretty great!
OS
I'm on Arch LInux with GNOME
Hardware
I'm using a touchpad built in to the laptop I use. From cat /proc/bus/input/devices it appears to be an "ETPS/2 Elantech touchpad"? I don't know what that means but hopefully that's useful lol.
$ cat /proc/bus/input/devices
...
I: Bus=0011 Vendor=0002 Product=000e Version=0000
N: Name="ETPS/2 Elantech Touchpad"
P: Phys=isa0060/serio1/input0
S: Sysfs=/devices/platform/i8042/serio1/input/input17
U: Uniq=
H: Handlers=event10 mouse1
B: PROP=5
B: EV=b
B: KEY=e420 10000 0 0 0 0
B: ABS=661800011000003
...
Testing
- Diagonal scrolling in song editor and piano roll is much better :+1:
- AudioFileProcessor zooming works. However, it is reversed, but I think it feels better that way. :+1:
- Compressor zooming seems to work as before (I didn't know you could zoom it lol) :+1:
- Equalizer handle resonance scrolling works much better :+1:
- Vectorscope zooming works :+1:
- Pattern editor volume scrolling works :+1:
- Automation Editor zooming/scrolling/etc works. The zooming and quantization changing feels a bit sensitive, but it's fine.
- Piano roll zooming/scrolling/etc works as well. Again the combo box stuff feels a bit sensitive but it's fine.
- Song editor scrolling and zooming work great. :+1:
- Scrolling piano in instrument window works. However, I noticed that scrolling left/right on my trackpad scrolls it at a normal speed, but scrolling up/down while holding shift scrolls it super fast. Idk if this was intentional or not.
- Resizing height of tracks works with alt, but not shift.
- Knobs work well, except that it seems holding ctrl while scrolling turns it at the same speed as holding alt while scrolling?
- Log knobs feel fine.
- Combo boxes/LCD number things work. :+1:
- Envelope/FX tabs in instruments work. They also feel a bit fast to me, but it's waay better than it was before so maybe it's fine.
Things I noticed
- Scrolling on faders feels super sensitive. Even with scrolling on a normal mouse.
- Scrolling on LCD numbers/combo boxes still feels maybe a tiny bit too fast for me? (or maybe it's fine, it's much better than what it used to be)
- Changing the volume of a note in the piano roll via scrolling feels a bit slow compared to the pattern editor.
Thanks for the thorough testing @regulus79
Scrolling on faders feels super sensitive
Good catch! I've fixed it now. It doesn't scroll linearly though, but it didn't before either and I'm not gonna fix that in this PR.
Diagonal scrolling in song editor and piano roll is much better
I'll check that off the TODO list
AudioFileProcessor zooming ... is reversed, but I think it feels better
That was intentional... I think
Scrolling piano in instrument window ... left/right scrolls at a normal speed, but up/down while holding shift scrolls it super fast
This seems to be a QScrollbar thing. I tested holding shift while scrolling the project notes and it scrolled faster. Good to know...
Resizing height of tracks works with alt, but not shift.
Sorry, I tricked you. It should be Alt+Shift not Ctrl+Shift.
holding ctrl while scrolling turns knobs at the same speed as holding alt
There's only a difference if the range is greater than 1000 steps, like the FREQ knob in Envelope tab.
Scrolling on LCD numbers/combo boxes still feels maybe a tiny bit too fast for me
There's not much to do, I'm afraid. If we slowed it down for you it would require two steps on a regular mouse wheel to move it one step.
Changing the volume of a note in the piano roll via scrolling feels a bit slow compared to the pattern editor.
Interesting find, I don't know if we should change it though.
We just need a macOS tester for the natural scrolling... @tresf where are you?
We just need a macOS tester for the natural scrolling... @tresf where are you?
I'll test and report my findings.
macOS testing on trackpad:
| Status | Component | Description | Modifier |
|---|---|---|---|
| ✅ PASS | Knob | change value faster | shift |
| ✅ PASS | Knob | change value slower (on knobs with a lot of values) | ctrl (Command) |
| 🚫 FAIL | Knob | change value super slow (on knobs with a lot of values) | alt (Option) |
The good:
- The knob speed is GREATLY improved with this PR. Using the trackpad to adjust knobs prior to this PR is very painful.
The bad: (including a few observations that may be contributing to the failing of the third test)
- The Alt modifier doesn't work well for flipping vertical and horizontal for the Piano Roll editor, however the scrolling seems to be controlling the horizontal in areas that should be ignored (such as track labels and track knobs scrolling the piano roll instead), so there's some propagation that existed before this PR that might be impacting this behavior.
- For this reason, I believe that Alt is allowing the "super slow" behavior properly, but due to the propagation to the piano roll, this only works on horizontal scroll (which is backwards, knobs are normally adjusted with vertical scroll). It works "OK" if used in the wrong axis, but this is clearly a bug in the implementation. For this reason, I would recommend NOT trying to re-use a single shortcut key for two separate wheel functions.
| Status | Component | Description | Modifier |
|---|---|---|---|
| 🚫 FAIL | Automation editor | scroll horizontally | alt (Option) |
| ✅ PASS | Automation editor | zoom | ctrl (Command) |
| ✅ PASS | Automation editor | zoom Y direction | ctrl+shift (Command + shift) |
macOS uses Command for zoom modifier and that works just fine however horizontal scrolling via modifier seems to be bound to Shift, not <kbd>Alt</kbd> as documented above. Trackpad's built-in horizontal works just fine without modifiers.
| Status | Component | Description | Modifier |
|---|---|---|---|
| ✅ PASS | LcdSpinBox | change value |
The accuracy of this on trackpad is GREATLY improved and the trackpad works fine for this, but sometimes the controls are passed to the parent (such as the Song Editor) and it scrolls the track away from the cursor. I've uploaded a video of this to show the (somewhat) erratic the behavior is.
https://github.com/user-attachments/assets/d6d106fe-f467-45a2-b353-2eb60717967b
| Status | Component | Description | Modifier |
|---|---|---|---|
| ✅ PASS | Envelope/FX tabs in instrument window | change tab | |
| ✅ PASS | LcdFloatSpinBox (in Scales and Keymaps) | change value |
The accuracy of these on trackpad are GREATLY improved!
Testing notes:
- I didn't test at all with mouse yet
- I didn't test every table item however general navigation feels normal, no major regressions observed.
Just adding that pinch/zoom still does not work at all with this PR. I'm not sure if that's in scope or not.
Thanks @tresf! Qt uses Alt to swap orientation on Windows and Linux. I had a vague memory that this wasn't the case on macOS so I coded an exception to disregard Alt on macOS. Maybe they've changed it? Could you test if you test if you can use Alt to swap orientation in the project notes or the mixer? (testing on any recent build will be fine)
Thanks @tresf! Qt uses Alt to swap orientation on Windows and Linux. I had a vague memory that this wasn't the case on macOS so I coded an exception to disregard Alt on macOS. Maybe they've changed it? Could you test if you test if you can use Alt to swap orientation in the project notes or the mixer? (testing on any recent build will be fine)
- Project notes does not appear to have a horizontal scroll bar
- Mixer does have a horizontal scroll bar and I'm able to switch from "vertical" to "horizontal" using Shift however it is extremely sensitive and not very useful and only works with mouse (does not work with trackpad)
- Moving my mouse over the horizontal scrollbar also allows me to adjust it without any modifiers (I assume this is the stock behavior?)
- The Shift "modifier" behavior is ignored with trackpad on mixer, but is honored on song-editor. Unlike the mixer + mouse behavior, Shift is granular and fluid when used as a modifier for the trackpad (I can't for the life of me understand why someone with a trackpad would use this modifier, but it works fine on Song Editor)
Notes to self
The Alt modifier doesn't work
Glancing through the Qt source code for macOS I see no mention of an Alt modifier [1] like there is on Windows. [2]. To match that system behavior, this PR does not use Alt to swap orientation on macOS [3].
using Shift however it is extremely sensitive
This is a thing with QScrollBar, it "moves one page regardless of delta" when holding Ctrl or Shift. [4]
I'm able to switch from "vertical" to "horizontal" using Shift ... only works with mouse (does not work with trackpad)
Seems to be something macOS does on system level [5]. This complicates things quite a bit... I don't think there's much we can do about that.
Questions to @tresf
- Is the propagation issue you show in the video only happening when you press a certain modifier and using a trackpad or mouse?
- Does it not happen on master?
- Alt should not change orientation on macOS, and it seems to working fine, but somehow it still affects knobs?
- If shift changes direction with regular mouse, then shift+scroll with a regular mouse on knobs shouldn't work?
And also, in which direction does "combo boxes" scroll in other apps on macOS?
Is the propagation issue you show in the video only happening when you press a certain modifier and using a trackpad or mouse?
Just to focus on this one issue a bit... (Trackpad only)
- Currently anything left of the editor area (track labels, gear, mute, solo, mixer and knobs) allows the trackpad to scroll left and right in the Song-Editor. This is much more consistent with this PR versus master branch (for example, master branch works on track labels, gear, mute, solo but NOT on mixer and knobs)
- Where this PR acts a bit weird (still a huge improvement over master) is when Alt (Option) is pressed. Here's a screen recording of holding Alt (Option) and scrolling the trackpad left/right. I think what's happening is since some of the scroll direction is being polluted (fingers drift on the trackpad), both directions are being triggered at the same time.
https://github.com/user-attachments/assets/1a905a6b-e9b5-41cb-b937-ab6e278bd2e0
Alt should not change orientation on macOS, and it seems to working fine, but somehow it still affects knobs?
Correct, with the trackpad, knobs and sliders are inverted with Alt (Option). This may be normal but I wanted to share.
Seems to be something macOS does on system level [5]. This complicates things quite a bit... I don't think there's much we can do about that.
Yeah it's just odd to have Shift do something different between knobs / sliders (faster) and scroll bars (invert). I feel the same way about Alt (Option) being used for both slow control as well as inversion modifier, but if no one else cares, I won't complain. With exception of pinch/zoom missing, navigation on a trackpad is so much better than a conventional mouse and this PR makes that even better.
And also, in which direction does "combo boxes" scroll in other apps on macOS?
I tested this in GarageBand and Safari and macOS combo boxes don't respond at all to trackpad "scroll" events.
I think what's happening is since some of the scroll direction is being polluted (fingers drift on the trackpad), both directions are being triggered at the same time
I think you nailed it
knobs and sliders are inverted with Alt (Option)
Like X/Y swapped or up/down swapped?
I'm testing scrolling in Windows 11 on my old laptop with a synaptics touchpad. These are my (not LMMS specific) findings:
- Scrolling doesn't work anywhere in the OS when Alt is pressed... 😐
- Not all system apps uses Shift to scroll horizontally. Browsers do. Explorer, Notepad, Taskmanager, doesn't.
- Ctrl or Shift makes scrolling slower in apps like Task manager and Explorer.
- In Qt apps Ctrl or Shift makes it scroll a whole page each time (QScrollBar feature), but since scrolling seems to be slowed down by the system it takes a larger than usual movement to make it move.
- In Qt apps horizontal scrolling (on my synaptics touchpad) is interpreted as left/right arrow key presses. So I can move the cursor in a textfield in VLC by scrolling horizontally. This is not the case for native apps.
I have developed a new hatred towards this issue.
Edit: I heard from other Windows users that Alt works fine for them. Maybe all of these issues are just because I have an old touchpad with a sketchy driver.
I think what's happening is since some of the scroll direction is being polluted (fingers drift on the trackpad), both directions are being triggered at the same time
I think you nailed it
knobs and sliders are inverted with Alt (Option)
Like X/Y swapped or up/down swapped?
When Alt (Option) is used on the knobs, it slows down the sensitivity AND inverts, so the knobs can only be adjusted by swiping the wrong way (up/down won't adjust the knob, only left/right will).
When Alt (Option) is used on the sliders, it doesn't seem to impact sensitivity but still inverts (up/down do nothing whereas left/right is needed to adjust the slider).
Re-quoting:
I would recommend NOT trying to re-use a single shortcut key for two separate wheel functions.
Huh, well that makes things easier, then I can remove the macOS specific code
Tested on Windows 11 on an ASUS Precision Touchpad and Logitech M170/M171 mice. Works fine, Shift and Alt changes the scroll direction to left/right. Diagonal scrolling also works fine
Thank you to everyone who tested this!
@tresf whenever you get around to it, make a final test that Option can switch X/Y now and confirm that scrolling up increases the volume of Faders, even though you have natural scrolling. I agree that Alt shouldn't do multiple things, but there's not so much we can do about it being used to swap X/Y. And most people also want Shift to do that.
Since the problems seems to be so OS dependent, there are probably more edge cases to be found. But the current state of LMMS is so horrible on a trackpad / smooth scrolling mouse, so the sooner we get it merged the better. And then I'm sure those bug reports will drop in eventually :) GUI code is cheap to fix, no backwards compatibility to worry about.
@tresf whenever you get around to it, make a final test that Option can switch X/Y now and confirm that scrolling up increases the volume of Faders, even though you have natural scrolling. I agree that Alt shouldn't do multiple things, but there's not so much we can do about it being used to swap X/Y. And most people also want Shift to do that.
Knobs
- Shift acts as an accelerator for up/down
- Super (Command) acts as a decelerator for up/down
- Shift acts as an inverter for left/right to make it instead go up/down
- 🚫 Alt (Option) doesn't appear to work as an inverter
Faders
- Shift acts as an accelerator for up/down
- Super (Command) acts as a decelerator for up/down
- Alt (Option) acts as an inverter for left/right to make it instead go up/down
- 🚫 Shift doesn't appear to work as an inverter
sooner we get it merged the better
I agree, this is all a vast improvement, I just have serious issues with dual function keybindings. All it takes is for a fader to be left/right and bindings like Shift start to break my brain. Furthemore, bindings such as Super + Scroll for Zoom otherwise break any future possibility for a decelerator key. (I understand that complaining about this is much less effort -- and less productive -- than helping choose a better shortcut system, but I have a fear that if we don't iron this out now, we'll be struggling with this for years to come)
I'd also like to make a prominent note that Shift SLOWS the controls when the mouse is used but SPEEDS the controls when the trackpad is used, another head-scratcher.
I acrually didn't looked at anything, but I love Smooth Scrolling!
Downloads are available here: https://lmms.io/download/pull-request/7941
We need to the bottom of how Qt receives WheelEvents on macOS before we can continue.
- I think we settled that Qt switches x/y when
Altis pressed. - Does the OS also intervene in some way when modifiers are pressed?
- Is there a difference between how the OS handles a trackpad and a mouse?
- Does different Qt widgets have different default behavior?
First of all, let's make sure we both use the same terminology. To make it easier (for me), let's call the keys by the names that are used in the codebase:
Secondly, I've hacked together a tool that will print out some debug info for WheelEvents on different widgets. Download the build and open Project notes.
https://github.com/allejok96/lmms/actions/runs/16240581001#artifacts
For the record, these are my findings on Linux with trackpad. Left/right scroll not supported :cry: (by my hardware)
No modifiers, scrolling up
- Positive Y values.
- Scroll area moves to the top
- Sliders moves up/right
- Scrolling directly on the scrollbars moves them up/left
Alt, scrolling up
- Positive X values
- Moves to the left side of the text
- The sliders move down and left :thinking:
- Scrolling directly on the scrollbars moves them up/left
Ctrl or Shift
Values are the same, but widgets move faster.
Meta
Same as no modifiers. Also, combining modifiers simply combine their behavior.
The values inv and phase are always zero.
For the record, these are my findings on Linux with trackpad. Left/right scroll not supported :(
Wow. macOS support is starting to look sunny. ☀️