src/video/SDL_video.c
changeset 1970 db3ba6c0d0df
parent 1969 5d3724f64f2b
child 1977 754847f19490
     1.1 --- a/src/video/SDL_video.c	Sun Aug 06 00:09:04 2006 +0000
     1.2 +++ b/src/video/SDL_video.c	Sun Aug 06 04:39:13 2006 +0000
     1.3 @@ -645,6 +645,7 @@
     1.4  SDL_SetFullscreenDisplayMode(const SDL_DisplayMode * mode)
     1.5  {
     1.6      SDL_VideoDisplay *display;
     1.7 +    SDL_DisplayMode fullscreen_mode;
     1.8      int i;
     1.9  
    1.10      if (!_this) {
    1.11 @@ -653,18 +654,29 @@
    1.12      }
    1.13  
    1.14      display = &SDL_CurrentDisplay;
    1.15 -    if (mode) {
    1.16 -        SDL_GetClosestDisplayMode(mode, &display->desired_mode);
    1.17 -        display->fullscreen_mode = &display->desired_mode;
    1.18 -    } else {
    1.19 -        display->fullscreen_mode = NULL;
    1.20 +    if (!mode) {
    1.21 +        mode = &display->desktop_mode;
    1.22      }
    1.23  
    1.24 +    SDL_GetClosestDisplayMode(mode, &fullscreen_mode);
    1.25 +    if (SDL_memcmp
    1.26 +        (&fullscreen_mode, &display->fullscreen_mode,
    1.27 +         sizeof(fullscreen_mode)) == 0) {
    1.28 +        /* Nothing to do... */
    1.29 +        return 0;
    1.30 +    }
    1.31 +    display->fullscreen_mode = fullscreen_mode;
    1.32 +
    1.33      /* Actually set the mode if we have a fullscreen window visible */
    1.34      for (i = 0; i < display->num_windows; ++i) {
    1.35          SDL_Window *window = &display->windows[i];
    1.36          if (FULLSCREEN_VISIBLE(window)) {
    1.37 -            return SDL_SetDisplayMode(display->fullscreen_mode);
    1.38 +            if (SDL_SetDisplayMode(&display->fullscreen_mode) < 0) {
    1.39 +                return -1;
    1.40 +            }
    1.41 +        }
    1.42 +        if (window->flags & SDL_WINDOW_FULLSCREEN) {
    1.43 +            SDL_OnWindowResized(window);
    1.44          }
    1.45      }
    1.46      return 0;
    1.47 @@ -678,7 +690,7 @@
    1.48          return -1;
    1.49      }
    1.50      if (mode) {
    1.51 -        *mode = *SDL_CurrentDisplay.fullscreen_mode;
    1.52 +        *mode = SDL_CurrentDisplay.fullscreen_mode;
    1.53      }
    1.54      return 0;
    1.55  }
    1.56 @@ -1197,7 +1209,7 @@
    1.57                  }
    1.58              }
    1.59  
    1.60 -            SDL_SetDisplayMode(display->fullscreen_mode);
    1.61 +            SDL_SetDisplayMode(&display->fullscreen_mode);
    1.62          }
    1.63      } else {
    1.64          window->flags &= ~SDL_WINDOW_FULLSCREEN;
    1.65 @@ -1252,12 +1264,22 @@
    1.66  }
    1.67  
    1.68  void
    1.69 +SDL_OnWindowResized(SDL_Window * window)
    1.70 +{
    1.71 +    SDL_Renderer *renderer = window->renderer;
    1.72 +
    1.73 +    if (renderer && renderer->DisplayModeChanged) {
    1.74 +        renderer->DisplayModeChanged(renderer);
    1.75 +    }
    1.76 +}
    1.77 +
    1.78 +void
    1.79  SDL_OnWindowFocusGained(SDL_Window * window)
    1.80  {
    1.81      SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
    1.82  
    1.83      if (window->flags & SDL_WINDOW_FULLSCREEN) {
    1.84 -        SDL_SetDisplayMode(display->fullscreen_mode);
    1.85 +        SDL_SetDisplayMode(&display->fullscreen_mode);
    1.86      }
    1.87      if (display->gamma && _this->SetDisplayGammaRamp) {
    1.88          _this->SetDisplayGammaRamp(_this, display->gamma);