Skip to content

events: Pass through the scroll wheel source when known#15965

Draft
Kontrabant wants to merge 2 commits into
libsdl-org:mainfrom
Kontrabant:scroll_finger
Draft

events: Pass through the scroll wheel source when known#15965
Kontrabant wants to merge 2 commits into
libsdl-org:mainfrom
Kontrabant:scroll_finger

Conversation

@Kontrabant

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").

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 with a finger source and 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. A basic demonstration of this functionality was added to testmouse.

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

As mentioned, to indicate finger lift, a mouse wheel event with x and y values of 0.0 are sent. It's unlikely that sending zero scroll values would cause problems in existing software, 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

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.
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