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 1173 - No mouse wheel event on linux/x11 (incl. suggested patch)
Summary: No mouse wheel event on linux/x11 (incl. suggested patch)
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.0
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-20 23:07 UTC by Matthias
Modified: 2011-04-05 09:41 UTC (History)
0 users

See Also:


Attachments
Patched SDL_x11events.c with mouse wheel support (20.93 KB, text/x-csrc)
2011-03-20 23:07 UTC, Matthias
Details
diff / patch file for SDL_x11events.c (2.08 KB, patch)
2011-03-20 23:07 UTC, Matthias
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias 2011-03-20 23:07:02 UTC
Created attachment 596 [details]
Patched SDL_x11events.c with mouse wheel support

On X11, SDL 1.3 does not generate a mouse wheel event. Instead, button down/buttton up events are generated by SDL. After looking at the code in SDL_x11events.c, I assume this is due to the fact that X11 does not have a dedicated mouse wheel event.

I did a little research on the behavior of mouse wheel events on X11 systems. Apparently, mouse wheel events generate a button down/button up event with the same time, i.e. with exact same timestamp. 

Attached you can find my changes to SDL_x11events.c, which generates SDL mouse wheel events for those button down events that have a button release event immediately following it (for the same button, and with the same timestamp).

I did have to make an assumption: As standard X11 implementations know only 5 buttons, I have mapped Button4 to "wheel up" (i.e. +1), and Button5 to "wheel down" (i.e. -1).

Note that if you include this patch, no SDL button down/up events will be generated on X11 platforms for mouse wheel events (which is probably a significant change for those that have programmed their code to work with them).
Comment 1 Matthias 2011-03-20 23:07:50 UTC
Created attachment 597 [details]
diff / patch file for SDL_x11events.c
Comment 2 Sam Lantinga 2011-04-04 12:56:09 UTC
Thank you very much for your patch for SDL 1.3!

Do you give me permission to release your code with SDL 1.3 and future
versions of SDL under both the LGPL and a closed-source commercial
license?
Comment 3 Matthias 2011-04-04 22:58:50 UTC
(In reply to comment #2)
> Thank you very much for your patch for SDL 1.3!
> 
> Do you give me permission to release your code with SDL 1.3 and future
> versions of SDL under both the LGPL and a closed-source commercial
> license?

You're welcome and: Yes, I do:-)
Comment 4 Sam Lantinga 2011-04-05 09:41:48 UTC
Thanks, your patch is in!
http://hg.libsdl.org/SDL/rev/4e46a7b6773d