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 882315a1b4b8e20a
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
     1.1 --- a/src/render/direct3d/SDL_render_d3d.c	Wed Jun 04 10:57:40 2014 -0700
     1.2 +++ b/src/render/direct3d/SDL_render_d3d.c	Wed Jun 04 10:57:52 2014 -0700
     1.3 @@ -462,15 +462,21 @@
     1.4      if (data->updateSize) {
     1.5          SDL_Window *window = renderer->window;
     1.6          int w, h;
     1.7 +        Uint32 window_flags = SDL_GetWindowFlags(window);
     1.8  
     1.9          SDL_GetWindowSize(window, &w, &h);
    1.10          data->pparams.BackBufferWidth = w;
    1.11          data->pparams.BackBufferHeight = h;
    1.12 -        if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) {
    1.13 -            data->pparams.BackBufferFormat =
    1.14 -                PixelFormatToD3DFMT(SDL_GetWindowPixelFormat(window));
    1.15 +        if (window_flags & SDL_WINDOW_FULLSCREEN && (window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
    1.16 +            SDL_DisplayMode fullscreen_mode;
    1.17 +            SDL_GetWindowDisplayMode(window, &fullscreen_mode);
    1.18 +            data->pparams.Windowed = FALSE;
    1.19 +            data->pparams.BackBufferFormat = PixelFormatToD3DFMT(fullscreen_mode.format);
    1.20 +            data->pparams.FullScreen_RefreshRateInHz = fullscreen_mode.refresh_rate;
    1.21          } else {
    1.22 +            data->pparams.Windowed = TRUE;
    1.23              data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
    1.24 +            data->pparams.FullScreen_RefreshRateInHz = 0;
    1.25          }
    1.26          if (D3D_Reset(renderer) < 0) {
    1.27              return -1;
    1.28 @@ -565,25 +571,16 @@
    1.29      pparams.hDeviceWindow = windowinfo.info.win.window;
    1.30      pparams.BackBufferWidth = w;
    1.31      pparams.BackBufferHeight = h;
    1.32 -    if (window_flags & SDL_WINDOW_FULLSCREEN) {
    1.33 -        pparams.BackBufferFormat =
    1.34 -            PixelFormatToD3DFMT(fullscreen_mode.format);
    1.35 -    } else {
    1.36 -        pparams.BackBufferFormat = D3DFMT_UNKNOWN;
    1.37 -    }
    1.38      pparams.BackBufferCount = 1;
    1.39      pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
    1.40  
    1.41 -    if (window_flags & SDL_WINDOW_FULLSCREEN) {
    1.42 -        if ((window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP)  {
    1.43 -            pparams.Windowed = TRUE;
    1.44 -            pparams.FullScreen_RefreshRateInHz = 0;
    1.45 -        } else {
    1.46 -            pparams.Windowed = FALSE;
    1.47 -            pparams.FullScreen_RefreshRateInHz = fullscreen_mode.refresh_rate;
    1.48 -        }
    1.49 +    if (window_flags & SDL_WINDOW_FULLSCREEN && (window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
    1.50 +        pparams.Windowed = FALSE;
    1.51 +        pparams.BackBufferFormat = PixelFormatToD3DFMT(fullscreen_mode.format);
    1.52 +        pparams.FullScreen_RefreshRateInHz = fullscreen_mode.refresh_rate;
    1.53      } else {
    1.54          pparams.Windowed = TRUE;
    1.55 +        pparams.BackBufferFormat = D3DFMT_UNKNOWN;
    1.56          pparams.FullScreen_RefreshRateInHz = 0;
    1.57      }
    1.58      if (flags & SDL_RENDERER_PRESENTVSYNC) {
     2.1 --- a/src/video/SDL_video.c	Wed Jun 04 10:57:40 2014 -0700
     2.2 +++ b/src/video/SDL_video.c	Wed Jun 04 10:57:52 2014 -0700
     2.3 @@ -1044,10 +1044,10 @@
     2.4  
     2.5      fullscreen_mode = window->fullscreen_mode;
     2.6      if (!fullscreen_mode.w) {
     2.7 -        fullscreen_mode.w = window->w;
     2.8 +        fullscreen_mode.w = window->windowed.w;
     2.9      }
    2.10      if (!fullscreen_mode.h) {
    2.11 -        fullscreen_mode.h = window->h;
    2.12 +        fullscreen_mode.h = window->windowed.h;
    2.13      }
    2.14  
    2.15      display = SDL_GetDisplayForWindow(window);
    2.16 @@ -1093,9 +1093,9 @@
    2.17  SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
    2.18  {
    2.19      SDL_VideoDisplay *display;
    2.20 -	SDL_Window *other;
    2.21 -
    2.22 -	CHECK_WINDOW_MAGIC(window,);
    2.23 +    SDL_Window *other;
    2.24 +
    2.25 +    CHECK_WINDOW_MAGIC(window,);
    2.26  
    2.27  #ifdef __MACOSX__
    2.28      if (Cocoa_SetWindowFullscreenSpace(window, fullscreen)) {
    2.29 @@ -1688,15 +1688,13 @@
    2.30          h = window->max_h;
    2.31      }
    2.32  
    2.33 +    window->windowed.w = w;
    2.34 +    window->windowed.h = h;
    2.35 +
    2.36      if (window->flags & SDL_WINDOW_FULLSCREEN) {
    2.37 -        window->windowed.w = w;
    2.38 -        window->windowed.h = h;
    2.39 -
    2.40          if (FULLSCREEN_VISIBLE(window) && (window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
    2.41 -            SDL_DisplayMode fullscreen_mode;
    2.42 -            if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
    2.43 -                SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
    2.44 -            }
    2.45 +            window->last_fullscreen_flags = 0;
    2.46 +            SDL_UpdateFullscreenMode(window, SDL_TRUE);
    2.47          }
    2.48      } else {
    2.49          window->w = w;