Skip to content

winit-wayland: add hold gesture support#4585

Open
jondkinney wants to merge 1 commit into
rust-windowing:masterfrom
jondkinney:wayland-hold-gesture
Open

winit-wayland: add hold gesture support#4585
jondkinney wants to merge 1 commit into
rust-windowing:masterfrom
jondkinney:wayland-hold-gesture

Conversation

@jondkinney
Copy link
Copy Markdown

@jondkinney jondkinney commented Jun 3, 2026

Summary

Adds the Wayland hold gesture (zwp_pointer_gesture_hold_v1) as a new
WindowEvent::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.axis
event.

This builds directly on the existing pinch-gesture support: it reuses the
already-bound zwp_pointer_gestures_v1 manager and the PointerGestureData
window tracking, adding only the hold object and its dispatch.

Details

  • Manager bind raised from 1..=1 to 1..=3 so the hold gesture (added in
    manager v3) is available where the compositor supports it. Older compositors
    bind a lower version and keep pinch unchanged.
  • The hold object is created only when the bound manager is v3+
    (manager.version() >= 3), so v1/v2 compositors are unaffected.
  • BeginTouchPhase::Started; EndEnded, or Cancelled when the
    compositor reports the gesture cancelled (e.g. fingers moved into a real
    scroll) — mirroring the pinch handling, including the subsurface filter.
  • New WindowEvent::HoldGesture { device_id: Option<DeviceId>, phase: TouchPhase }
    in winit-core (no delta; hold carries none).

Platform support

  • Wayland: implemented.
  • Other platforms: unchanged (no equivalent stationary-hold gesture today).

Testing

  • cargo build -p winit-wayland, full cargo build -p winit (x11 + wayland),
    and cargo clippy -p winit-wayland all clean.
  • Runtime-verified on Hyprland (Wayland, zwp_pointer_gestures_v1 v3) with a
    small example logging window events: resting two fingers fires
    HoldGesture { phase: Started } then Ended on lift, or Cancelled when the
    rest turns into a scroll. The existing Pan/Pinch/Rotation gestures continue to
    fire alongside, unaffected.

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.
@Murmele
Copy link
Copy Markdown
Contributor

Murmele commented Jun 4, 2026

Same intention than in #4549

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants