Closed Bug 1213601 Opened 4 years ago Closed 6 months ago
Kinetic scrolling does not work on Linux
How to enable/disable kinetic scrolling? Go to `about:config` and toggle pref `apz.gtk.kinetic_scroll.enabled`
GTK 3 kinetic scrolling does not work, but does work in native applications. Note: my system has no kinetic scrolling emulation at driver level enabled (common with synaptics drivers). See an attached video for the demonstration.
Does this just apply to touch screens?
This is reproducible on regular touchpad with xf86-input-libinput driver.
Ah, I also forgot to mention this is gtk 3.18.
That's strange; the GTK documentation mentions that "Kinetic scrolling only applies to devices with source GDK_SOURCE_TOUCHSCREEN."
Hmm, that might be just a documentation bug, especially given it is noted in release notes https://help.gnome.org/misc/release-notes/3.18/more.html.en#scrolling.
If you're referring to support for floating point scroll deltas (smooth scrolling), you'll need to set the environment variable MOZ_USE_XINPUT2. See bug 1207700 for more details.
No, this is about scrolling "inertia" - the content keeps moving after the fingers have been lifted after a flick. Though, the implementation in GTK3 might need XInput2 regardless.
I already have “smooth” scrolling in a sense that firefox seems to scroll in as precisely as 1 pixel increments, implying XInput2 being enabled (starting with the environment variable changes nothing, for the record). I’m referring here to kinetic scrolling (as specified in issue title) where removing fingers from the touchpad while scrolling will not immediately stop scrolling but decrease in speed over a period of time (seems to be 1.5 seconds or thereabouts). I think it is clearly visible in the video. In firefox, removing fingers from the touchpad will stop scrolling immediately. The scrolling in the video might look a little bit janky, though, because I had to record it at 15 fps.
(In reply to Jan Steffens from comment #7) > No, this is about scrolling "inertia" - the content keeps moving after the > fingers have been lifted after a flick. > > Though, the implementation in GTK3 might need XInput2 regardless. My mistake; looks like kinetic scrolling is indeed implemented at the widget level (see gtkscrolledwindow.c) and not in simulated XI2 events (as some touchpad driver implementations provided). It looks like the scrolling follows a deceleration path after the GdkEventScroll event reports scroll deltas of zero. I'm not sure how kinetic/fling scrolling is implemented on other platforms in Gecko, I suspect we'll be able to reuse some code for this rather than have to re-implement this in the widget code.
The FAQ of libinput says: > libinput does not implement kinetic scrolling for touchpads. Instead it provides the libinput_event_pointer_get_axis_source() function that enables callers to implement kinetic scrolling on a per-widget basis, see Scroll sources. Meaning that it's up to the client to implement it. https://wayland.freedesktop.org/libinput/doc/latest/faq.html
I just compiled firefox nightly with --enable-default-toolkit=cairo-gtk3-wayland. It seems that I do have pixel perfect scrolling (as discovered in this bug earlier) but I don't have kinetic scrolling, the inertia after releasing both fingers from scrolling on the touchpad. This is on gnome-shell on wayland and therefore using libinput. It seems that we would need to add gtk_scrolled_window_set_kinetic_scrolling somewhere. It's been several years since this bug was last discussed so perhaps the environment has changed now that GTK3 is default and many distros are including wayland or using it by default, and I think it would be a great usability improvement. To see how it works, you can install Gnome Web (Epiphany) and see how it does have working kinetic scrolling. I don't know exactly where to insert that line, but I think it should be a simple insertion (somewhere) and kinetic scrolling should work. I'm on Ubuntu 18.04.
I think that enabling kinetic scrolling would probably involve adding "gtk_scrolled_window_set_kinetic_scrolling" to widget/gtk/mozgtk/mozgtk.c and then calling "gtk_scrolled_window_set_kinetic_scrolling" with kinetic_scrolling TRUE in widget/gtk/nsWindow.cpp. Unfortunately I don't know how to code C++ but I did find a cool example program at https://github.com/linuxmint/gtk/blob/master/tests/testkineticscrolling.c that you can compile like this: gcc testkineticscrolling.c -o testkineticscrolling `pkg-config --cflags --libs gtk+-3.0` And that includes that function to enable kinetic scrolling, so you can see how the function is used in practice.
Firefox doesn't use GtkScrolledWindow for the main content. From a quick grep in the source, I can see it's only used for crashreporter_linux. The actual browser only uses a GtkScrollbar. The main content is all custom gecko stuff. I think I found something — Firefox describes scroll events as WidgetWheelEvent, which has a property 'mIsMomentum' that's set by the Mac code, but not GTK..
You're completely right about crashreporter_linux actually - I was testing webrender and crashed firefox, and kinetic scrolling worked on the window shown after pressing "details" on the crash reporter, how interesting... Since there's no GtkScrolledWindow in the main firefox window, I think that as you said, mIsMomentum is the way to go. Now that many distributions are shipping wayland (and thus libinput - including Ubuntu, even on Xorg) and since the other two big platforms (macOS and Windows) already support kinetic scrolling, I think it would be a big usability improvement to add kinetic scrolling to Linux. It is now the only platform without it. Gnome Web (Epiphany) supports kinetic scrolling and it works very well, it would be great to have it on Firefox too.
I looked at this a bit more, just setting some random fields like that doesn't work. Looks like this place needs to emit proper APZ events (PanGestureInput). > Gnome Web (Epiphany) Yeah, here's WebKitGTK's patch for this: https://bugs.webkit.org/show_bug.cgi?id=155750
Summary: Kinetic scrolling does not work → Kinetic scrolling does not work on Linux
Flags: needinfo?(botond) → needinfo?(greg)
Pushed by email@example.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/f9699ae30f4d Implement kinetic/inertial scrolling (fling) for Gtk touchpads. r=botond,karlt
Assignee: nobody → greg
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Pushed by firstname.lastname@example.org: https://hg.mozilla.org/integration/mozilla-inbound/rev/d9f7c87aa3b4 implement kinetic/inertial scrolling (fling) for Gtk. r=botond
You need to log in before you can comment on or make changes to this bug.