vhakulinen / gnvim

GUI for neovim, without any web bloat
MIT License
1.84k stars 69 forks source link

Implement smooth scrolling support #175

Closed jeanguyomarch closed 3 years ago

jeanguyomarch commented 3 years ago

Scrolling with the touchpad had no effect. It seemed scrolling events were purely ignored. As explained in #70, this is due to smooth scrolling. The problem with enabling smooth scrolling is that it generates a lot of scrolling events, resulting in overly fast scroll without further processing.

The solution here consists in hooking on the "start scroll" event to reset a scrolling counter (this requires to bump the GTK version). When the scrolling is hapening, this counter is incremented with the scrolling deltas. When it reaches -1.0 or +1.0 (which is the value that "normal scrolling" sends), we trigger a scrolling event (down or up, depending on the sign) and reset the counter.

Overall, it enables scrolling in gnvim with the touchpad.

This probably fixes #70.

vhakulinen commented 3 years ago

Nice, thanks for the PR! I'll to take a closer look and test this within a week or so.

vhakulinen commented 3 years ago

I dropped the gtk version requirement back to 3.18 so we don't change the requirements for gnvim. This meant that the EventControllerScroll usage had to be removed, but scrolling still worked on wayland + touchbad combo. Only down side is that the delta value isn't rested anymore on scroll start.