Browse Source

Use the application requested size to determine automatic orientation on iOS

Fixes https://github.com/libsdl-org/SDL/issues/8201
Sam Lantinga 1 year ago
parent
commit
e3b5999bb4
1 changed files with 2 additions and 10 deletions
  1. 2 10
      src/video/uikit/SDL_uikitwindow.m

+ 2 - 10
src/video/uikit/SDL_uikitwindow.m

@@ -113,14 +113,6 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow
 
 #if !TARGET_OS_TV && !TARGET_OS_XR
     if (displaydata.uiscreen == [UIScreen mainScreen]) {
-        /* SDL_CreateWindow sets the window w&h to the display's bounds if the
-         * fullscreen flag is set. But the display bounds orientation might not
-         * match what we want, and GetSupportedOrientations call below uses the
-         * window w&h. They're overridden below anyway, so we'll just set them
-         * to the requested size for the purposes of determining orientation. */
-        window->w = window->windowed.w;
-        window->h = window->windowed.h;
-
         NSUInteger orients = UIKit_GetSupportedOrientations(window);
         BOOL supportsLandscape = (orients & UIInterfaceOrientationMaskLandscape) != 0;
         BOOL supportsPortrait = (orients & (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown)) != 0;
@@ -441,10 +433,10 @@ UIKit_GetSupportedOrientations(SDL_Window *window)
         }
 
         if (orientationMask == 0) {
-            if (window->w >= window->h) {
+            if (window->floating.w >= window->floating.h) {
                 orientationMask |= UIInterfaceOrientationMaskLandscape;
             }
-            if (window->h >= window->w) {
+            if (window->floating.h >= window->floating.w) {
                 orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
             }
         }