Setting the window size changes the fullscreen display mode, unless a window display mode has been set.
authorSam Lantinga <slouken@libsdl.org>
Wed, 04 Jun 2014 10:57:52 -0700
changeset 8823 15a1b4b8e20a
parent 8822 b554a3e19d6c
child 8824 c2a79f186731
Setting the window size changes the fullscreen display mode, unless a window display mode has been set. Testing: * Ran testsprite2 --fullscreen, used Ctrl+ and Ctrl- to change window sizes, verified that the display mode changed as well.
src/render/direct3d/SDL_render_d3d.c
src/video/SDL_video.c
--- a/src/render/direct3d/SDL_render_d3d.c	Wed Jun 04 10:57:40 2014 -0700
+++ b/src/render/direct3d/SDL_render_d3d.c	Wed Jun 04 10:57:52 2014 -0700
@@ -462,15 +462,21 @@
     if (data->updateSize) {
         SDL_Window *window = renderer->window;
         int w, h;
+        Uint32 window_flags = SDL_GetWindowFlags(window);
 
         SDL_GetWindowSize(window, &w, &h);
         data->pparams.BackBufferWidth = w;
         data->pparams.BackBufferHeight = h;
-        if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) {
-            data->pparams.BackBufferFormat =
-                PixelFormatToD3DFMT(SDL_GetWindowPixelFormat(window));
+        if (window_flags & SDL_WINDOW_FULLSCREEN && (window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
+            SDL_DisplayMode fullscreen_mode;
+            SDL_GetWindowDisplayMode(window, &fullscreen_mode);
+            data->pparams.Windowed = FALSE;
+            data->pparams.BackBufferFormat = PixelFormatToD3DFMT(fullscreen_mode.format);
+            data->pparams.FullScreen_RefreshRateInHz = fullscreen_mode.refresh_rate;
         } else {
+            data->pparams.Windowed = TRUE;
             data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
+            data->pparams.FullScreen_RefreshRateInHz = 0;
         }
         if (D3D_Reset(renderer) < 0) {
             return -1;
@@ -565,25 +571,16 @@
     pparams.hDeviceWindow = windowinfo.info.win.window;
     pparams.BackBufferWidth = w;
     pparams.BackBufferHeight = h;
-    if (window_flags & SDL_WINDOW_FULLSCREEN) {
-        pparams.BackBufferFormat =
-            PixelFormatToD3DFMT(fullscreen_mode.format);
-    } else {
-        pparams.BackBufferFormat = D3DFMT_UNKNOWN;
-    }
     pparams.BackBufferCount = 1;
     pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
 
-    if (window_flags & SDL_WINDOW_FULLSCREEN) {
-        if ((window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP)  {
-            pparams.Windowed = TRUE;
-            pparams.FullScreen_RefreshRateInHz = 0;
-        } else {
-            pparams.Windowed = FALSE;
-            pparams.FullScreen_RefreshRateInHz = fullscreen_mode.refresh_rate;
-        }
+    if (window_flags & SDL_WINDOW_FULLSCREEN && (window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
+        pparams.Windowed = FALSE;
+        pparams.BackBufferFormat = PixelFormatToD3DFMT(fullscreen_mode.format);
+        pparams.FullScreen_RefreshRateInHz = fullscreen_mode.refresh_rate;
     } else {
         pparams.Windowed = TRUE;
+        pparams.BackBufferFormat = D3DFMT_UNKNOWN;
         pparams.FullScreen_RefreshRateInHz = 0;
     }
     if (flags & SDL_RENDERER_PRESENTVSYNC) {
--- a/src/video/SDL_video.c	Wed Jun 04 10:57:40 2014 -0700
+++ b/src/video/SDL_video.c	Wed Jun 04 10:57:52 2014 -0700
@@ -1044,10 +1044,10 @@
 
     fullscreen_mode = window->fullscreen_mode;
     if (!fullscreen_mode.w) {
-        fullscreen_mode.w = window->w;
+        fullscreen_mode.w = window->windowed.w;
     }
     if (!fullscreen_mode.h) {
-        fullscreen_mode.h = window->h;
+        fullscreen_mode.h = window->windowed.h;
     }
 
     display = SDL_GetDisplayForWindow(window);
@@ -1093,9 +1093,9 @@
 SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
 {
     SDL_VideoDisplay *display;
-	SDL_Window *other;
-
-	CHECK_WINDOW_MAGIC(window,);
+    SDL_Window *other;
+
+    CHECK_WINDOW_MAGIC(window,);
 
 #ifdef __MACOSX__
     if (Cocoa_SetWindowFullscreenSpace(window, fullscreen)) {
@@ -1688,15 +1688,13 @@
         h = window->max_h;
     }
 
+    window->windowed.w = w;
+    window->windowed.h = h;
+
     if (window->flags & SDL_WINDOW_FULLSCREEN) {
-        window->windowed.w = w;
-        window->windowed.h = h;
-
         if (FULLSCREEN_VISIBLE(window) && (window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
-            SDL_DisplayMode fullscreen_mode;
-            if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
-                SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
-            }
+            window->last_fullscreen_flags = 0;
+            SDL_UpdateFullscreenMode(window, SDL_TRUE);
         }
     } else {
         window->w = w;