From 4f0cd0693a3aadbf3277dba0eb902db2c78f60cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 10 Dec 2013 18:30:07 +0100 Subject: iOS: Calculate screen (available) geometry using [UIView convertRect] Instead of custom logic to detect portrait/landscape and the height of the status bar. The latter would fail when the statusbar/orientation was set explicitly through [UIApplication setStatusBarOrientation], as the statusbar would not follow the normal behavior of covering the top part of the screen. The new code also handles upside-down portrait mode, as well as iOS8's behavior of reporting screen bounds and application frame in interface orientation instead of device orientation. Change-Id: I54e3b99246a32e17aaba13960f456fa823768fd8 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiosscreen.mm | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/plugins/platforms/ios') diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index eb3b7e3c44..86ef71c914 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -241,17 +241,10 @@ void QIOSScreen::updateProperties() QRect previousGeometry = m_geometry; QRect previousAvailableGeometry = m_availableGeometry; - bool inPortrait = UIInterfaceOrientationIsPortrait(m_uiWindow.rootViewController.interfaceOrientation); - m_geometry = inPortrait ? fromCGRect(m_uiScreen.bounds).toRect() - : QRect(m_uiScreen.bounds.origin.x, m_uiScreen.bounds.origin.y, - m_uiScreen.bounds.size.height, m_uiScreen.bounds.size.width); + UIView *rootView = m_uiWindow.rootViewController.view; - m_availableGeometry = m_geometry; - - CGSize applicationFrameSize = m_uiScreen.applicationFrame.size; - int statusBarHeight = m_geometry.height() - (inPortrait ? applicationFrameSize.height : applicationFrameSize.width); - - m_availableGeometry.adjust(0, statusBarHeight, 0, 0); + m_geometry = fromCGRect([rootView convertRect:m_uiScreen.bounds fromView:m_uiWindow]).toRect(); + m_availableGeometry = fromCGRect([rootView convertRect:m_uiScreen.applicationFrame fromView:m_uiWindow]).toRect(); if (m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry) { const qreal millimetersPerInch = 25.4; -- cgit v1.2.3