Closed Bug 1539730 (s2n-linux) Opened 3 years ago Closed 2 months ago

Two finger touchpad horizontal swipe gesture for forward and back should work in GTK (Linux)

Categories

(Core :: Widget: Gtk, enhancement, P5)

Unspecified
Linux
enhancement

Tracking

()

RESOLVED FIXED
103 Branch
Tracking Status
firefox68 --- wontfix
firefox103 --- fixed

People

(Reporter: yoasif, Assigned: jwatt)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

STR:

Use two fingers on touchpad and swipe horizontally to the left or right.

What happens:

Nothing.

Expected result:

Page should move back or forward.

This is now enabled in Webkit https://trac.webkit.org/changeset/241224/webkit and GNOME Web: https://blogs.gnome.org/mcatanzaro/2019/03/27/epiphany-3-32-and-webkitgtk-2-24/

Has STR: --- → yes
Type: defect → enhancement
Priority: -- → P5
See Also: → 1564022
Duplicate of this bug: 1652954

Any roadmap for this?

Can we please get an update on this? Now that pinch zoom if is finally landed on Linux, this would be amazing to complete the trackpad support on Linux.

Flags: needinfo?(stransky)

Botond, any idea?
Thanks.

Flags: needinfo?(stransky) → needinfo?(botond)

Swipe-to-navigate is one of the APZ features under consideration for the Firefox Proton release.

Based on the most recent discussions, overscroll is likely to have higher priority, and we may not have time to do both for Proton, but even in that case swipe-to-navigate will be a high-priority follow-up to Proton.

Support for this feature does require some platform-specific work. As with desktop zooming, we will likely implement for Windows first, and then Linux (Mac already supports it). You can follow the Windows progress in bug 1564022.

Flags: needinfo?(botond)
Duplicate of this bug: 1529605
See Also: 1564022s2n-win
Summary: Two finger touchpad horizontal gesture for forward and back should work in GTK → Two finger touchpad horizontal swipe gesture for forward and back should work in GTK (Linux)

It looks like the frontend code will do the right thing (go back/forward) if the widget code sends the correct eSwipeGesture* events:
https://searchfox.org/mozilla-central/search?q=eSwipeGesture&path=widget%2FEventMessageList.h

Currently only the cocoa code does that:
https://searchfox.org/mozilla-central/search?q=SwipeGesture&path=widget

In GTK land we handle GDK_TOUCHPAD_PINCH:
https://searchfox.org/mozilla-central/search?q=GDK_TOUCHPAD_PINCH

But there's no code to handle GDK_TOUCHPAD_SWIPE.

https://docs.gtk.org/gdk3/struct.EventTouchpadSwipe.html
https://docs.gtk.org/gdk3/enum.TouchpadGesturePhase.html

Assignee: nobody → jwatt
Alias: s2n-linux
Flags: needinfo?(jwatt)

(In reply to Jonathan Watt [:jwatt] from comment #7)

It looks like the frontend code will do the right thing (go back/forward) if the widget code sends the correct eSwipeGesture* events:
https://searchfox.org/mozilla-central/search?q=eSwipeGesture&path=widget%2FEventMessageList.h

Currently only the cocoa code does that:
https://searchfox.org/mozilla-central/search?q=SwipeGesture&path=widget

In GTK land we handle GDK_TOUCHPAD_PINCH:
https://searchfox.org/mozilla-central/search?q=GDK_TOUCHPAD_PINCH

But there's no code to handle GDK_TOUCHPAD_SWIPE.

https://docs.gtk.org/gdk3/struct.EventTouchpadSwipe.html
https://docs.gtk.org/gdk3/enum.TouchpadGesturePhase.html

Unfortunately, it's not that easy. 2 finger swipes are usually recognized as "scrolls" so the wayland compositor, most likely, won't send the corresponding swipe gesture event.

(In reply to Vlad Zahorodnii [:zzag] from comment #9)

Unfortunately, it's not that easy. 2 finger swipes are usually recognized as "scrolls" so the wayland compositor, most likely, won't send the corresponding swipe gesture event.

Have you ever used an epiphany browser?
Horizontal scrolling takes precedence, and gesture animation occurs when the end is reached.

Ideally we'd use GDK_TOUCHPAD_SWIPE/GdkEventTouchpadSwipe (GTK's native events)
for this for the best compatibility with the the platform/other apps.
Unfortunately that seems complicated, so for now we use our SwipeTracker code
and make our own determination of what counts as a swipe.

Note that the pref widget.swipe.whole-page-pixel-size can be used to tweak
the swipe sensitivity.

Just so that i understand whats blocking GDK impl, does it require targeting a newer version or is it simply that it will take a lot more work to wire up the events to the back action in a way that allows detecting gestures early and triggering 1:! animations?

I'm hoping the current patch is sufficient (for Wayland - it doesn't work for X.org).

