summaryrefslogtreecommitdiff
path: root/src/video
diff options
context:
space:
mode:
authorAlex Szpakowski <slime73@gmail.com>2017-08-18 23:23:30 -0300
committerAlex Szpakowski <slime73@gmail.com>2017-08-18 23:23:30 -0300
commitdb293a56083c1b71c1428fcb1a41da59e1d274e3 (patch)
tree263b0373dc763a573e7e5dce3000955927979704 /src/video
parent2166ea45692b258681bacfe4bac1f39e01660691 (diff)
downloadsdl-db293a56083c1b71c1428fcb1a41da59e1d274e3.tar.gz
iOS 10: Work around screen bounds orientation bug. Fixes bugs #3465 and #3505.
Diffstat (limited to 'src/video')
-rw-r--r--src/video/uikit/SDL_uikitvideo.m27
-rw-r--r--src/video/uikit/SDL_uikitviewcontroller.m3
2 files changed, 27 insertions, 3 deletions
diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m
index 496cb1f27..617ce093b 100644
--- a/src/video/uikit/SDL_uikitvideo.m
+++ b/src/video/uikit/SDL_uikitvideo.m
@@ -176,16 +176,39 @@ UIKit_IsSystemVersionAtLeast(double version)
CGRect
UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen)
{
+ CGRect frame = screen.bounds;
+
#if !TARGET_OS_TV && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0)
BOOL hasiOS7 = UIKit_IsSystemVersionAtLeast(7.0);
/* The view should always show behind the status bar in iOS 7+. */
if (!hasiOS7 && !(window->flags & (SDL_WINDOW_BORDERLESS|SDL_WINDOW_FULLSCREEN))) {
- return screen.applicationFrame;
+ frame = screen.applicationFrame;
+ }
+#endif
+
+#if !TARGET_OS_TV
+ /* iOS 10 seems to have a bug where, in certain conditions, putting the
+ * device to sleep with the a landscape-only app open, re-orienting the
+ * device to portrait, and turning it back on will result in the screen
+ * bounds returning portrait orientation despite the app being in landscape.
+ * This is a workaround until a better solution can be found.
+ * https://bugzilla.libsdl.org/show_bug.cgi?id=3505
+ * https://bugzilla.libsdl.org/show_bug.cgi?id=3465
+ * https://forums.developer.apple.com/thread/65337 */
+ if (UIKit_IsSystemVersionAtLeast(8.0)) {
+ UIInterfaceOrientation orient = [UIApplication sharedApplication].statusBarOrientation;
+ BOOL isLandscape = UIInterfaceOrientationIsLandscape(orient);
+
+ if (isLandscape != (frame.size.width > frame.size.height)) {
+ float height = frame.size.width;
+ frame.size.width = frame.size.height;
+ frame.size.height = height;
+ }
}
#endif
- return screen.bounds;
+ return frame;
}
/*
diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m
index 513da8779..6c3c23bbe 100644
--- a/src/video/uikit/SDL_uikitviewcontroller.m
+++ b/src/video/uikit/SDL_uikitviewcontroller.m
@@ -293,8 +293,9 @@ SDL_AppleTVControllerUIHintChanged(void *userdata, const char *name, const char
- (void)keyboardWillHide:(NSNotification *)notification
{
- if (!rotatingOrientation)
+ if (!rotatingOrientation) {
SDL_StopTextInput();
+ }
[self setKeyboardHeight:0];
}