From c6824a67486e1ab8af0278d3929d6be113104663 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 10 Mar 2025 14:59:35 +0100 Subject: [PATCH] make this slightly less ugly --- src/sdl/i_video.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 9a4ed80dd..adf0441e8 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -903,7 +903,9 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) { if (USE_MOUSEINPUT) { - if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window)) + const boolean windowinfocus = (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window); + + if (!windowinfocus) { SDLdoUngrabMouse(); return; @@ -913,7 +915,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) // add on the offsets so we can make an overall event later. if (SDL_GetRelativeMouseMode()) { - if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window) + if (windowinfocus) { mousemovex += evt.xrel; mousemovey += -evt.yrel; @@ -933,20 +935,21 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) // just grab and set relative mode // this fixes the stupid camera jerk on mouse entering bug // -- Monster Iestyn - if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window) + if (windowinfocus) { SDLdoGrabMouse(); } } else if (cv_alwaysgrabmouse.value) { - if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window)) + const boolean windowinfocus = (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window); + + if (!windowinfocus) { SDLdoUngrabMouse(); return; } - - if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window) + else if (windowinfocus) { SDLdoGrabMouse(); }