From a8acdb9d374976d5c416df628647a884513b43cc Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 18 Aug 2024 14:56:58 +0200 Subject: [PATCH] Stop grabbing mouse when game window doesn't have the focus --- src/common/platform/win32/i_mouse.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/common/platform/win32/i_mouse.cpp b/src/common/platform/win32/i_mouse.cpp index 72dc3f335..e0050cc3a 100644 --- a/src/common/platform/win32/i_mouse.cpp +++ b/src/common/platform/win32/i_mouse.cpp @@ -267,7 +267,7 @@ void I_CheckNativeMouse(bool preferNative, bool eventhandlerresult) } else { - if ((GetForegroundWindow() != mainwindow.GetHandle()) || preferNative || !use_mouse) + if (preferNative || !use_mouse) { want_native = true; } @@ -286,6 +286,10 @@ void I_CheckNativeMouse(bool preferNative, bool eventhandlerresult) if (!want_native && eventhandlerresult) want_native = true; + // The application should *never* grab the mouse cursor if its window doesn't have the focus. + if (GetForegroundWindow() != mainwindow.GetHandle()) + want_native = true; + //Printf ("%d %d %d\n", wantNative, preferNative, NativeMouse); if (want_native != NativeMouse)