iOS: Fix SDL_EVENT_DROP_FILE lost on cold start from URL open

This commit is contained in:
Jason Millard
2026-03-27 22:08:07 -04:00
committed by Sam Lantinga
parent 2f13731d23
commit 290f0c831f

View File

@@ -352,6 +352,7 @@ API_AVAILABLE(ios(13.0))
@implementation SDLUIKitSceneDelegate
{
UIWindow *launchWindow;
NSMutableArray<NSURL *> *launchURLs;
}
+ (NSString *)getSceneDelegateClassName
@@ -411,15 +412,16 @@ API_AVAILABLE(ios(13.0))
// Set working directory to resource path
[[NSFileManager defaultManager] changeCurrentDirectoryPath:[bundle resourcePath]];
// Handle any connection options (like opening URLs)
launchURLs = [[NSMutableArray alloc] init];
for (NSUserActivity *activity in connectionOptions.userActivities) {
if (activity.webpageURL) {
[self handleURL:activity.webpageURL];
[launchURLs addObject:activity.webpageURL];
}
}
for (UIOpenURLContext *urlContext in connectionOptions.URLContexts) {
[self handleURL:urlContext.URL];
[launchURLs addObject:urlContext.URL];
}
SDL_SetMainReady();
@@ -488,6 +490,7 @@ API_AVAILABLE(ios(13.0))
- (void)postFinishLaunch
{
[self performSelector:@selector(hideLaunchScreen) withObject:nil afterDelay:0.0];
[self performSelector:@selector(processLaunchURLs) withObject:nil afterDelay:0.0];
SDL_SetiOSEventPump(true);
exit_status = SDL_CallMainFunction(forward_argc, forward_argv, forward_main);
@@ -499,6 +502,14 @@ API_AVAILABLE(ios(13.0))
}
}
- (void)processLaunchURLs
{
for (NSURL *url in launchURLs) {
[self handleURL:url];
}
launchURLs = nil;
}
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options API_AVAILABLE(ios(13.0))
{
// This doesn't appear to be called, but it needs to be implemented to signal that we support the UIScene life cycle