Skip to content
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

Touchpad gestures #1114

Merged
merged 5 commits into from
Sep 4, 2023
Merged

Touchpad gestures #1114

merged 5 commits into from
Sep 4, 2023

Conversation

YaLTeR
Copy link
Contributor

@YaLTeR YaLTeR commented Sep 2, 2023

Implements zwp_pointer_gestures_v1 and the entire Smithay support for it.

The Wayland gesture objects store whether they are currently active (i.e. between begin() and end()) on a given WlSurface. When receiving gesture update or end event, this field is checked, and if it doesn't match, then the gesture is cancelled. This way, gesture objects bound mid-gesture, or something equally weird happening, won't receive update() with no begin().

You could do something smarter, e.g. mutter will synthesize a gesture begin event if you move the pointer onto a surface mid-gesture, but doing this sounds quite more complex (need to track ongoing gestures on the pointer), and I don't think this usecase is very realistic (for this to happen you have to do something along move the pointer with a mouse while also making a gesture on the touchpad).

Anyway, here's a demo on my compositor, but it works in Anvil too, even on Xwayland windows.

gestures.mp4

Here you can see the pinch zoom/rotate gesture visually in gtk4-demo, then the swipe gesture only in WAYLAND_DEBUG on the right, then the hold gesture by stopping the kinetic scrolling by putting a finger on the touchpad.

By default an Anvil build won't have the hold gestures, to enable them build with the smithay/libinput_1_19 feature.

anvil/src/input_handler.rs Outdated Show resolved Hide resolved
Copy link
Member

@Drakulix Drakulix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing the work!

Lots and lots of plumbing code, but nothing problematic. I didn't even realize libinput just gave us gesture events (too long since I wrote the bindings...), so thanks for wiring that up!

I'll wait for a resolution on the name-conflict and possibly merge the clippy PR first so we get working CI, but otherwise this looks good for merge to me.

anvil/src/input_handler.rs Outdated Show resolved Hide resolved
@YaLTeR YaLTeR force-pushed the pointer-gestures branch 2 times, most recently from 4ba0b1a to 94d77fa Compare September 4, 2023 09:50
@YaLTeR
Copy link
Contributor Author

YaLTeR commented Sep 4, 2023

Oh right, Smallvil.

@Drakulix
Copy link
Member

Drakulix commented Sep 4, 2023

Oh right, Smallvil.

I think it is fine to leave pointer gestures out of smallvil (cc @PolyMeilex).
So just stubs with comments should be enough to fix that.

@YaLTeR
Copy link
Contributor Author

YaLTeR commented Sep 4, 2023

The winit backend does not generate gesture events, so yeah, it wouldn't work there anyway.

@YaLTeR
Copy link
Contributor Author

YaLTeR commented Sep 4, 2023

Can't even default-impl those because of no lifetime bound on D

@YaLTeR
Copy link
Contributor Author

YaLTeR commented Sep 4, 2023

Oh, and I forgot to write docs

The Wayland gesture objects store whether they are currently active
(i.e. between begin() and end()) on a given WlSurface. When receiving
gesture update or end event, this field is checked, and if it doesn't
match, then the gesture is cancelled.
@YaLTeR
Copy link
Contributor Author

YaLTeR commented Sep 4, 2023

finally

@Drakulix Drakulix merged commit 95093ca into Smithay:master Sep 4, 2023
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants