From e8baaceccd8827d5cd09d05d6f3a0206b67e270d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Wed, 10 Apr 2024 15:13:17 -0300 Subject: [PATCH] fix mouse cursor randomly becoming invisible outside gzdoom --- src/common/platform/win32/i_input.cpp | 4 +++- src/common/platform/win32/i_mouse.cpp | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/common/platform/win32/i_input.cpp b/src/common/platform/win32/i_input.cpp index 054c9959030..35f0b6638e8 100644 --- a/src/common/platform/win32/i_input.cpp +++ b/src/common/platform/win32/i_input.cpp @@ -323,6 +323,8 @@ bool CallHook(FInputDevice *device, HWND hWnd, UINT message, WPARAM wParam, LPAR return device->WndProcHook(hWnd, message, wParam, lParam, result); } +extern void SetCursorState(bool visible); + LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT result; @@ -415,7 +417,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_SETCURSOR: if (!CursorState) { - SetCursor(NULL); // turn off window cursor + SetCursorState(false); return TRUE; // Prevent Windows from setting cursor to window class cursor } else diff --git a/src/common/platform/win32/i_mouse.cpp b/src/common/platform/win32/i_mouse.cpp index 37ee3570983..e7b4f27f68b 100644 --- a/src/common/platform/win32/i_mouse.cpp +++ b/src/common/platform/win32/i_mouse.cpp @@ -131,7 +131,7 @@ enum EMouseMode // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- -static void SetCursorState(bool visible); +void SetCursorState(bool visible); static FMouse *CreateWin32Mouse(); static FMouse *CreateDInputMouse(); static FMouse *CreateRawMouse(); @@ -191,7 +191,7 @@ CUSTOM_CVAR (Int, in_mouse, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) static bool mouse_shown = true; -static void SetCursorState(bool visible) +void SetCursorState(bool visible) { CursorState = visible || !m_hidepointer; if (GetForegroundWindow() == mainwindow.GetHandle())