scroll: round up fractional mouse scroll ticks
Scrolling with a mouse on macos doesn't work very well when doing small, single tick scrolls. macos attempts to mimic precision scrolling by changing the magnitude of the scroll deltas based on scrolling speed. Slow scrolls only send deltas with a magnitude of 0.1, which isn't enough to send a single scroll event with the default scroll multiplier of 3. Changing the scroll multiplier to 10 as a workaround (so even single small scroll ticks are enough to register a scroll event) cause scrolling to be way too fast if the scroll speed is ramped up.
This commit causes the yoffset delta to be rounded out to at least a magnitude of 1 in the appropriate direction. Single scroll ticks now register as a single vertical cell scroll event, but as scroll speed is ramped up, the true delta reported to the surface is used again. Setting a scroll multiplier of 1 with the changes here makes mouse scrolling feel just as good as trackpad precision scrolling.
On Linux, we get a magnitude of 1.0 for a generic wheel click regardless of speed. If I understand this correctly, macOS does speed scaling at the OS level for wheel ticks? As in - a wheel tick magnitude depends on the momentum of the scroll?
On Linux, we get a magnitude of 1.0 for a generic wheel click regardless of speed. If I understand this correctly, macOS does speed scaling at the OS level for wheel ticks? As in - a wheel tick magnitude depends on the momentum of the scroll?
Yeah, that's basically exactly what happens. macOS "pretends" to do precision scrolling by ramping up the offsets when you scroll "fast" (ticks / time unit). The smallest unit (one tick / time unit) is always -0.1 or 0.1 but it quickly ramps up depending on the mouse scroll speed setting in macos' mouse settings panel.
I was pretty sure Linux always reports a magnitude of 1.0, so this change shouldn't affect the way Linux scrolling works at all. It just makes scrolling on macOS behave much closer to intuitive expectations and how other apps scroll within the OS.
I can confirm this doesn't change behavior of scrolling on linux. I think we should have @mitchellh confirm the behavior on macos before merging though. If he signs off on how it feels I am good on this one.
Ping @mitchellh - would you be able to test / merge this when you get some time? Thanks!