SDL: Don't drop mouse focus on WM_MOUSELEAVE if the mouse is in relative mode; mouse-level is not meaningful for that case.

https://github.com/libsdl-org/SDL/commit/adf3ce7c01002456dc567cf9bdb20f9166b4fb2c

From adf3ce7c01002456dc567cf9bdb20f9166b4fb2c Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 5 Jul 2022 21:42:24 -0700
Subject: [PATCH] Don't drop mouse focus on WM_MOUSELEAVE if the mouse is in
 relative mode; mouse-level is not meaningful for that case.

Do drop mouse focus when keyboard focus is lost if the mouse is in relative mode.
---
 src/video/windows/SDL_windowsevents.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 8fbdccd0905..60e80a8cec9 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -451,6 +451,10 @@ WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus)
         data->in_window_deactivation = SDL_TRUE;
 
         SDL_SetKeyboardFocus(NULL);
+        /* In relative mode we are guaranteed to not have mouse focus if we don't have keyboard focus */
+        if (SDL_GetMouse()->relative_mode) {
+            SDL_SetMouseFocus(NULL);
+        }
         WIN_ResetDeadKeys();
 
         if (GetClipCursor(&rect) && SDL_memcmp(&rect, &data->cursor_clipped_rect, sizeof(rect)) == 0) {
@@ -943,8 +947,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                }
             }
 
-            /* When WM_MOUSELEAVE is fired we can be assured that the cursor has left the window */
-            SDL_SetMouseFocus(NULL);
+            if (!SDL_GetMouse()->relative_mode) {
+                /* When WM_MOUSELEAVE is fired we can be assured that the cursor has left the window */
+                SDL_SetMouseFocus(NULL);
+            }
         }
 
         /* Once we get WM_MOUSELEAVE we're guaranteed that the window is no longer tracked */