mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-07 11:58:12 +00:00
cocoa: Wait for fullscreen spaces transitions to complete if switching to an exclusive mode
If attempting to switch to an exclusive mode while a fullscreen spaces transition is active, wait until the transition is complete before trying to apply the changes, or the window can wind up in a weird, broken state if a mode switch occurs while in a fullscreen space.
(cherry picked from commit f44a98729c
)
This commit is contained in:
@@ -173,6 +173,7 @@ static VideoBootStrap *bootstrap[] = {
|
|||||||
#if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA)
|
#if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA)
|
||||||
// Support for macOS fullscreen spaces, etc.
|
// Support for macOS fullscreen spaces, etc.
|
||||||
extern bool Cocoa_IsWindowInFullscreenSpace(SDL_Window *window);
|
extern bool Cocoa_IsWindowInFullscreenSpace(SDL_Window *window);
|
||||||
|
extern bool Cocoa_IsWindowInFullscreenSpaceTransition(SDL_Window *window);
|
||||||
extern bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, bool state, bool blocking);
|
extern bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, bool state, bool blocking);
|
||||||
extern bool Cocoa_IsShowingModalDialog(SDL_Window *window);
|
extern bool Cocoa_IsShowingModalDialog(SDL_Window *window);
|
||||||
#endif
|
#endif
|
||||||
@@ -2111,6 +2112,16 @@ bool SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode
|
|||||||
* is in progress. It will be overwritten if a new request is made.
|
* is in progress. It will be overwritten if a new request is made.
|
||||||
*/
|
*/
|
||||||
SDL_copyp(&window->current_fullscreen_mode, &window->requested_fullscreen_mode);
|
SDL_copyp(&window->current_fullscreen_mode, &window->requested_fullscreen_mode);
|
||||||
|
|
||||||
|
#if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA)
|
||||||
|
/* If this is called while in the middle of a Cocoa fullscreen spaces transition,
|
||||||
|
* wait until the transition has completed, or the window can wind up in a weird,
|
||||||
|
* broken state if a mode switch occurs while in a fullscreen space.
|
||||||
|
*/
|
||||||
|
if (SDL_strcmp(_this->name, "cocoa") == 0 && Cocoa_IsWindowInFullscreenSpaceTransition(window)) {
|
||||||
|
SDL_SyncWindow(window);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (SDL_WINDOW_FULLSCREEN_VISIBLE(window)) {
|
if (SDL_WINDOW_FULLSCREEN_VISIBLE(window)) {
|
||||||
SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_UPDATE, true);
|
SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_UPDATE, true);
|
||||||
SDL_SyncIfRequired(window);
|
SDL_SyncIfRequired(window);
|
||||||
|
@@ -411,6 +411,19 @@ bool Cocoa_IsWindowInFullscreenSpace(SDL_Window *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Cocoa_IsWindowInFullscreenSpaceTransition(SDL_Window *window)
|
||||||
|
{
|
||||||
|
@autoreleasepool {
|
||||||
|
SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal;
|
||||||
|
|
||||||
|
if ([data.listener isInFullscreenSpaceTransition]) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Cocoa_IsWindowZoomed(SDL_Window *window)
|
bool Cocoa_IsWindowZoomed(SDL_Window *window)
|
||||||
{
|
{
|
||||||
SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal;
|
SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal;
|
||||||
|
Reference in New Issue
Block a user