From e43550c0393512afea3cfa41d4cfb0a108ba0bd1 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 9 Jun 2019 14:08:18 -0700 Subject: [PATCH] Fixed bug 4658 - iOS 12 fullscreen flag and SDL_HINT_IOS_HIDE_HOME_INDICATOR not working Caleb Cornett On iOS 12, creating a window with the SDL_WINDOW_FULLSCREEN flag does not dim the home indicator or defer system gestures. The same goes for setting the SDL_HINT_IOS_HIDE_HOME_INDICATOR to "2" -- it has no effect at all. I've tracked down the source of this misbehavior to a timing issue. The initial `setNeedsUpdate...` calls were happening too early and getting applied to the launch screen by mistake. In the attached patch, I've added a call to those functions right after the launch screen is hidden so that they apply to the main view controller instead. This appears to fix the issue, at least on my iPhone 6s Plus. --- src/video/uikit/SDL_uikitappdelegate.m | 1 + src/video/uikit/SDL_uikitmessagebox.m | 14 +------------- src/video/uikit/SDL_uikitvideo.h | 2 ++ src/video/uikit/SDL_uikitvideo.m | 18 ++++++++++++++++++ 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index 8d3e3c433eec0..ecc695d250310 100644 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -343,6 +343,7 @@ - (void)hideLaunchScreen window.alpha = 0.0; } completion:^(BOOL finished) { window.hidden = YES; + UIKit_ForceUpdateHomeIndicator(); /* Wait for launch screen to hide so settings are applied to the actual view controller. */ }]; } diff --git a/src/video/uikit/SDL_uikitmessagebox.m b/src/video/uikit/SDL_uikitmessagebox.m index 16a0c21223e64..b14a3c019a4fc 100644 --- a/src/video/uikit/SDL_uikitmessagebox.m +++ b/src/video/uikit/SDL_uikitmessagebox.m @@ -108,19 +108,7 @@ alertwindow.hidden = YES; } -#if !TARGET_OS_TV - /* Force the main SDL window to re-evaluate home indicator state */ - SDL_Window *focus = SDL_GetFocusWindow(); - if (focus) { - SDL_WindowData *data = (__bridge SDL_WindowData *) focus->driverdata; - if (data != nil) { - if (@available(iOS 11.0, *)) { - [data.viewcontroller performSelectorOnMainThread:@selector(setNeedsUpdateOfHomeIndicatorAutoHidden) withObject:nil waitUntilDone:NO]; - [data.viewcontroller performSelectorOnMainThread:@selector(setNeedsUpdateOfScreenEdgesDeferringSystemGestures) withObject:nil waitUntilDone:NO]; - } - } - } -#endif /* !TARGET_OS_TV */ + UIKit_ForceUpdateHomeIndicator(); *buttonid = messageboxdata->buttons[clickedindex].buttonid; return YES; diff --git a/src/video/uikit/SDL_uikitvideo.h b/src/video/uikit/SDL_uikitvideo.h index c43ed80b8275a..4e12855c170c6 100644 --- a/src/video/uikit/SDL_uikitvideo.h +++ b/src/video/uikit/SDL_uikitvideo.h @@ -39,6 +39,8 @@ CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen); void UIKit_SuspendScreenSaver(_THIS); +void UIKit_ForceUpdateHomeIndicator(void); + SDL_bool UIKit_IsSystemVersionAtLeast(double version); #endif /* SDL_uikitvideo_h_ */ diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m index f0103aeccd603..7c21d16c2de3a 100644 --- a/src/video/uikit/SDL_uikitvideo.m +++ b/src/video/uikit/SDL_uikitvideo.m @@ -221,6 +221,24 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device) return frame; } +void +UIKit_ForceUpdateHomeIndicator() +{ +#if !TARGET_OS_TV + /* Force the main SDL window to re-evaluate home indicator state */ + SDL_Window *focus = SDL_GetFocusWindow(); + if (focus) { + SDL_WindowData *data = (__bridge SDL_WindowData *) focus->driverdata; + if (data != nil) { + if (@available(iOS 11.0, *)) { + [data.viewcontroller performSelectorOnMainThread:@selector(setNeedsUpdateOfHomeIndicatorAutoHidden) withObject:nil waitUntilDone:NO]; + [data.viewcontroller performSelectorOnMainThread:@selector(setNeedsUpdateOfScreenEdgesDeferringSystemGestures) withObject:nil waitUntilDone:NO]; + } + } + } +#endif /* !TARGET_OS_TV */ +} + /* * iOS log support. *