Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventMouseScroll: Report lines scroll separate from px scroll #115

Open
tonsky opened this issue Aug 19, 2021 · 10 comments
Open

EventMouseScroll: Report lines scroll separate from px scroll #115

tonsky opened this issue Aug 19, 2021 · 10 comments
Labels
Good First Issue Good for newcomers Help Wanted Extra attention is needed Platform: macOS Platform: X11

Comments

@tonsky
Copy link
Collaborator

tonsky commented Aug 19, 2021

No description provided.

@tonsky tonsky self-assigned this Aug 19, 2021
@tonsky tonsky changed the title Mouse scroll amount: px or lines? EventMouseScroll: Report lines scroll separate from px scroll Aug 29, 2021
@tonsky tonsky added the Design API design is needed before implementation label Aug 29, 2021
@tonsky tonsky removed their assignment Oct 22, 2021
@tonsky
Copy link
Collaborator Author

tonsky commented Oct 28, 2021

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):

ticks = GET_WHEEL_DELTA_WPARAM / WHEEL_DELTA (=120)
px = ticks * SPI_GETWHEELSCROLLLINES/SPI_GETWHEELSCROLLCHARS * 100.0f / 3.0f

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?

@tonsky tonsky added Platform: macOS Platform: Windows Platform: X11 and removed Design API design is needed before implementation labels Oct 28, 2021
tonsky added a commit that referenced this issue Oct 28, 2021
@tonsky
Copy link
Collaborator Author

tonsky commented Oct 29, 2021

@tonsky tonsky added Good First Issue Good for newcomers Help Wanted Extra attention is needed and removed Platform: Windows Platform: macOS labels Oct 29, 2021
@jaketothepast
Copy link

Hello from jwind in #Clojurians slack channel! I'll take this one on as a first issue

@jaketothepast
Copy link

@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

@tonsky
Copy link
Collaborator Author

tonsky commented Jan 19, 2024

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)

@jaketothepast
Copy link

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

@tonsky
Copy link
Collaborator Author

tonsky commented Jan 19, 2024

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:

Screenshot 2024-01-19 at 20 23 28

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

@jaketothepast
Copy link

Great, thank you for the additional context, if I have any more questions I'll let you know!

@jaketothepast
Copy link

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

@tonsky
Copy link
Collaborator Author

tonsky commented Jan 21, 2024

Sounds good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue Good for newcomers Help Wanted Extra attention is needed Platform: macOS Platform: X11
Development

No branches or pull requests

2 participants