-
Notifications
You must be signed in to change notification settings - Fork 539
Fix zoom not working while scrolling slowly on macOS, take WHEEL_DELTA into account on Windows. #825
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
Conversation
|
@vespakoen What's wrong with the way scroll wheell works now? |
|
Right now I have to scroll "large amounts" for a zoom to happen, and the amount / speed is not taken into account. Right now it casts the scroll amount to an integer, and always zoom by *= or /= 1.2. When scrolling slowly now, nothing happens, with this change, scrolling starts immediately and is smooth. However, this is only tested on macOS right now, and I should probably change the code so it actually only changes the scrolling behaviour on macOS right now until I test / implement it on Windows / Linux. |
11408ac to
aa0950d
Compare
|
I made some changes so that it should only affect macOS. can someone test this on Windows / Linux? On macOS I tested it with a Magic Trackpad 2, a Magic Mouse and a simple Logitech mouse with a scroll wheel and those are all working great now. |
4b24536 to
8a0b29c
Compare
|
I amended the commit and force pushed it to what I think should be the right incantation for Windows. With a normal mouse I can not achieve anything but 0.2 (1.2) though. I'll go to a machine with a 10 point multi touch screen now and test. I don't have access to a Windows laptop with a "modern" trackpad so if anyone has please test it. |
|
I'll test it out with my 3 "mice" on Windows this evening (need to be on macOS for work today) |
|
Tried zooming with
On all of them But scrolling works just as good as it always has on Windows, so I am fine with this change. |
|
By the way the documentation states:
So theoretically some devices may send different deltas, but the ones I have probably just generate more or less frequent events with 120. But the calculation event.scrollDelta = 0.2 * GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA;should handle them properly. |
|
Awesome! Excited to try it out later, thanks a lot =) |
|
I just tried this out in Windows, it works fine but the scrolling is a bit coarse to my taste, I would suggest using 0.1 in stead of 0.2 for the scaling. The logic all looks correct though, and trackpad and mouse behave similarly. Guess we just have to make sure nothing broke on linux. I bricked my linux install but I will try to get it working again or boot it live from a usb stick tomorrow. |
|
The patch (from the commit) here works on Linux. Not sure the zooming is any different on my normal 3-button mouse. Might be a little more sensitive but not excessively IMO. |
|
I just changed the zoom to 0.1 for windows and linux, let me know if this makes things too slow or if it is fine. |
|
A definite HUGE NO from me for a 1.1 (0.1) zoom factor! Unacceptably slow! |
|
Fair enough, It looks like Windows just doesn't support my "Magic Trackpad" well, everything scrolls way to fast (even when setting to "scroll 1 line" only) So I will revert Windows and Linux to 0.2, and call it good =) |
1667b45 to
126ea8b
Compare
|
If for some reason "very fine zooming" is important we can (at least on Windows) easily do I'm sorry for being too "pushy" but I pushed this change. Please comment. Shift+Scroll should be also trivial on GTK but I can not test it. |
c5d1bfb to
d081d5a
Compare
|
OK I pushed guigtk.cpp without even compiling it (it seems trivial enough) - I am sorry. @vespakoen @phkahler please try it. And if the whole "Shift+Scroll" idea seems stupid I will revert it. Attached is a Windows binary for testing |
|
No worries on being "pushy", happy that it's being worked on... It looks like on Linux we don't take the 'distance scrolled' into account yet, and simply look at the amount of events. |
|
The current version of this seems to work fine on Linux. |
|
BTW using SHIFT is enough to slow it way down on Linux. Seems like a nice little extra. |
d081d5a to
dacadea
Compare
|
After playing with it some more I changed the Especially @jwesthues what is your opinion on the whole @vespakoen Should we do something on Mac with On Linux/GTK using actual scroll deltas for smooth scrolling definitely seems possible based on the docummentation. It seems some systems even send On Windows smooth scrolling seems to be a matter of support in the lower layers (drivers, devices) and the current code in this PR should "just work" when a device supports it. One thing we can improve is use SystemParametersInfoW to get SPI_GETWHEELSCROLLLINES which is the "number of lines to scroll per WHEEL_DELTA" in the mouse options in Control Panel (default 3) we could use this to increase or decrease the default 1.2 zoom factor. This would solve @vespakoen's problem with scrolling being too sensitive and the configuration not making a difference. |
|
An here https://fossies.org/linux/scintilla/gtk/ScintillaGTK.cxx on line 1897+ they simulate smooth scrolling by timing the scroll events.... brrrrr... |
Yeah, screw that. It's an unsupported feature further upstream and that's where it should be fixed. BTW, how does it run on the PI? I've been dying to know. |
It works fine. I have not done anything complicated so I can not say much about the performance. Starting takes a perceptible time - a second or two. There is a strange glitch with the menu bar disappearing (black). You need to hit e.g. One thing it does better than Windows is render tiny objects at huge zoom levels (guess what I was testing:-D ). I think this is because it uses some kind of 128bit OpenGL implementation. I will post details when I am on the Raspberry again. Unlike Windows dimension lines are properly drawn down to ~1.5nm and zoomed in to take up the whole (1920x1080) screen. |
Absolutely! |
6c126d8 to
269d561
Compare
|
Thanks for all the suggestions and testing! I just noticed this PR breaks the scrolling on the text window (at least on macOS). I am working on a fix... EDIT: done The option to precisely scroll while holding Shift is also a nice addition, this way I can "smooth scroll" on Windows with the trackpad. @ruevs this line:
I ignored the scrollDelta for the TextWindow and now it seems to be working again. Let me know if this works fine on Windows and Linux, then this should be good to go. |
269d561 to
90e78f9
Compare
The diff outdated, but the changes are made.
|
I'll take alook soon(ish) :-) |
|
Cool, and no rush! the important thing to make sure still works fine is scrolling the info panel. |
|
OK going one by one:
I looked at the macOS docs
We do have a In my opinion you should test with a "normal" (PC) mouse connected to the mac and see what In this way (I guess) you should not have to change textwin.cpp. Also does using With all of the above in mind I will force push my changes to make delta=1 by default (and 0.1823216). I will also revert the text window change - it does not seem right - please see above and double check what is going on on Mac. |
03aa308 to
0960c59
Compare
|
@vespakoen even if you figure out the text window on Mac please do not merge this yet. And also the |
|
Hey, this is great! I was also thinking to change the scroll delta back to 1, so thanks for that! And The problem with the text window I had (on macOS) was that when scrolling less than a line, the text window "jumps back up" to the nearest line, so every scroll event should at least move it a whole line for it to even scroll at all on macOS. Basically it would have been nicer if the Window itself would handle the scrolling, and the content would change based on the position, but that is out of the scope of this issue. |
0960c59 to
1c1b736
Compare
On macOS actual scroll delta is used for the zoom amount. On Windows WHEEL_DELTA is used to allow smooth scrolling if supported. Shift+Scroll is added for 10x finer zooming.
1c1b736 to
f237ab3
Compare
|
I updated the code to use The text window also scrolls better now by removing this from guimac in - if(onScrollbarAdjusted) {
- onScrollbarAdjusted(pos);
- }When scrolling very slowly, the I added a check back to the TextWindow that now makes sure the scrollDelta is at least 0.2 or -0.2 which results in an offset of at least 2 pixels. Somehow, using 1 pixel didn't fix it, It has to do with rounding somewhere, but that was too hairy to try and understand for me at this point. The code I wrote can probably be expressed better than I did now, let me know if you have any suggestions, or simply force push again ;) |
|
Can we merge this and make a new PR for smooth scrolling on Linux once that's a thing? |

This is for macOS only at the moment, and probably breaks scrolling on windows and linux.
This is just an initial experiment, tested with a trackpad and an external mouse with a scroll wheel on macOS.
I will test this on windows and linux and will move the calculations to the platform specific code.
EDIT: Damn.. looks like my editor decided to format the whole mouse.cpp file...