Enable capturing raw Xinput2 touch events and use to flag global mouse state as dirty

- Touch events may be translated to mouse movement events without the normal Xinput2 raw motion events
  being sent. Not all touch events will necessarily move the mouse but this ensures we update the global
  mouse state just in case.

- Fix up some formatting

CR: saml
This commit is contained in:
Sam Lantinga 2022-07-27 10:31:24 -07:00
parent 42165fe8d1
commit dbf7940541
1 changed files with 30 additions and 15 deletions

View File

@ -120,7 +120,7 @@ X11_InitXinput2(_THIS)
int version = 0;
XIEventMask eventmask;
unsigned char mask[3] = { 0,0,0 };
unsigned char mask[4] = { 0, 0, 0, 0 };
int event, err;
/*
@ -149,7 +149,7 @@ X11_InitXinput2(_THIS)
xinput2_multitouch_supported = xinput2_version_atleast(version, 2, 2);
#endif
/* Enable Raw motion events for this display */
/* Enable raw motion events for this display */
eventmask.deviceid = XIAllMasterDevices;
eventmask.mask_len = sizeof(mask);
eventmask.mask = mask;
@ -158,6 +158,15 @@ X11_InitXinput2(_THIS)
XISetMask(mask, XI_RawButtonPress);
XISetMask(mask, XI_RawButtonRelease);
#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
/* Enable raw touch events if supported */
if (X11_Xinput2IsMultitouchSupported()) {
XISetMask(mask, XI_RawTouchBegin);
XISetMask(mask, XI_RawTouchUpdate);
XISetMask(mask, XI_RawTouchEnd);
}
#endif
if (X11_XISelectEvents(data->display, DefaultRootWindow(data->display), &eventmask,1) != Success) {
return;
}
@ -202,6 +211,11 @@ X11_HandleXinput2Event(SDL_VideoData *videodata,XGenericEventCookie *cookie)
case XI_RawButtonPress:
case XI_RawButtonRelease:
#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
case XI_RawTouchBegin:
case XI_RawTouchUpdate:
case XI_RawTouchEnd:
#endif
videodata->global_mouse_changed = SDL_TRUE;
break;
@ -252,6 +266,7 @@ X11_HandleXinput2Event(SDL_VideoData *videodata,XGenericEventCookie *cookie)
return 1;
}
break;
#endif
}
#endif