iOS: Fix issues with Split VIew on iPad (bugs #4586, #4705).

This commit is contained in:
Alex Szpakowski 2019-08-15 19:38:12 -03:00
parent 7f9016f265
commit 79cd6cfc94
1 changed files with 13 additions and 2 deletions

View File

@ -192,8 +192,16 @@ UIKit_IsSystemVersionAtLeast(double version)
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);
@ -214,9 +222,12 @@ UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen)
* 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;