SDL: Fixed grab handling when focus changes between windows in the same application

From bfd2f8993f173535efe436f8e60827cc44351bea Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 19 Oct 2021 17:29:23 -0700
Subject: [PATCH] Fixed grab handling when focus changes between windows in the
 same application

---
 src/video/windows/SDL_windowsevents.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 4c5b941c04..a1bdaf9430 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -663,6 +663,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
         }
         break;
 
+    case WM_SETFOCUS:
+    case WM_KILLFOCUS:
+        {
+            /* Update the focus in case it's changing between windows in the same application */
+            WIN_UpdateFocus(data->window);
+        }
+        break;
+
     case WM_POINTERUPDATE:
         {
             data->last_pointer_update = lParam;