Retain the high dpi flag when recreating the window (e.g when creating a renderer context)
authorSam Lantinga <slouken@libsdl.org>
Tue, 12 Nov 2013 02:18:52 -0800
changeset 7971 4151d8c29684
parent 7970 6dc794be47aa
child 7972 96f2f61be1c6
Retain the high dpi flag when recreating the window (e.g when creating a renderer context)
src/video/SDL_video.c
--- a/src/video/SDL_video.c	Tue Nov 12 02:04:12 2013 -0800
+++ b/src/video/SDL_video.c	Tue Nov 12 02:18:52 2013 -0800
@@ -1175,7 +1175,7 @@
 }
 
 #define CREATE_FLAGS \
-    (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE)
+    (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI)
 
 static void
 SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
@@ -1236,6 +1236,17 @@
             return NULL;
         }
     }
+
+    /* Unless the user has specified the high-DPI disabling hint, respect the
+     * SDL_WINDOW_ALLOW_HIGHDPI flag.
+     */
+    if (flags & SDL_WINDOW_ALLOW_HIGHDPI) {
+        hint = SDL_GetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED);
+        if (hint && SDL_atoi(hint) > 0) {
+            flags &= ~SDL_WINDOW_ALLOW_HIGHDPI;
+        }
+    }
+
     window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
     if (!window) {
         SDL_OutOfMemory();
@@ -1266,16 +1277,6 @@
     window->brightness = 1.0f;
     window->next = _this->windows;
 
-    /* Unless the user has specified the high-DPI disabling hint, respect the
-     * SDL_WINDOW_ALLOW_HIGHDPI flag.
-     */
-    hint = SDL_GetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED);
-    if (!hint || *hint != '1') {
-        if ((flags & SDL_WINDOW_ALLOW_HIGHDPI)) {
-            window->flags |= SDL_WINDOW_ALLOW_HIGHDPI;
-        }
-    }
-
     if (_this->windows) {
         _this->windows->prev = window;
     }