Use XIWarpPointer if compiled with xinput2

Co-authored-by: Andrei E <andreien@proton.me>
This commit is contained in:
Desour 2022-10-12 00:17:50 +02:00 committed by Sam Lantinga
parent fb32effd15
commit 6836273d14
2 changed files with 13 additions and 2 deletions

View File

@ -315,7 +315,16 @@ WarpMouseInternal(Window xwindow, const int x, const int y)
{
SDL_VideoData *videodata = (SDL_VideoData *) SDL_GetVideoDevice()->driverdata;
Display *display = videodata->display;
X11_XWarpPointer(display, None, xwindow, 0, 0, 0, 0, x, y);
#if SDL_VIDEO_DRIVER_X11_XINPUT2
int deviceid = 0;
X11_XIGetClientPointer(display, None, &deviceid);
if (deviceid != 0) {
X11_XIWarpPointer(display, deviceid, None, xwindow, 0.0, 0.0, 0, 0, (double)x, (double)y);
} else
#endif
{
X11_XWarpPointer(display, None, xwindow, 0, 0, 0, 0, x, y);
}
X11_XSync(display, False);
videodata->global_mouse_changed = SDL_TRUE;
}

View File

@ -166,7 +166,7 @@ SDL_X11_SYM(Status, XFixesQueryVersion,(Display* a, int* b, int* c), (a,b,c), re
#if SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS
SDL_X11_SYM(Bool,XGetEventData,(Display* a,XGenericEventCookie* b),(a,b),return)
SDL_X11_SYM(void,XFreeEventData,(Display* a,XGenericEventCookie* b),(a,b),)
SDL_X11_SYM(void,XFreeEventData,(Display* a,XGenericEventCookie* b),(a,b),)
#endif
#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
@ -270,6 +270,8 @@ SDL_X11_SYM(int,XIGrabTouchBegin,(Display *a,int b,Window c,int d,XIEventMask *e
SDL_X11_SYM(int,XIUngrabTouchBegin, (Display *a,int b,Window c, int d,XIGrabModifiers *e),(a, b, c, d, e),return)
SDL_X11_SYM(Status,XIQueryVersion,(Display *a,int *b,int *c),(a,b,c),return)
SDL_X11_SYM(XIEventMask*,XIGetSelectedEvents,(Display *a,Window b,int *c),(a,b,c),return)
SDL_X11_SYM(Bool,XIGetClientPointer,(Display *a,Window b,int *c),(a,b,c),return)
SDL_X11_SYM(Bool,XIWarpPointer,(Display *a,int b,Window c,Window d,double e,double f,int g,int h,double i,double j),(a,b,c,d,e,f,g,h,i,j),return)
#endif
/* XRandR support */