shithub: choc

Download patch

ref: 6d154ab06c663bbe9e9f5e7aea380f3b41aa80e4
parent: 5ad017e1713e0fccf33706757b57c17ccd700882
author: tpoppins <tpoppins@juno.com>
date: Thu Oct 21 11:17:42 EDT 2021

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.

--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1349,6 +1349,18 @@
                                 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);