From f0ff2736203506b4a0c1502ddbf95ba1766d28ef 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 72dc3f335c..e0050cc3ab 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)