SDL: Add SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN

From 0789610cfb906c15917abfa9cf51cfc3cd1c59c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9my=20Tassoux?= <[EMAIL REDACTED]>
Date: Thu, 14 Oct 2021 00:52:05 +0200
Subject: [PATCH] Add SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN

---
 include/SDL_hints.h                   | 11 +++++++++++
 src/video/windows/SDL_windowswindow.c |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/SDL_hints.h b/include/SDL_hints.h
index fdfb7eee86..40c38bda5d 100644
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
@@ -1617,6 +1617,17 @@ extern "C" {
  */
 #define SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN    "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN"
 
+/**
+*  \brief  A variable controlling whether the window is activated when the SDL_ShowWindow function is called 
+*
+*  This variable can be set to the following values:
+*    "0"       - The window is activated when the SDL_ShowWindow function is called
+*    "1"       - The window is not activated when the SDL_ShowWindow function is called
+*
+*  By default SDL will activate the window when the SDL_ShowWindow function is called
+*/
+#define SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN    "SDL_WINDOW_NO_ACTIVATION_WHEN_SHOWN"
+
 /** \brief Allows back-button-press events on Windows Phone to be marked as handled
  *
  *  Windows Phone devices typically feature a Back button.  When pressed,
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index 738d08cc94..8013d49515 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -555,7 +555,7 @@ WIN_ShowWindow(_THIS, SDL_Window * window)
     int nCmdShow;
 
     hwnd = ((SDL_WindowData *)window->driverdata)->hwnd;
-    nCmdShow = SW_SHOW;
+    nCmdShow = SDL_GetHintBoolean(SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN, SDL_FALSE) ? SW_SHOWNA : SW_SHOW;
     style = GetWindowLong(hwnd, GWL_EXSTYLE);
     if (style & WS_EX_NOACTIVATE) {
         nCmdShow = SW_SHOWNOACTIVATE;