Open tonsky opened 3 years ago
Hello from jwind
in #Clojurians slack channel! I'll take this one on as a first issue
@tonsky when you say lines
scroll, does this mean one "tick" of the mouse wheel? I looked into the code for Mac/Windows and it seems to be that way
No, I think in windows there’s a system setting that sets how many “lines” one wheel tick is. We should respect that when reporting it in EventMouseScroll::deltaLines
. Same for ::deltaPages
(I think it’s also a setting? You’ll have to check)
So the "lines" measure is arbitrary on Windows, are we trying to emulate this on X11? I looked into your other commits referencing this issue, seems that Windows is reporting line delta but not pages yet, and the only label on this issue currently is X11
Sorry I might have lost some context since.
So the idea is to report what’s actually happening (e.g. mouse wheel scrolls * lines per wheel tick) as well as some universal unit like pixels. So the people who just want simple solution can use pixels and those will works reasonable on all platforms. But people who want to go extra mile can be faithful to the reality. For example, if user uses mouse, users can add scroll smoothing on top of that, but not if user is on trackpad.
It seems like on Windows it’s already implemented that way.
On macOS it only reports pixels right now, which is how it should be for trackpad, but for mouse it should also report lines. I assume lines are number of ticks of mouse wheel times this setting:
As far as I can see, X11 is in the same state as Mac, but I am not sure how realistic it is to get amount of lines from X11.
It also looks like Windows lacks horizontal scroll, which can also be useful. I created a task #285
Great, thank you for the additional context, if I have any more questions I'll let you know!
I've found how to read that scroll scaling config value:
- (float)getScrollScaling {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *scrollScaling = [defaults objectForKey:@"com.apple.scrollwheel.scaling"];
// ...
}
I'm thinking of using a combination of this, and the system pixels per line in CGEventSourceGetPixelsPerLine
, to report on the line delta using the pixel delta on macos
The config value on macos appears to be a float, from 0 -> 1.0
Sounds good!
macOS: mouse wheel scroll events need to be multiplied. Chrome uses 40, druid 32, Flutter uses system-provided value which is usually set to 10 which seems too low after comparing e.g. with Safari
On Windows, scroll is reported in wheel ticks * 120, which are converted to lines (coeff in settings), which then should be converted to pixels by multiplying by 33 (Chromium, JavaFX):
On Windows, scroll might be set to pages, too, then just report pages. Possible to report px value in that case as the height of the window?