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 2974

Summary: X11 touch device not found first time after boot
Product: SDL Reporter: Volumetric <demlow>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: brett.ernst.77, demlow, icculus
Version: 2.0.3   
Hardware: x86_64   
OS: Linux   
Attachments: Patch for querying all X11 input devices, so some touch devices aren't skipped

Description Volumetric 2015-05-01 21:13:20 UTC
Created attachment 2147 [details]
Patch for querying all X11 input devices, so some touch devices aren't skipped

On my systems the X11 code that looks for touch input devices misses the touch screen the first time after boot.  Subsequent times work.  This is under Fedora 20 and it manifests on very different hardware (workstation + touch screen, and also a tablet).

Below and attached please find a patch that fixes this by looking at all X input devices, not just the master devices.  It does redundantly checks some devices but correctly handles those duplicates, and fixes the problem.

diff -r -C 3 SDL-2.0.4-9574/src/video/x11/SDL_x11xinput2.c SDL-2.0.4-9574.mod/src/video/x11/SDL_x11xinput2.c
*** SDL-2.0.4-9574/src/video/x11/SDL_x11xinput2.c	2014-03-02 22:14:59.000000000 -0600
--- SDL-2.0.4-9574.mod/src/video/x11/SDL_x11xinput2.c	2015-05-01 15:55:27.181289471 -0500
***************
*** 183,189 ****
      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
      XIDeviceInfo *info;
      int ndevices,i,j;
!     info = X11_XIQueryDevice(data->display, XIAllMasterDevices, &ndevices);
  
      for (i = 0; i < ndevices; i++) {
          XIDeviceInfo *dev = &info[i];
--- 183,189 ----
      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
      XIDeviceInfo *info;
      int ndevices,i,j;
!     info = X11_XIQueryDevice(data->display, XIAllDevices, &ndevices);
  
      for (i = 0; i < ndevices; i++) {
          XIDeviceInfo *dev = &info[i];
Comment 1 Ryan C. Gordon 2015-06-01 03:00:45 UTC
This patch is now https://hg.libsdl.org/SDL/rev/a7e9b75ec1c9, thanks!

--ryan.
Comment 2 Sam Lantinga 2017-08-15 05:08:28 UTC
*** Bug 2196 has been marked as a duplicate of this bug. ***