SDL: When updating grab state, only activate windows that are grabbed, fullscreen, and shown.

From 4e784fce431d588a949517fafece5903d1acae44 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 17 Mar 2022 16:57:33 -0700
Subject: [PATCH] When updating grab state, only activate windows that are
 grabbed, fullscreen, and shown.

Fixes https://github.com/libsdl-org/SDL/issues/5371
---
 src/video/windows/SDL_windowswindow.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index 9ec9089f359..36bda16c4cf 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -859,13 +859,10 @@ WIN_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
 {
     WIN_UpdateClipCursor(window);
 
-    if (window->flags & SDL_WINDOW_FULLSCREEN) {
-        UINT flags = SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOSIZE;
-
-        if (!(window->flags & SDL_WINDOW_SHOWN)) {
-            flags |= SWP_NOACTIVATE;
-        }
-        WIN_SetWindowPositionInternal(_this, window, flags);
+    if (grabbed &&
+        (window->flags & SDL_WINDOW_FULLSCREEN) &&
+        (window->flags & SDL_WINDOW_SHOWN)) {
+        WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOSIZE);
     }
 }