From c9e73c3e0095f97b2e0d080700a68c15d6abc2b9 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 5 Sep 2017 16:15:54 -0400 Subject: [PATCH] x11: make sure SDL_GetGlobalMouseState notices mouse warping through SDL APIs. --- src/video/x11/SDL_x11mouse.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 78bf4787c..60b052b31 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -308,23 +308,27 @@ X11_ShowCursor(SDL_Cursor * cursor) return 0; } +static void +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); + X11_XSync(display, False); + videodata->global_mouse_changed = SDL_TRUE; +} + static void X11_WarpMouse(SDL_Window * window, int x, int y) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - Display *display = data->videodata->display; - - X11_XWarpPointer(display, None, data->xwindow, 0, 0, 0, 0, x, y); - X11_XSync(display, False); + WarpMouseInternal(data->xwindow, x, y); } static int X11_WarpMouseGlobal(int x, int y) { - Display *display = GetDisplay(); - - X11_XWarpPointer(display, None, DefaultRootWindow(display), 0, 0, 0, 0, x, y); - X11_XSync(display, False); + WarpMouseInternal(DefaultRootWindow(GetDisplay()), x, y); return 0; }