src/video/SDL_video.c
changeset 5404 6717e01acbe0
parent 5403 424f036f7c68
child 5423 b69fa50e80d7
     1.1 --- a/src/video/SDL_video.c	Sun Feb 27 20:06:45 2011 -0800
     1.2 +++ b/src/video/SDL_video.c	Sun Feb 27 21:17:06 2011 -0800
     1.3 @@ -1018,12 +1018,12 @@
     1.4  }
     1.5  
     1.6  static void
     1.7 -SDL_UpdateFullscreenMode(SDL_Window * window)
     1.8 +SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
     1.9  {
    1.10      SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    1.11      SDL_Window *other;
    1.12  
    1.13 -    if (FULLSCREEN_VISIBLE(window)) {
    1.14 +    if (fullscreen) {
    1.15          /* Hide any other fullscreen windows */
    1.16          if (display->fullscreen_window &&
    1.17              display->fullscreen_window != window) {
    1.18 @@ -1032,15 +1032,24 @@
    1.19      }
    1.20  
    1.21      /* See if anything needs to be done now */
    1.22 -    if ((display->fullscreen_window == window) == FULLSCREEN_VISIBLE(window)) {
    1.23 +    if ((display->fullscreen_window == window) == fullscreen) {
    1.24          return;
    1.25      }
    1.26  
    1.27      /* See if there are any fullscreen windows */
    1.28      for (other = _this->windows; other; other = other->next) {
    1.29 -        if (FULLSCREEN_VISIBLE(other) &&
    1.30 -            SDL_GetDisplayForWindow(other) == display) {
    1.31 +        SDL_bool setDisplayMode = SDL_FALSE;
    1.32 +
    1.33 +        if (other == window) {
    1.34 +            setDisplayMode = fullscreen;
    1.35 +        } else if (FULLSCREEN_VISIBLE(other) &&
    1.36 +                   SDL_GetDisplayForWindow(other) == display) {
    1.37 +            setDisplayMode = SDL_TRUE;
    1.38 +        }
    1.39 +
    1.40 +        if (setDisplayMode) {
    1.41              SDL_DisplayMode fullscreen_mode;
    1.42 +
    1.43              if (SDL_GetWindowDisplayMode(other, &fullscreen_mode) == 0) {
    1.44                  SDL_bool resized = SDL_TRUE;
    1.45  
    1.46 @@ -1144,7 +1153,7 @@
    1.47  
    1.48          displayIndex = SDL_GetIndexOfDisplay(display);
    1.49          SDL_GetDisplayBounds(displayIndex, &bounds);
    1.50 -        if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
    1.51 +        if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISCENTERED(x)) {
    1.52              window->x = bounds.x + (bounds.w - w) / 2;
    1.53          }
    1.54          if (SDL_WINDOWPOS_ISUNDEFINED(y) || SDL_WINDOWPOS_ISCENTERED(y)) {
    1.55 @@ -1512,6 +1521,8 @@
    1.56          return;
    1.57      }
    1.58  
    1.59 +    SDL_UpdateFullscreenMode(window, SDL_FALSE);
    1.60 +
    1.61      if (_this->HideWindow) {
    1.62          _this->HideWindow(_this, window);
    1.63      }
    1.64 @@ -1528,9 +1539,6 @@
    1.65      }
    1.66      if (_this->RaiseWindow) {
    1.67          _this->RaiseWindow(_this, window);
    1.68 -    } else {
    1.69 -        /* FIXME: What we really want is a way to request focus */
    1.70 -        SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0);
    1.71      }
    1.72  }
    1.73  
    1.74 @@ -1557,6 +1565,8 @@
    1.75          return;
    1.76      }
    1.77  
    1.78 +    SDL_UpdateFullscreenMode(window, SDL_FALSE);
    1.79 +
    1.80      if (_this->MinimizeWindow) {
    1.81          _this->MinimizeWindow(_this, window);
    1.82      }
    1.83 @@ -1574,7 +1584,6 @@
    1.84      if (_this->RestoreWindow) {
    1.85          _this->RestoreWindow(_this, window);
    1.86      }
    1.87 -    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
    1.88  }
    1.89  
    1.90  int
    1.91 @@ -1582,10 +1591,7 @@
    1.92  {
    1.93      CHECK_WINDOW_MAGIC(window, -1);
    1.94  
    1.95 -    if (fullscreen) {
    1.96 -        fullscreen = SDL_WINDOW_FULLSCREEN;
    1.97 -    }
    1.98 -    if ((window->flags & SDL_WINDOW_FULLSCREEN) == fullscreen) {
    1.99 +    if (!!fullscreen == !!(window->flags & SDL_WINDOW_FULLSCREEN)) {
   1.100          return 0;
   1.101      }
   1.102      if (fullscreen) {
   1.103 @@ -1593,7 +1599,7 @@
   1.104      } else {
   1.105          window->flags &= ~SDL_WINDOW_FULLSCREEN;
   1.106      }
   1.107 -    SDL_UpdateFullscreenMode(window);
   1.108 +    SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window));
   1.109  
   1.110      return 0;
   1.111  }
   1.112 @@ -1682,7 +1688,7 @@
   1.113  {
   1.114      CHECK_WINDOW_MAGIC(window, );
   1.115  
   1.116 -    if ((!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED))) {
   1.117 +    if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) {
   1.118          return;
   1.119      }
   1.120      if (grabbed) {
   1.121 @@ -1704,14 +1710,13 @@
   1.122  void
   1.123  SDL_OnWindowShown(SDL_Window * window)
   1.124  {
   1.125 -    SDL_RaiseWindow(window);
   1.126 -    SDL_UpdateFullscreenMode(window);
   1.127 +    SDL_OnWindowRestored(window);
   1.128  }
   1.129  
   1.130  void
   1.131  SDL_OnWindowHidden(SDL_Window * window)
   1.132  {
   1.133 -    SDL_UpdateFullscreenMode(window);
   1.134 +    SDL_UpdateFullscreenMode(window, SDL_FALSE);
   1.135  }
   1.136  
   1.137  void
   1.138 @@ -1724,14 +1729,17 @@
   1.139  void
   1.140  SDL_OnWindowMinimized(SDL_Window * window)
   1.141  {
   1.142 -    SDL_UpdateFullscreenMode(window);
   1.143 +    SDL_UpdateFullscreenMode(window, SDL_FALSE);
   1.144  }
   1.145  
   1.146  void
   1.147  SDL_OnWindowRestored(SDL_Window * window)
   1.148  {
   1.149      SDL_RaiseWindow(window);
   1.150 -    SDL_UpdateFullscreenMode(window);
   1.151 +
   1.152 +    if (FULLSCREEN_VISIBLE(window)) {
   1.153 +        SDL_UpdateFullscreenMode(window, SDL_TRUE);
   1.154 +    }
   1.155  }
   1.156  
   1.157  void