mirror of https://github.com/encounter/SDL.git
X11: allow using touchscreen, while pointer is grabbed (see bug #3978)
This commit is contained in:
parent
ddc6be3559
commit
531d83bf6a
|
@ -1623,6 +1623,8 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
|||
}
|
||||
}
|
||||
|
||||
X11_Xinput2GrabTouch(_this, window);
|
||||
|
||||
/* Raise the window if we grab the mouse */
|
||||
X11_XRaiseWindow(display, data->xwindow);
|
||||
|
||||
|
@ -1632,6 +1634,8 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
|||
}
|
||||
} else {
|
||||
X11_XUngrabPointer(display, CurrentTime);
|
||||
|
||||
X11_Xinput2UngrabTouch(_this, window);
|
||||
}
|
||||
X11_XSync(display, False);
|
||||
}
|
||||
|
|
|
@ -343,6 +343,50 @@ X11_Xinput2IsMultitouchSupported()
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
X11_Xinput2GrabTouch(_THIS, SDL_Window *window)
|
||||
{
|
||||
#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
|
||||
unsigned char mask[4] = { 0, 0, 0, 0 };
|
||||
XIGrabModifiers mods;
|
||||
XIEventMask eventmask;
|
||||
|
||||
mods.modifiers = XIAnyModifier;
|
||||
mods.status = 0;
|
||||
|
||||
eventmask.deviceid = XIAllDevices;
|
||||
eventmask.mask_len = sizeof(mask);
|
||||
eventmask.mask = mask;
|
||||
|
||||
XISetMask(eventmask.mask, XI_TouchBegin);
|
||||
XISetMask(eventmask.mask, XI_TouchUpdate);
|
||||
XISetMask(eventmask.mask, XI_TouchEnd);
|
||||
XISetMask(eventmask.mask, XI_Motion);
|
||||
|
||||
XIGrabTouchBegin(display, XIAllDevices, data->xwindow, True, &eventmask, 1, &mods);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
X11_Xinput2UngrabTouch(_THIS, SDL_Window *window)
|
||||
{
|
||||
#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
|
||||
XIGrabModifiers mods;
|
||||
|
||||
mods.modifiers = XIAnyModifier;
|
||||
mods.status = 0;
|
||||
|
||||
XIUngrabTouchBegin(display, XIAllDevices, data->xwindow, 1, &mods);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_X11 */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -36,6 +36,8 @@ extern int X11_HandleXinput2Event(SDL_VideoData *videodata,XGenericEventCookie *
|
|||
extern int X11_Xinput2IsInitialized(void);
|
||||
extern int X11_Xinput2IsMultitouchSupported(void);
|
||||
extern void X11_Xinput2SelectTouch(_THIS, SDL_Window *window);
|
||||
extern void X11_Xinput2GrabTouch(_THIS, SDL_Window *window);
|
||||
extern void X11_Xinput2UngrabTouch(_THIS, SDL_Window *window);
|
||||
|
||||
#endif /* SDL_x11xinput2_h_ */
|
||||
|
||||
|
|
Loading…
Reference in New Issue