Skip to content

Report touchpad gestures and devices arriving and leaving - #130

Merged
jwinarske merged 2 commits into
mainfrom
feat/input-gestures-devices
Nov 17, 2026
Merged

jwinarske merged 2 commits into
mainfrom
feat/input-gestures-devices

Conversation

@jwinarske

Copy link
Copy Markdown
Owner

drmkit-input's Seat::dispatch dropped libinput's gesture events and kept device arrivals to itself. fl-engine's KMS platform needs both: a pinch for the framework's pan-zoom, and the arrivals to tell a touchpad from a mouse and to know when the last pointer has gone.

What is added

  • InputEvent::Gesture(GestureEvent): a swipe, a pinch or a hold (GestureKind), with its GesturePhase, finger count, the center's travel, and for a pinch the scale (a total) and the turn in degrees (a step), as libinput reports them
  • A gesture libinput cancels ends as GesturePhase::Cancel, apart from End
  • InputEvent::Device(DeviceEvent): DeviceChange::Added or Removed, the kernel's node name (event5), the device's name, vendor and product ids, and DeviceCapabilities
  • The devices on the seat when it opens are reported by the first dispatch; a suspend's removals by the first dispatch after the resume
  • Device events are in order with the device's own: after libinput's releases and touch cancels for a device that goes

InputEvent was already non_exhaustive, so this is an addition a patch release can carry. The reference carries neither; CHANGELOG and TEST_PARITY say so.

Seen

On a Raspberry Pi 5, the input example with a touchpad made through /dev/uinput:

  • the seat's eight devices added at the first dispatch, then the touchpad as it was plugged in (pointer and gesture)
  • a two-finger pinch out: begin, updates to a scale of 2.33, end
  • a three-finger swipe: begin, three updates, end
  • a two-finger hold that ended, and one that was canceled as the fingers moved
  • the touchpad removed

Not seen: a pinch or a swipe canceled (libinput took the script's last pinch for a touch jump), and no real touchpad was used.

Tests

a_canceled_gesture_does_not_read_as_ended. The conversions themselves need a libinput event, which only a device makes; CI has none, so they are covered by the run above.

Seat::dispatch dropped libinput's gesture events and kept device
arrivals to itself, as the reference does. A consumer drawing a pointer
or zooming a view needs both: a pinch is not recoverable from anything
else the seat reports, and without the arrivals there is no telling a
touchpad from a mouse or that the last mouse has gone.

InputEvent::Gesture carries a swipe, a pinch or a hold as a
GestureEvent: kind, phase, finger count, the center's travel, and for a
pinch the scale (a total, as libinput gives it) and the turn (a step).
libinput ends a gesture with one event and a canceled flag; here a
canceled one is GesturePhase::Cancel, since what it did is to be undone
where an ended one's stands.

InputEvent::Device carries an arrival or a departure as a DeviceEvent,
in order with the device's own events: the kernel's node name, which
identifies one device where its name does not, the name, the vendor and
product ids, and its DeviceCapabilities. The devices on the seat when it
opens are reported by the first dispatch, and a suspend's removals by
the first dispatch after the resume.

Both enums were already non_exhaustive, so nothing that compiled stops
compiling.

Seen on a Raspberry Pi 5 with a touchpad made through /dev/uinput: the
seat's eight devices and the touchpad added, a two-finger pinch out to
2.33, a three-finger swipe, a hold ended and a hold canceled, and the
touchpad removed.

Review: a finger count libinput reports as negative reads as zero, and a
removed device is described while its event is in hand. Device names
are the device's own text and are passed on as data. A device event
costs two short strings; a gesture event one, as a motion does.

Signed-off-by: Joel Winarske <joel.winarske@linux.com>
cargo-deny fails the lint lane on rustix 1.1.4: its xattr functions mark
unwritten bytes as initialized when given a zero-length buffer. Nothing
here calls them; the lockfile moves to 1.1.6, which carries the fix, so
the lane passes again.

Review: a lockfile change only; clippy and the drmkit-input tests pass
on it.

Signed-off-by: Joel Winarske <joel.winarske@linux.com>
@jwinarske
jwinarske merged commit b407d14 into main Nov 17, 2026
9 checks passed
@jwinarske
jwinarske deleted the feat/input-gestures-devices branch November 17, 2026 04:19
@jwinarske jwinarske mentioned this pull request Nov 17, 2026
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.

1 participant