mirror of https://github.com/libsdl-org/SDL.git
Keep the lifecycle observer active while there are windows active
Fixes https://github.com/libsdl-org/SDL/issues/11627
This commit is contained in:
parent
355f69ebfe
commit
2c7b7d1d33
|
|
@ -172,6 +172,10 @@ extern bool Cocoa_IsWindowInFullscreenSpace(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);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SDL_VIDEO_DRIVER_UIKIT
|
||||||
|
extern void SDL_UpdateLifecycleObserver(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
static void SDL_CheckWindowDisplayChanged(SDL_Window *window);
|
static void SDL_CheckWindowDisplayChanged(SDL_Window *window);
|
||||||
static void SDL_CheckWindowDisplayScaleChanged(SDL_Window *window);
|
static void SDL_CheckWindowDisplayScaleChanged(SDL_Window *window);
|
||||||
static void SDL_CheckWindowSafeAreaChanged(SDL_Window *window);
|
static void SDL_CheckWindowSafeAreaChanged(SDL_Window *window);
|
||||||
|
|
@ -2467,6 +2471,10 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props)
|
||||||
// Make sure window pixel size is up to date
|
// Make sure window pixel size is up to date
|
||||||
SDL_CheckWindowPixelSizeChanged(window);
|
SDL_CheckWindowPixelSizeChanged(window);
|
||||||
|
|
||||||
|
#ifdef SDL_VIDEO_DRIVER_UIKIT
|
||||||
|
SDL_UpdateLifecycleObserver();
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_ClearError();
|
SDL_ClearError();
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
|
|
@ -4198,6 +4206,10 @@ void SDL_DestroyWindow(SDL_Window *window)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_free(window);
|
SDL_free(window);
|
||||||
|
|
||||||
|
#ifdef SDL_VIDEO_DRIVER_UIKIT
|
||||||
|
SDL_UpdateLifecycleObserver();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDL_ScreenSaverEnabled(void)
|
bool SDL_ScreenSaverEnabled(void)
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,16 @@ static BOOL UIKit_EventPumpEnabled = YES;
|
||||||
- (void)update
|
- (void)update
|
||||||
{
|
{
|
||||||
NSNotificationCenter *notificationCenter = NSNotificationCenter.defaultCenter;
|
NSNotificationCenter *notificationCenter = NSNotificationCenter.defaultCenter;
|
||||||
if ((UIKit_EventPumpEnabled || SDL_HasMainCallbacks()) && !self.isObservingNotifications) {
|
bool wants_observation = (UIKit_EventPumpEnabled || SDL_HasMainCallbacks());
|
||||||
|
if (!wants_observation) {
|
||||||
|
// Make sure no windows have active animation callbacks
|
||||||
|
int num_windows = 0;
|
||||||
|
SDL_free(SDL_GetWindows(&num_windows));
|
||||||
|
if (num_windows > 0) {
|
||||||
|
wants_observation = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wants_observation && !self.isObservingNotifications) {
|
||||||
self.isObservingNotifications = YES;
|
self.isObservingNotifications = YES;
|
||||||
[notificationCenter addObserver:self selector:@selector(applicationDidBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil];
|
[notificationCenter addObserver:self selector:@selector(applicationDidBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil];
|
||||||
[notificationCenter addObserver:self selector:@selector(applicationWillResignActive) name:UIApplicationWillResignActiveNotification object:nil];
|
[notificationCenter addObserver:self selector:@selector(applicationWillResignActive) name:UIApplicationWillResignActiveNotification object:nil];
|
||||||
|
|
@ -58,7 +67,7 @@ static BOOL UIKit_EventPumpEnabled = YES;
|
||||||
name:UIApplicationDidChangeStatusBarOrientationNotification
|
name:UIApplicationDidChangeStatusBarOrientationNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
#endif
|
#endif
|
||||||
} else if (!UIKit_EventPumpEnabled && !SDL_HasMainCallbacks() && self.isObservingNotifications) {
|
} else if (!wants_observation && self.isObservingNotifications) {
|
||||||
self.isObservingNotifications = NO;
|
self.isObservingNotifications = NO;
|
||||||
[notificationCenter removeObserver:self];
|
[notificationCenter removeObserver:self];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue