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
Fix smooth scrolling Linux Wayland. #205122
Fix smooth scrolling Linux Wayland. #205122
Conversation
Thanks for working on this, I have a follow-up question
Would it be related to the fractional scaling support on wayland ? Does the current integer based smooth scrolling work fine in your setup when the scale factor is forced via How does the scroll delta values look like in x11 for comparison, does it also support fractional scaling ? |
Thank you! |
Thank you for merging this @alexdima and @sandy081! Apologies @deepak1556 for not replying earlier, life has been busy, but when is it not?
It might, though my fractional scaling is set to 1.25, not 1.5. 🤔 I'm currently leaving to visit family for a short while so wouldn't be able to test this unfortunately. I'd be interested myself if you were to have the time.
The X11 scroll deltas were rounded like the other test values. I was going to add some test values for those, but did not end up having the time unfortunately. |
@AndreasBackx does this modify mouse-wheel scrolling only? When scrolling with a touchpad, vs-code does not have "momentum" like with chrome, firefox, etc. but perhaps that's not related to this smooth-scrolling? At least, scrolling with the touchpad has the same behavior before and after this PR. |
Ah yes, I am talking about "kinetic scrolling", there's an issue here: #201937 Sorry for the noise! |
Fixes #182499.
MouseWheelClassifier
is trying to assess whether the scrolling device is actually a physical scroll wheel and not a touchpad (or touch screen?). There is an_computeScore(...)
function that tries to assess a particular scroll event and give it a likelihood of whether it's a physical device or not. This particular part was the reason why the identification failed on Wayland Linux:This is saying that when the delta movement is not a round number, it's more likely to be a touchpad.
The problem however is that on Linux the scroll delta is not a round number like on MacOS and Windows, its base is 1.5 for some reason instead of for example 1 or 2. To replace this, I've found a more reliable way to determine this particular part, see the changed files.
What I'm doing is verifying whether the delta from the current event is a modulo of the previous event or vice versa. This seems to be a more reliable way of detecting a physical scroll wheel. I am keeping the original implementation however because this new implementation won't work on the first event. I've given it a higher score deduction instead and MacOS / Windows still have original behaviour.
I've also added updated the tests with test data from my machine.
I was considering making a newer version of the classifier, see below. Though it wasn't entirely reliable. This seems to be a rabbit hole that I would rather stay out of so I opted for the approach above. It's a bit of a bummer that the type of input device is not available to JS. This has the code I was considering on adding...