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

Touchpad scrolling does not scale with monitor scale #4703

Closed
xsrvmy opened this issue Feb 13, 2022 · 14 comments · Fixed by #4705
Closed

Touchpad scrolling does not scale with monitor scale #4703

xsrvmy opened this issue Feb 13, 2022 · 14 comments · Fixed by #4705
Labels

Comments

@xsrvmy
Copy link
Contributor

xsrvmy commented Feb 13, 2022

The handling for touchpad scrolling in mouse.c uses the line height in physical pixels, which means scrolling is slower on hidpi screens. This is especially apparent in mixed dpi environments using wayland. It was mentioned in another issue that this might not be as obvious on macOS, but that might be due to the way macOS handles mixed dpi rendering.

The better way to handle this is probably to divide the line height by the monitor scale.

(Note: I am using dpi and scale interchangably. Kitty doesn't seem to respect dpi on X anyways.)

@xsrvmy xsrvmy added the bug label Feb 13, 2022
@kovidgoyal
Copy link
Owner

kovidgoyal commented Feb 13, 2022 via email

@xsrvmy
Copy link
Contributor Author

xsrvmy commented Feb 13, 2022

This is a density-dependent pixel vs physical pixel problem. A touchpad's input is based on physical length, which means it should be mapped to density-dependent pixels, but the code in mouse.c uses physical pixels from the cell rendering instead.

BTW, the number reported by wayland is just some arbitrary unit of measurement, not pixels. For example a mouse wheel scroll sends 15 which is actually in degrees.

Regarding Xft.dpi, does kitty only read .Xresources and not .Xdefaults or something? Because I do have Xft.dpi set to 192.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Feb 13, 2022 via email

@xsrvmy
Copy link
Contributor Author

xsrvmy commented Feb 13, 2022

I don't know what QT does, but alacritty uses winit which scales the pixel size of the input event before it even reaches alacritty. I'm guessing wayland expects this hidpi conversion to be handled by the windowing library. So if we want to do the equivalent, it would be done in wl_init.c in glfw again.

@kovidgoyal
Copy link
Owner

@kovidgoyal
Copy link
Owner

And just for giggles I did some related reading and apparently axis_discrete is going to be deprecated: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/72

Coming to this issue, I think it is OK to scale the pixels if the following is true: Does the same motion produce the same event stream from the compositor regardless of the scale of the current monitor? It would be good to be able to test this with at least a couple of major wayland compositors. If it is true they I guess we need to scale in application code.

@xsrvmy
Copy link
Contributor Author

xsrvmy commented Feb 13, 2022

I can't actually tell exactly what konsole is doing actually. It seems like it might be doing something with QT's scrollbar though which presumably uses density-dependent pixels already.

Whether this should be handled by the application or the windowing/ui library is really a matter of convention I think. Handling it it in glfw is actually very easy for wayland, and I have no idea if macOS actually needs this fix. The only possible concern is the recent change to ignore the touch multiplier for alternate mouse control which could make the touchpad way too slow.

@xsrvmy
Copy link
Contributor Author

xsrvmy commented Feb 13, 2022

"Does the same motion produce the same event stream from the compositor regardless of the scale of the current monitor?"

I'm getting slower scrolling on my hi dpi screen when testing on gnome (with and without frame buffer scaling), KDE and sway, so I believe yes.

@page-down
Copy link
Contributor

Someone with mixed monitors on macOS needs to check there what the behavior is.

Under macOS, scrolling speed is consistent across different DPI screens using Trackpad (or mouse) and everything works fine.
Any changes should not affect the way macOS works now.

One question, using the mouse wheel under macOS, a single scroll is always one scrollback row.
The scroll multiplier only affects the scroll acceleration.
I wonder if I can set it to scroll three scrollback rows in one scroll. However, my scrolling has acceleration, so it is not very needed.

This is the only problem about scrolling under macOS, in my opinion.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Feb 14, 2022 via email

@kovidgoyal
Copy link
Owner

kovidgoyal commented Feb 14, 2022 via email

@page-down
Copy link
Contributor

page-down commented Feb 14, 2022

What is one scroll here? Is this with a wheel with clicks?

Yes, scroll wheel with clicks. (one click)

@xsrvmy
Copy link
Contributor Author

xsrvmy commented Feb 14, 2022

That's a different issue I think.
There is a comment in the code about mouse generating very small scrolling events, but the scaling is applied before that.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Feb 14, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants