From d2f8233e6de6c5c7a3fbd75652f026ee3716fbb8 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 12 Sep 2021 18:30:14 +1000 Subject: [PATCH] fix never displaying anything on ios version --- src/Launcher.c | 2 +- src/interop_ios.m | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Launcher.c b/src/Launcher.c index 45512b03d..3f7729279 100644 --- a/src/Launcher.c +++ b/src/Launcher.c @@ -338,7 +338,7 @@ void Launcher_Run(void) { Http_Component.Free(); Program_Run(0, NULL); - Window_ExitFullscreen(); + Window_ExitFullscreen(); /* TODO remove */ Window_RemakeSurface(); Launcher_Run(); } diff --git a/src/interop_ios.m b/src/interop_ios.m index 357e3b880..334224900 100644 --- a/src/interop_ios.m +++ b/src/interop_ios.m @@ -27,10 +27,16 @@ static UIWindow* winHandle; @implementation AppDelegate -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - // Override point for customization after application launch. +- (void)runMainLoop { extern int main_real(int argc, char** argv); main_real(1, NULL); +} + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + // schedule the actual main loop to run in next CFRunLoop iteration + // (as calling main_real here doesn't work properly) + [self performSelector:@selector(runMainLoop) withObject:nil afterDelay:0.0]; return YES; } @@ -107,7 +113,7 @@ void Window_Create(int width, int height) { controller = [ViewController alloc]; winHandle = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; winHandle.rootViewController = controller; - winHandle.backgroundColor = UIColor.greenColor; + winHandle.backgroundColor = UIColor.blueColor; WindowInfo.Exists = true; } void Window_SetSize(int width, int height) { } @@ -118,7 +124,13 @@ void Window_Show(void) { [winHandle makeKeyAndVisible]; } -void Window_ProcessEvents(void) { } +void Window_ProcessEvents(void) { + SInt32 res; + // manually tick event queue + do { + res = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE); + } while (res == kCFRunLoopRunHandledSource); +} void ShowDialogCore(const char* title, const char* msg) { } void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) { }