Skip to content

Commit

Permalink
iOS: Fix issues with Split VIew on iPad (bugs #4586, #4705).
Browse files Browse the repository at this point in the history
  • Loading branch information
slime73 committed Aug 15, 2019
1 parent 7f9016f commit 79cd6cf
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/video/uikit/SDL_uikitvideo.m
Expand Up @@ -192,8 +192,16 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device)
CGRect
UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen)
{
SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
CGRect frame = screen.bounds;

/* Use the UIWindow bounds instead of the UIScreen bounds, when possible.
* The uiwindow bounds may be smaller than the screen bounds when Split View
* is used on an iPad. */
if (data != nil && data.uiwindow != nil) {
frame = data.uiwindow.bounds;
}

#if !TARGET_OS_TV && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0)
BOOL hasiOS7 = UIKit_IsSystemVersionAtLeast(7.0);

Expand All @@ -214,9 +222,12 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device)
* https://forums.developer.apple.com/thread/65337 */
if (UIKit_IsSystemVersionAtLeast(8.0)) {
UIInterfaceOrientation orient = [UIApplication sharedApplication].statusBarOrientation;
BOOL isLandscape = UIInterfaceOrientationIsLandscape(orient);
BOOL landscape = UIInterfaceOrientationIsLandscape(orient);
BOOL fullscreen = CGRectEqualToRect(screen.bounds, frame);

if (isLandscape != (frame.size.width > frame.size.height)) {
/* The orientation flip doesn't make sense when the window is smaller
* than the screen (iPad Split View, for example). */
if (fullscreen && (landscape != (frame.size.width > frame.size.height))) {
float height = frame.size.width;
frame.size.width = frame.size.height;
frame.size.height = height;
Expand Down

0 comments on commit 79cd6cf

Please sign in to comment.