Skip to content

events: Add additional wheel scroll info and gestures for client-side kinetic scrolling - #15965

Open
Kontrabant wants to merge 3 commits into
libsdl-org:mainfrom
Kontrabant:scroll_finger
Open

events: Add additional wheel scroll info and gestures for client-side kinetic scrolling#15965
Kontrabant wants to merge 3 commits into
libsdl-org:mainfrom
Kontrabant:scroll_finger

Conversation

@Kontrabant

@Kontrabant Kontrabant commented Jul 10, 2026

Copy link
Copy Markdown
Contributor
  • I confirm that I am the author of this code and release it to the SDL project under the Zlib license. This contribution does not contain code from other sources, including code generated by a Large Language Model ("AI").

This adds the source of a scroll event, in particular if the source of the scroll was a finger, notes that a scroll event with an x/y of 0,0 indicates that the scroll ended due to the finger being lifted, and adds a 'hold' gesture to indicate that there are motionless fingers on a trackpad.

This allows for implementing client-side kinetic scrolling via a 'flick' gesture, and stopping it when a finger is again placed on the trackpad. A basic demonstration of this functionality was added to testmouse.

This information is currently passed through on X11 (although XInput2 lacks the hold gesture) and Wayland. There is probably a way to get this information on Apple platforms, but I haven't looked into it yet, and Macs already have native kinetic scrolling that can be enabled via a hint. No idea about Windows, as kinetic scrolling there seems to be implemented within third-party drivers.

As mentioned, to indicate finger lift, a mouse wheel event with x and y values of 0.0 is sent (libinput does the same to indicate that a kinetic scroll should be started). It's unlikely that sending zero scroll values would cause problems in existing software, as they already have to contend with either axis potentially being zero, but it is a slight behavior change, so maybe a separate SDL_EVENT_MOUSE_WHEEL_STOP (SDL_EVENT_MOUSE_WHEEL_FINGER_LIFTED?) event would be better suited for this?

Fixes #15955

@Kontrabant Kontrabant changed the title events: Pass through the scroll wheel source when known events: Add additional wheel scroll info and gestures for client-side kinetic scrolling Jul 14, 2026
@Kontrabant
Kontrabant marked this pull request as ready for review July 15, 2026 14:48
If the source of a scroll event is known to be from a finger, pass this information through in the scroll wheel event. Additionally, a scroll event for a finger with a delta of 0,0 may be passed through to indicate that the scroll ended due to the finger being lifted.

This allows for implementing client-side kinetic scrolling via a 'flick' gesture.
Use the new information in scroll events to implement kinetic scrolling when finger scroll events are received.
A hold gesture indicates that fingers are resting on a trackpad with no associated motion. This is useful for stopping a kinetic scroll.
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.

Trackpad handling

1 participant