From be29ca01899dc6757dfb1949340a06280c44d19f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 24 Dec 2023 17:14:16 -0800 Subject: [PATCH] Use the application requested size to determine automatic orientation on iOS Fixes https://github.com/libsdl-org/SDL/issues/8201 (cherry picked from commit e3b5999bb4fe9bc8413630215d928f90347073d1) --- src/video/uikit/SDL_uikitwindow.m | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index 919e98a11f..ff3cb859db 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -114,14 +114,6 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo #if !TARGET_OS_TV 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; @@ -459,10 +451,10 @@ NSUInteger UIKit_GetSupportedOrientations(SDL_Window * window) } if (orientationMask == 0) { - if (window->w >= window->h) { + if (window->windowed.w >= window->windowed.h) { orientationMask |= UIInterfaceOrientationMaskLandscape; } - if (window->h >= window->w) { + if (window->windowed.h >= window->windowed.w) { orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown); } }