From fc0d82d49066ba7fcdadd3139c8f192a30478b85 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 10 Jan 2021 15:43:49 +1100 Subject: [PATCH] [client] wm: added new platform agnostic wmWarpMouse --- client/src/main.c | 13 +------------ client/src/wm.c | 20 ++++++++++++++++++++ client/src/wm.h | 1 + 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/client/src/main.c b/client/src/main.c index a9431a79..284d07a6 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -846,18 +846,7 @@ static void warpMouse(int x, int y, bool disable) if (g_cursor.pos.x == x && g_cursor.pos.y == y) return; - if (g_state.wminfo.subsystem == SDL_SYSWM_X11) - { - XWarpPointer( - g_state.wminfo.info.x11.display, - None, - g_state.wminfo.info.x11.window, - 0, 0, 0, 0, - x, y); - XSync(g_state.wminfo.info.x11.display, False); - } - else - SDL_WarpMouseInWindow(g_state.window, x, y); + wmWarpMouse(x, y); } static bool isValidCursorLocation(int x, int y) diff --git a/client/src/wm.c b/client/src/wm.c index 0f665eff..e6e4dfc6 100644 --- a/client/src/wm.c +++ b/client/src/wm.c @@ -135,3 +135,23 @@ void wmUngrabAll() wmUngrabPointer(); wmUngrabKeyboard(); } + +void wmWarpMouse(int x, int y) +{ + switch(g_state.wminfo.subsystem) + { + case SDL_SYSWM_X11: + XWarpPointer( + g_state.wminfo.info.x11.display, + None, + g_state.wminfo.info.x11.window, + 0, 0, 0, 0, + x, y); + XSync(g_state.wminfo.info.x11.display, False); + break; + + default: + SDL_WarpMouseInWindow(g_state.window, x, y); + break; + } +} diff --git a/client/src/wm.h b/client/src/wm.h index 455d033d..04d3f500 100644 --- a/client/src/wm.h +++ b/client/src/wm.h @@ -23,3 +23,4 @@ void wmGrabKeyboard(); void wmUngrabKeyboard(); void wmGrabAll(); void wmUngrabAll(); +void wmWarpMouse(int x, int y);