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 4804

Summary: Getting both mouse events and finger events
Product: SDL Reporter: Moritz Bruder <muesli4>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sylvain.becker
Version: 2.0.10   
Hardware: ARM   
OS: Linux   
Attachments: Example that does not reproduce the error.

Description Moritz Bruder 2019-09-15 12:38:20 UTC
Created attachment 3970 [details]
Example that does not reproduce the error.

I'm using a Raspberry Pi with an ADS7846 touchscreen running an SDL application on top of an xserver:

[alarm@pi src]$ export DISPLAY=:0.0 
[alarm@pi src]$ xinput
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ ADS7846 Touchscreen                     	id=6	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]

However, since 2.0.10 (sdl2-2.0.10-1 archlinuxarm) I get duplicated events. That is, I receive both mouse events and finger events. I did some simple print output debugging in my program (this is after i touched it once):

event.type = 1024 SDL_MOUSEMOTION
event.type = 1025 SDL_MOUSEBUTTONDOWN
event.type = 1792 SDL_FINGERDOWN
event.type = 1024 SDL_MOUSEMOTION
event.type = 1794 SDL_FINGERMOTION
event.type = 1024 SDL_MOUSEMOTION
event.type = 1794 SDL_FINGERMOTION
event.type = 1024 SDL_MOUSEMOTION
event.type = 1794 SDL_FINGERMOTION
event.type = 1026 SDL_MOUSEBUTTON_UP
event.type = 1793 SDL_FINGERUP
event.type = 32768 SDL_USEREVENT
event.type = 32768 SDL_USEREVENT

I tried this with a simple application but unfortunately I can't reproduce the behavior (there I only get touch events). Maybe you can give me some pointers on how to debug this further.

In my application where it occurs I use user events (but I only ever push them).
* This is where I setup SDL: https://github.com/muesli4/mpd-touch-screen-gui/blob/36ebdb473e2a145bcf425156f7de3b062e7a2acc/src/main.cpp#L55
* This is where I handle the specific events: https://github.com/muesli4/libwtk-sdl2/blob/09b736a9ae9ffe13fd3bc2f9a66258d9f8153685/src/widget_context.cpp#L44
Comment 1 Sylvain 2019-09-16 10:10:50 UTC
Hi,
how are set the hints 

SDL_HINT_TOUCH_MOUSE_EVENTS
SDL_HINT_MOUSE_TOUCH_EVENTS

https://hg.libsdl.org/SDL/file/2ede888544ac/include/SDL_hints.h#l313

please log also the 
id: TouchId and MouseId

https://hg.libsdl.org/SDL/file/2ede888544ac/include/SDL_events.h#l438
https://hg.libsdl.org/SDL/file/2ede888544ac/include/SDL_events.h#l258

also, try the latest SDL, and do you know which sdl code is used with xserver ?

see bug 1612 
because it triggers SendMouseMotion in EnterNotify and LeaveNotify
https://hg.libsdl.org/SDL/annotate/84bbd421d62f/src/video/x11/SDL_x11events.c#l315
which might be incorrect or inconsistent with other backends
Comment 2 Sylvain 2019-09-16 10:12:18 UTC
Besides, using atexit + SDL_Quit has proved to cause some trouble

https://github.com/muesli4/mpd-touch-screen-gui/blob/36ebdb473e2a145bcf425156f7de3b062e7a2acc/src/main.cpp#L62