From 6e356e20ad236e6f3af5e6260beaf6f9158c8f56 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9my=20Tassoux?= <[EMAIL REDACTED]>
Date: Tue, 12 Oct 2021 18:35:52 +0200
Subject: [PATCH] Fix mouse focus being set to null when a captured mouse
cursor leaves the window.
---
src/video/windows/SDL_windowsevents.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 00ef203c00..42127065dd 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -979,7 +979,9 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
being lost. This then causes a cascading failure where SDL_WINDOWEVENT_ENTER / SDL_WINDOWEVENT_LEAVE
can stop firing permanently, due to the focus being in the wrong state and TrackMouseEvent never
resubscribing. */
- SDL_SetMouseFocus(NULL);
+ const SDL_bool isCapture = ((data->window->flags & SDL_WINDOW_MOUSE_CAPTURE) != 0);
+ if (!isCapture)
+ SDL_SetMouseFocus(NULL);
returnCode = 0;
break;