Allow switching between FS and desktop FS.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Wed, 15 Jan 2014 11:17:09 -0800
changeset 811098646f687e2b
parent 8109 19f0074531cf
child 8111 426e78ce52e4
Allow switching between FS and desktop FS.

This should fix bug #2057 (https://bugzilla.libsdl.org/show_bug.cgi?id=2057)
src/video/SDL_sysvideo.h
src/video/SDL_video.c
     1.1 --- a/src/video/SDL_sysvideo.h	Wed Jan 15 11:08:55 2014 -0800
     1.2 +++ b/src/video/SDL_sysvideo.h	Wed Jan 15 11:17:09 2014 -0800
     1.3 @@ -79,6 +79,7 @@
     1.4      int min_w, min_h;
     1.5      int max_w, max_h;
     1.6      Uint32 flags;
     1.7 +    Uint32 last_fullscreen_flags;
     1.8  
     1.9      /* Stored position and size for windowed mode */
    1.10      SDL_Rect windowed;
     2.1 --- a/src/video/SDL_video.c	Wed Jan 15 11:08:55 2014 -0800
     2.2 +++ b/src/video/SDL_video.c	Wed Jan 15 11:17:09 2014 -0800
     2.3 @@ -115,6 +115,7 @@
     2.4          return retval; \
     2.5      }
     2.6  
     2.7 +#define FULLSCREEN_MASK ( SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN )
     2.8  
     2.9  #ifdef __MACOSX__
    2.10  /* Support for Mac OS X fullscreen spaces */
    2.11 @@ -1096,6 +1097,7 @@
    2.12  
    2.13  #ifdef __MACOSX__
    2.14      if (Cocoa_SetWindowFullscreenSpace(window, fullscreen)) {
    2.15 +        window->last_fullscreen_flags = window->flags;
    2.16          return;
    2.17      }
    2.18  #endif
    2.19 @@ -1112,7 +1114,9 @@
    2.20  
    2.21      /* See if anything needs to be done now */
    2.22      if ((display->fullscreen_window == window) == fullscreen) {
    2.23 -        return;
    2.24 +        if ((window->last_fullscreen_flags & FULLSCREEN_MASK) == (window->flags & FULLSCREEN_MASK)) {
    2.25 +            return;
    2.26 +        }
    2.27      }
    2.28  
    2.29      /* See if there are any fullscreen windows */
    2.30 @@ -1157,6 +1161,8 @@
    2.31                  }
    2.32  
    2.33                  SDL_RestoreMousePosition(other);
    2.34 +
    2.35 +                window->last_fullscreen_flags = window->flags;
    2.36                  return;
    2.37              }
    2.38          }
    2.39 @@ -1175,6 +1181,8 @@
    2.40  
    2.41      /* Restore the cursor position */
    2.42      SDL_RestoreMousePosition(window);
    2.43 +
    2.44 +    window->last_fullscreen_flags = window->flags;
    2.45  }
    2.46  
    2.47  #define CREATE_FLAGS \
    2.48 @@ -1277,6 +1285,7 @@
    2.49          }
    2.50      }
    2.51      window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
    2.52 +    window->last_fullscreen_flags = window->flags;
    2.53      window->brightness = 1.0f;
    2.54      window->next = _this->windows;
    2.55  
    2.56 @@ -1318,6 +1327,7 @@
    2.57      window->magic = &_this->window_magic;
    2.58      window->id = _this->next_object_id++;
    2.59      window->flags = SDL_WINDOW_FOREIGN;
    2.60 +    window->last_fullscreen_flags = window->flags;
    2.61      window->brightness = 1.0f;
    2.62      window->next = _this->windows;
    2.63      if (_this->windows) {
    2.64 @@ -1378,6 +1388,7 @@
    2.65      window->title = NULL;
    2.66      window->icon = NULL;
    2.67      window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
    2.68 +    window->last_fullscreen_flags = window->flags;
    2.69  
    2.70      if (_this->CreateWindow && !(flags & SDL_WINDOW_FOREIGN)) {
    2.71          if (_this->CreateWindow(_this, window) < 0) {
    2.72 @@ -1857,7 +1868,6 @@
    2.73      }
    2.74  }
    2.75  
    2.76 -#define FULLSCREEN_MASK ( SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN )
    2.77  int
    2.78  SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
    2.79  {