Fixed bug 4658 - iOS 12 fullscreen flag and SDL_HINT_IOS_HIDE_HOME_INDICATOR not working
authorSam Lantinga
Sun, 09 Jun 2019 14:08:18 -0700
changeset 128119b59bc963a74
parent 12810 77707a081153
child 12812 4f015bc7cbb1
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
src/video/uikit/SDL_uikitmessagebox.m
src/video/uikit/SDL_uikitvideo.h
src/video/uikit/SDL_uikitvideo.m
     1.1 --- a/src/video/uikit/SDL_uikitappdelegate.m	Sun Jun 09 11:54:51 2019 -0400
     1.2 +++ b/src/video/uikit/SDL_uikitappdelegate.m	Sun Jun 09 14:08:18 2019 -0700
     1.3 @@ -343,6 +343,7 @@
     1.4          window.alpha = 0.0;
     1.5      } completion:^(BOOL finished) {
     1.6          window.hidden = YES;
     1.7 +        UIKit_ForceUpdateHomeIndicator(); /* Wait for launch screen to hide so settings are applied to the actual view controller. */
     1.8      }];
     1.9  }
    1.10  
     2.1 --- a/src/video/uikit/SDL_uikitmessagebox.m	Sun Jun 09 11:54:51 2019 -0400
     2.2 +++ b/src/video/uikit/SDL_uikitmessagebox.m	Sun Jun 09 14:08:18 2019 -0700
     2.3 @@ -108,19 +108,7 @@
     2.4          alertwindow.hidden = YES;
     2.5      }
     2.6  
     2.7 -#if !TARGET_OS_TV
     2.8 -    /* Force the main SDL window to re-evaluate home indicator state */
     2.9 -    SDL_Window *focus = SDL_GetFocusWindow();
    2.10 -    if (focus) {
    2.11 -        SDL_WindowData *data = (__bridge SDL_WindowData *) focus->driverdata;
    2.12 -        if (data != nil) {
    2.13 -            if (@available(iOS 11.0, *)) {
    2.14 -                [data.viewcontroller performSelectorOnMainThread:@selector(setNeedsUpdateOfHomeIndicatorAutoHidden) withObject:nil waitUntilDone:NO];
    2.15 -                [data.viewcontroller performSelectorOnMainThread:@selector(setNeedsUpdateOfScreenEdgesDeferringSystemGestures) withObject:nil waitUntilDone:NO];
    2.16 -            }
    2.17 -        }
    2.18 -    }
    2.19 -#endif /* !TARGET_OS_TV */
    2.20 +    UIKit_ForceUpdateHomeIndicator();
    2.21  
    2.22      *buttonid = messageboxdata->buttons[clickedindex].buttonid;
    2.23      return YES;
     3.1 --- a/src/video/uikit/SDL_uikitvideo.h	Sun Jun 09 11:54:51 2019 -0400
     3.2 +++ b/src/video/uikit/SDL_uikitvideo.h	Sun Jun 09 14:08:18 2019 -0700
     3.3 @@ -39,6 +39,8 @@
     3.4  
     3.5  void UIKit_SuspendScreenSaver(_THIS);
     3.6  
     3.7 +void UIKit_ForceUpdateHomeIndicator(void);
     3.8 +
     3.9  SDL_bool UIKit_IsSystemVersionAtLeast(double version);
    3.10  
    3.11  #endif /* SDL_uikitvideo_h_ */
     4.1 --- a/src/video/uikit/SDL_uikitvideo.m	Sun Jun 09 11:54:51 2019 -0400
     4.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Sun Jun 09 14:08:18 2019 -0700
     4.3 @@ -221,6 +221,24 @@
     4.4      return frame;
     4.5  }
     4.6  
     4.7 +void
     4.8 +UIKit_ForceUpdateHomeIndicator()
     4.9 +{
    4.10 +#if !TARGET_OS_TV
    4.11 +    /* Force the main SDL window to re-evaluate home indicator state */
    4.12 +    SDL_Window *focus = SDL_GetFocusWindow();
    4.13 +    if (focus) {
    4.14 +        SDL_WindowData *data = (__bridge SDL_WindowData *) focus->driverdata;
    4.15 +        if (data != nil) {
    4.16 +            if (@available(iOS 11.0, *)) {
    4.17 +                [data.viewcontroller performSelectorOnMainThread:@selector(setNeedsUpdateOfHomeIndicatorAutoHidden) withObject:nil waitUntilDone:NO];
    4.18 +                [data.viewcontroller performSelectorOnMainThread:@selector(setNeedsUpdateOfScreenEdgesDeferringSystemGestures) withObject:nil waitUntilDone:NO];
    4.19 +            }
    4.20 +        }
    4.21 +    }
    4.22 +#endif /* !TARGET_OS_TV */
    4.23 +}
    4.24 +
    4.25  /*
    4.26   * iOS log support.
    4.27   *