I pushed the patch to CI, and the resulting build can be found at:

https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/Z-Dm_VCKSbGKqeAZkhUkTQ/runs/0/artifacts/public/build/target.tar.bz2

I'd appreciate any testing that anyone can do. I tested on GNOME on a laptop using both the built-in trackpad and an external Apple trackpad.

Specifically, I'd be interested to know:

a) does it work for you?
b) what are the max/min values for the pref widget.swipe.whole-page-pixel-size that work for you, and is the default (80) acceptable?

(In reply to Rohan from comment #12)

Just so that i understand whats blocking GDK impl

Various things. I'll write a longer comment after I get the current patch landed since I want to focus on getting that landed for Firefox 103, and soft freeze is in a couple of days. Offhand, some of the issues for the GDK swipe event approach are that I wasn't getting events is some circumstances, GNOME with certain configurations appears to have both the app and desktop respond to swipes simultaneously, and libinput itself doesn't dispatch swipes for two finger swipes.

(In reply to Jonathan Watt [:jwatt] from comment #14)

libinput itself doesn't dispatch swipes for two finger swipes.

AFAIK what we want here is indeed tracking two finger scrolling - that's what other GTK apps use. Swipe gestures, i.e. three or more fingers on touchpads, may be used for e.g. the Gnome Shell. So the approach here looks like the optimal one to me, IIUC.

Thank you for implementing this!

Just tested this on a Thinkpad t480 with the built-in touchpad under Gnome 42/Wayland. Works flawlessly with the default settings!

In regards to the values for widget.swipe.whole-page-pixel-size, I was able to go as low as 30 without triggering the gestures accidentally. I think 80 is okay, I would suggest anything higher as it makes usage a bit cumbersome.

I guess we can expect this to be present in the next nightly, right?

Also, for me on a laptop with a pretty big trackpad (Asus Zephyrus M16), the default value of widget.swipe.whole-page-pixel-size is way too big, and I found a value of 20 as the sweet spot for me. But my input might also be different as I use libinput-config with scroll-factor set to .25 (not sure if this affects this gesture too)

Pushed by jwatt@jwatt.org:
https://hg.mozilla.org/integration/autoland/rev/7e39a8bcbbb2
Implement swipe-to-nav back/forward in history on Linux. r=tnikkel
Status: NEW → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 103 Branch

Thanks for the feedback, everyone. I expect this will be in Nightly later today and in Beta 103.

I reduced the sensitivity to 40 after your feedback and based on my own feeling for what works. There's every chance we may end up tweaking the default, but we'll see how it goes.

This is exciting, thanks Jonathan!

(In reply to Jonathan Watt [:jwatt] from comment #21)

I expect this will be in Nightly later today and in Beta 103.

Do we want it to be in beta 103? I wonder if a cycle of nightly-only baking time would make sense to gather additional feedback.

For clarity, it's only enabled for early beta (same as Windows).

The patch also works on X11, you just have to set the MOZ_USE_XINPUT2=1 environment variable (and run an up to date X server)

QA Whiteboard: [qa-103b-p2]

(In reply to benpicco from comment #24)

The patch also works on X11, you just have to set the MOZ_USE_XINPUT2=1 environment variable (and run an up to date X server)

Could you please suggest how to test the feature. I have a recent Manjaro on Lenovo Ideapad with a recent enough X11/KDE, Firefox 103.
Two-fingers scroll works in Firefox as well as zoom pinch. I have exported MOZ_USE_XINPUT2=1 variable, as you suggested. However history forth/back is still missing.

Thank you in advance.

(In reply to AlexM from comment #25)
On release you need to set widget.disable-swipe-tracker=false on about:config.

(In reply to Emilio Cobos Álvarez (:emilio) from comment #26)

(In reply to AlexM from comment #25)
On release you need to set widget.disable-swipe-tracker=false on about:config.

Thank you a lot! Now it works like a charm.

Blocks: 1784251
You need to log in before you can comment on or make changes to this bug.