From 3907ded0c7cd36059b00dd4dd4267e6ef35db08f Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 29 Oct 2017 15:11:37 +1100 Subject: [PATCH] [client] realign mouse on window changes --- client/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/client/main.c b/client/main.c index ae22a9da..9ea8ace0 100644 --- a/client/main.c +++ b/client/main.c @@ -40,6 +40,8 @@ struct KVMGFXState { bool running; bool started; + bool windowChanged; + SDL_Window * window; SDL_Renderer * renderer; struct KVMGFXHeader * shm; @@ -316,6 +318,7 @@ int renderThread(void * unused) SDL_LockTexture(texture, NULL, (void**)&texPixels, &unused); memcpy(&format, state.shm, sizeof(format)); + state.windowChanged = true; } glDisable(GL_COLOR_LOGIC_OP); @@ -406,6 +409,14 @@ int eventThread(void * arg) init = true; } + if (state.windowChanged) + { + mouseX = state.shm->mouseX; + mouseY = state.shm->mouseY; + SDL_WarpMouseInWindow(state.window, mouseX, mouseY); + state.windowChanged = false; + } + switch(event.type) { case SDL_KEYDOWN: