Allow switching between FS and desktop FS. This should fix bug #2057 (https://bugzilla.libsdl.org/show_bug.cgi?id=2057)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
index 94ff9b3..c70beef 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 658ac8e..a4a8c6e 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)
{