Allow switching between FS and desktop FS.

This should fix bug #2057 (https://bugzilla.libsdl.org/show_bug.cgi?id=2057)
This commit is contained in:
J?rgen P. Tjern? 2014-01-15 11:17:09 -08:00
parent a442f121e6
commit a0c9e649f5
2 changed files with 13 additions and 2 deletions

View File

@ -79,6 +79,7 @@ struct SDL_Window
int min_w, min_h;
int max_w, max_h;
Uint32 flags;
Uint32 last_fullscreen_flags;
/* Stored position and size for windowed mode */
SDL_Rect windowed;

View File

@ -115,6 +115,7 @@ static SDL_VideoDevice *_this = NULL;
return retval; \
}
#define FULLSCREEN_MASK ( SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN )
#ifdef __MACOSX__
/* Support for Mac OS X fullscreen spaces */
@ -1096,6 +1097,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
#ifdef __MACOSX__
if (Cocoa_SetWindowFullscreenSpace(window, fullscreen)) {
window->last_fullscreen_flags = window->flags;
return;
}
#endif
@ -1112,8 +1114,10 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
/* See if anything needs to be done now */
if ((display->fullscreen_window == window) == fullscreen) {
if ((window->last_fullscreen_flags & FULLSCREEN_MASK) == (window->flags & FULLSCREEN_MASK)) {
return;
}
}
/* See if there are any fullscreen windows */
for (other = _this->windows; other; other = other->next) {
@ -1157,6 +1161,8 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
}
SDL_RestoreMousePosition(other);
window->last_fullscreen_flags = window->flags;
return;
}
}
@ -1175,6 +1181,8 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
/* Restore the cursor position */
SDL_RestoreMousePosition(window);
window->last_fullscreen_flags = window->flags;
}
#define CREATE_FLAGS \
@ -1277,6 +1285,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
}
}
window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
window->last_fullscreen_flags = window->flags;
window->brightness = 1.0f;
window->next = _this->windows;
@ -1318,6 +1327,7 @@ SDL_CreateWindowFrom(const void *data)
window->magic = &_this->window_magic;
window->id = _this->next_object_id++;
window->flags = SDL_WINDOW_FOREIGN;
window->last_fullscreen_flags = window->flags;
window->brightness = 1.0f;
window->next = _this->windows;
if (_this->windows) {
@ -1378,6 +1388,7 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
window->title = NULL;
window->icon = NULL;
window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
window->last_fullscreen_flags = window->flags;
if (_this->CreateWindow && !(flags & SDL_WINDOW_FOREIGN)) {
if (_this->CreateWindow(_this, window) < 0) {
@ -1857,7 +1868,6 @@ SDL_RestoreWindow(SDL_Window * window)
}
}
#define FULLSCREEN_MASK ( SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN )
int
SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
{