foxygit / doom Log in
commit 6d154ab06c663bbe9e9f5e7aea380f3b41aa80e4
Author:     tpoppins <tpoppins@juno.com>
AuthorDate: Thu Oct 21 15:17:42 2021 -0400
Commit:     GitHub <noreply@github.com>
CommitDate: Thu Oct 21 15:17:42 2021 -0400

    Fixes Alt+Tab bug with SDL2 v2.0.14+ on Windows

    Fixes #1396.

    Adapted from kraflab's [coelckers/prboom-plus@74e8a55](https://github.com/coelckers/prboom-plus/commit/74e8a5542a1d1fc2ddfe370102fb0ece1a92d033), based on a fix in Woof taken from Doom Retro.
---
 src/i_video.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/i_video.c b/src/i_video.c
index 1b5fd4cc..babeef86 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1349,6 +1349,18 @@ static void SetVideoMode(void)
                                 SDL_TEXTUREACCESS_STREAMING,
                                 SCREENWIDTH, SCREENHEIGHT);

+    // Workaround for SDL 2.0.14+ alt-tab bug (taken from Doom Retro via Prboom-plus and Woof)
+#if defined(_WIN32)
+    {
+        SDL_version ver;
+        SDL_GetVersion(&ver);
+        if (ver.major == 2 && ver.minor == 0 && ver.patch >= 14)
+        {
+           SDL_SetHintWithPriority(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "1", SDL_HINT_OVERRIDE);
+        }
+    }
+#endif
+
     // Initially create the upscaled texture for rendering to screen

     CreateUpscaledTexture(true);