winit-wayland: add hold gesture support#4585
Open
jondkinney wants to merge 1 commit into
Open
Conversation
Bind the hold gesture from zwp_pointer_gestures_v1 (added in v3 of the
manager) alongside the existing pinch gesture, emitting the new
WindowEvent::HoldGesture on begin (Started) and end (Ended/Cancelled).
A hold gesture fires when fingers are placed on a touchpad without
significant movement; per the protocol its canonical use is to stop
kinetic ("momentum") scrolling.
The manager is now bound up to v3 so the hold gesture is available where
the compositor supports it; older compositors bind a lower version and
keep the pinch gesture, and the hold object is only created when the
bound manager is v3 or newer.
Contributor
|
Same intention than in #4549 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the Wayland hold gesture (
zwp_pointer_gesture_hold_v1) as a newWindowEvent::HoldGesture { device_id, phase }.A hold gesture fires when one or more fingers are placed on a touchpad without
significant movement. Per the protocol, its canonical use is to stop kinetic
("momentum") scrolling — there's currently no way for a winit app to observe a
stationary finger-rest on Wayland, since a rest produces no
wl_pointer.axisevent.
This builds directly on the existing pinch-gesture support: it reuses the
already-bound
zwp_pointer_gestures_v1manager and thePointerGestureDatawindow tracking, adding only the hold object and its dispatch.
Details
1..=1to1..=3so the hold gesture (added inmanager v3) is available where the compositor supports it. Older compositors
bind a lower version and keep pinch unchanged.
(
manager.version() >= 3), so v1/v2 compositors are unaffected.Begin→TouchPhase::Started;End→Ended, orCancelledwhen thecompositor reports the gesture cancelled (e.g. fingers moved into a real
scroll) — mirroring the pinch handling, including the subsurface filter.
WindowEvent::HoldGesture { device_id: Option<DeviceId>, phase: TouchPhase }in
winit-core(nodelta; hold carries none).Platform support
Testing
cargo build -p winit-wayland, fullcargo build -p winit(x11 + wayland),and
cargo clippy -p winit-waylandall clean.zwp_pointer_gestures_v1v3) with asmall example logging window events: resting two fingers fires
HoldGesture { phase: Started }thenEndedon lift, orCancelledwhen therest turns into a scroll. The existing Pan/Pinch/Rotation gestures continue to
fire alongside, unaffected.