From a0c9e649f5b87bb911a1c16a75312fb54065fc30 Mon Sep 17 00:00:00 2001 From: "J?rgen P. Tjern?" Date: Wed, 15 Jan 2014 11:17:09 -0800 Subject: [PATCH] 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 | 1 + src/video/SDL_video.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 94ff9b3234a95..c70beefa7bfbb 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -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; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 658ac8e14a2bf..a4a8c6ef3ab3e 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -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,7 +1114,9 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen) /* See if anything needs to be done now */ if ((display->fullscreen_window == window) == fullscreen) { - return; + if ((window->last_fullscreen_flags & FULLSCREEN_MASK) == (window->flags & FULLSCREEN_MASK)) { + return; + } } /* See if there are any fullscreen windows */ @@ -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) {