src/video/uikit/SDL_uikitvideo.m
changeset 11327 770196e01af1
parent 11306 45fbdef6a227
child 11365 a9bd2625fa01
equal deleted inserted replaced
11326:ba4fe3686323 11327:770196e01af1
   174 }
   174 }
   175 
   175 
   176 CGRect
   176 CGRect
   177 UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen)
   177 UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen)
   178 {
   178 {
       
   179     CGRect frame = screen.bounds;
       
   180 
   179 #if !TARGET_OS_TV && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0)
   181 #if !TARGET_OS_TV && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0)
   180     BOOL hasiOS7 = UIKit_IsSystemVersionAtLeast(7.0);
   182     BOOL hasiOS7 = UIKit_IsSystemVersionAtLeast(7.0);
   181 
   183 
   182     /* The view should always show behind the status bar in iOS 7+. */
   184     /* The view should always show behind the status bar in iOS 7+. */
   183     if (!hasiOS7 && !(window->flags & (SDL_WINDOW_BORDERLESS|SDL_WINDOW_FULLSCREEN))) {
   185     if (!hasiOS7 && !(window->flags & (SDL_WINDOW_BORDERLESS|SDL_WINDOW_FULLSCREEN))) {
   184         return screen.applicationFrame;
   186         frame = screen.applicationFrame;
   185     }
   187     }
   186 #endif
   188 #endif
   187 
   189 
   188     return screen.bounds;
   190 #if !TARGET_OS_TV
       
   191     /* iOS 10 seems to have a bug where, in certain conditions, putting the
       
   192      * device to sleep with the a landscape-only app open, re-orienting the
       
   193      * device to portrait, and turning it back on will result in the screen
       
   194      * bounds returning portrait orientation despite the app being in landscape.
       
   195      * This is a workaround until a better solution can be found.
       
   196      * https://bugzilla.libsdl.org/show_bug.cgi?id=3505
       
   197      * https://bugzilla.libsdl.org/show_bug.cgi?id=3465
       
   198      * https://forums.developer.apple.com/thread/65337 */
       
   199     if (UIKit_IsSystemVersionAtLeast(8.0)) {
       
   200         UIInterfaceOrientation orient = [UIApplication sharedApplication].statusBarOrientation;
       
   201         BOOL isLandscape = UIInterfaceOrientationIsLandscape(orient);
       
   202 
       
   203         if (isLandscape != (frame.size.width > frame.size.height)) {
       
   204             float height = frame.size.width;
       
   205             frame.size.width = frame.size.height;
       
   206             frame.size.height = height;
       
   207         }
       
   208     }
       
   209 #endif
       
   210 
       
   211     return frame;
   189 }
   212 }
   190 
   213 
   191 /*
   214 /*
   192  * iOS log support.
   215  * iOS log support.
   193  *
   216  *