x11: make sure SDL_GetGlobalMouseState notices mouse warping through SDL APIs.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 05 Sep 2017 16:15:54 -0400
changeset 114559e33d1be5d65
parent 11454 f6b9e7bd038a
child 11456 14800ea6ff4c
x11: make sure SDL_GetGlobalMouseState notices mouse warping through SDL APIs.
src/video/x11/SDL_x11mouse.c
     1.1 --- a/src/video/x11/SDL_x11mouse.c	Tue Sep 05 08:24:38 2017 -0700
     1.2 +++ b/src/video/x11/SDL_x11mouse.c	Tue Sep 05 16:15:54 2017 -0400
     1.3 @@ -309,22 +309,26 @@
     1.4  }
     1.5  
     1.6  static void
     1.7 +WarpMouseInternal(Window xwindow, const int x, const int y)
     1.8 +{
     1.9 +    SDL_VideoData *videodata = (SDL_VideoData *) SDL_GetVideoDevice()->driverdata;
    1.10 +    Display *display = videodata->display;
    1.11 +    X11_XWarpPointer(display, None, xwindow, 0, 0, 0, 0, x, y);
    1.12 +    X11_XSync(display, False);
    1.13 +    videodata->global_mouse_changed = SDL_TRUE;
    1.14 +}
    1.15 +
    1.16 +static void
    1.17  X11_WarpMouse(SDL_Window * window, int x, int y)
    1.18  {
    1.19      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    1.20 -    Display *display = data->videodata->display;
    1.21 -
    1.22 -    X11_XWarpPointer(display, None, data->xwindow, 0, 0, 0, 0, x, y);
    1.23 -    X11_XSync(display, False);
    1.24 +    WarpMouseInternal(data->xwindow, x, y);
    1.25  }
    1.26  
    1.27  static int
    1.28  X11_WarpMouseGlobal(int x, int y)
    1.29  {
    1.30 -    Display *display = GetDisplay();
    1.31 -
    1.32 -    X11_XWarpPointer(display, None, DefaultRootWindow(display), 0, 0, 0, 0, x, y);
    1.33 -    X11_XSync(display, False);
    1.34 +    WarpMouseInternal(DefaultRootWindow(GetDisplay()), x, y);
    1.35      return 0;
    1.36  }
    1.37