From 921acaa2915db5ea28b2ecba520a15e42e218175 Mon Sep 17 00:00:00 2001 From: Jonathan Campbell Date: Tue, 6 May 2025 00:18:36 -0700 Subject: [PATCH] Bug fix: Keep the user mouse dimensions reported to the guest up to date with the window size, instead of only whenever the mouse moves --- src/gui/sdlmain.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index a92dc9c60..57c39e05d 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -2090,6 +2090,7 @@ void drawmenu(Bitu) { #endif void RENDER_Reset(void); +void UpdateUserCursorScreenDimensions(void); Bitu GFX_SetSize(Bitu width, Bitu height, Bitu flags, double scalex, double scaley, GFX_CallBack_t callback) { @@ -2242,7 +2243,7 @@ Bitu GFX_SetSize(Bitu width, Bitu height, Bitu flags, double scalex, double scal } #endif UpdateWindowDimensions(); - + UpdateUserCursorScreenDimensions(); #if defined(WIN32) && !defined(HX_DOS) && !defined(_WIN32_WINDOWS) WindowsTaskbarUpdatePreviewRegion(); #endif @@ -4465,6 +4466,16 @@ bool GFX_CursorInOrNearScreen(int wx,int wy) { return (wx >= minx && wx < maxx) && (wy >= miny && wy < maxy); } +void UpdateUserCursorScreenDimensions(void) { + user_cursor_sw = sdl.clip.w; + user_cursor_sh = sdl.clip.h; + + if (video_debug_overlay && vga.draw.width < render.src.width) { + user_cursor_sw = (vga.draw.width*user_cursor_sw)/render.src.width; + user_cursor_sh = (vga.draw.height*user_cursor_sh)/render.src.height; + } +} + static void HandleMouseMotion(SDL_MouseMotionEvent * motion) { bool inputToScreen = false; @@ -4547,13 +4558,8 @@ static void HandleMouseMotion(SDL_MouseMotionEvent * motion) { user_cursor_y = motion->y - sdl.clip.y; user_cursor_locked = sdl.mouse.locked; user_cursor_emulation = sdl.mouse.emulation; - user_cursor_sw = sdl.clip.w; - user_cursor_sh = sdl.clip.h; - if (video_debug_overlay && vga.draw.width < render.src.width) { - user_cursor_sw = (vga.draw.width*user_cursor_sw)/render.src.width; - user_cursor_sh = (vga.draw.height*user_cursor_sh)/render.src.height; - } + UpdateUserCursorScreenDimensions(); auto xrel = static_cast(motion->xrel) * sdl.mouse.xsensitivity / 100.0f; auto yrel = static_cast(motion->yrel) * sdl.mouse.ysensitivity / 100.0f;