We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4917 - [PATCH] Wayland: handle discrete pointer axis events
Summary: [PATCH] Wayland: handle discrete pointer axis events
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.1
Hardware: x86_64 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-26 00:11 UTC by Luis Caceres
Modified: 2020-02-03 08:57 UTC (History)
0 users

See Also:


Attachments
Proposed patch (6.63 KB, text/plain)
2019-12-26 00:11 UTC, Luis Caceres
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Luis Caceres 2019-12-26 00:11:47 UTC
Created attachment 4138 [details]
Proposed patch

The current handling of Wayland mouse pointer events only handles wl_pointer.axis events, which, according to the Wayland documentation, deal with mouse wheel scroll events on a continuous scale. While this is reasonable for some input sources (e.g. touchpad two-finger scrolling), it is not for mouse wheel clicks which generate wl_pointer.axis events with large deltas.

This patch adds handling for wl_pointer.axis_discrete and wl_pointer.frame events and prefers to report SDL_MouseWheelEvent in discrete units if they are available. This means that for mouse wheel scrolling we count in clicks, but for touchpad two-finger scrolling we still use whatever units Wayland uses. This behaviour is closer to that of the X11 backend.

Since these events are only available since version 5 of the wl_seat interface, this patch also checks for this and falls back to the previous behaviour if its not available. I also had to add definitions for some of the pointer and keyboard events specified in versions 2-5 but these are just stubs and do nothing.
Comment 1 Luis Caceres 2020-01-31 02:22:19 UTC
Is there anything I should correct in the patch? 

Or maybe this is the wrong channel for contributions? (the website is not very clear on this)
Comment 2 Sam Lantinga 2020-02-03 08:57:32 UTC
Looks good, thanks!
https://hg.libsdl.org/SDL/rev/b76ac1a7f87c