Skip to content

Commit

Permalink
x11: make sure SDL_GetGlobalMouseState notices mouse warping through …
Browse files Browse the repository at this point in the history
…SDL APIs.
  • Loading branch information
icculus committed Sep 5, 2017
1 parent 0782f9b commit c9e73c3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/video/x11/SDL_x11mouse.c
Expand Up @@ -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;
}

Expand Down

0 comments on commit c9e73c3

Please sign in to comment.