summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qiosscreen.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2015-01-15 17:19:07 +0100
committerTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-01-22 00:30:09 +0100
commitbe6c50a2511fc95b165b702cae1f54a9e06fa67c (patch)
tree92ee31250b9982350d1b4cf5a2bbdbfa6f266129 /src/plugins/platforms/ios/qiosscreen.mm
parentcec7dcc723cd234c9bbb9d7df78fd96820523e87 (diff)
iOS: Make screen orientation reporting more consistent
Change-Id: Ic21efb939639711c4071161e3c742525a55d41be Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/ios/qiosscreen.mm')
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index 0713a95522..e9b2c546d4 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -143,17 +143,7 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
- (void) orientationChanged:(NSNotification *)notification
{
Q_UNUSED(notification);
-
- UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
- switch (deviceOrientation) {
- case UIDeviceOrientationFaceUp:
- case UIDeviceOrientationFaceDown:
- // We ignore these events, as iOS will send events with the 'regular'
- // orientations alongside these two orientations.
- return;
- default:
- QWindowSystemInterface::handleScreenOrientationChange(m_screen->screen(), m_screen->orientation());
- }
+ m_screen->updateProperties();
}
@end
@@ -261,6 +251,14 @@ void QIOSScreen::updateProperties()
m_availableGeometry = transform.mapRect(m_availableGeometry);
}
+ if (screen() && screen()->orientation() != orientation())
+ QWindowSystemInterface::handleScreenOrientationChange(screen(), orientation());
+
+ // Note: The screen orientation change and the geometry changes are not atomic, so when
+ // the former is emitted, the latter has not been reported and reflected in the QScreen
+ // API yet. But conceptually it makes sense that the orientation update happens first,
+ // and the geometry updates caused by auto-rotation happen after that.
+
if (m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry) {
const qreal millimetersPerInch = 25.4;
m_physicalSize = QSizeF(m_geometry.size()) / m_unscaledDpi * millimetersPerInch;
@@ -331,6 +329,14 @@ Qt::ScreenOrientation QIOSScreen::orientation() const
if (deviceOrientation == UIDeviceOrientationUnknown)
deviceOrientation = UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation);
+ // If the device reports face up or face down orientations, we can't map
+ // them to Qt orientations, so we pretend we're in the same orientation
+ // as before.
+ if (deviceOrientation == UIDeviceOrientationFaceUp || deviceOrientation == UIDeviceOrientationFaceDown) {
+ Q_ASSERT(screen());
+ return screen()->orientation();
+ }
+
return toQtScreenOrientation(deviceOrientation);
}
@@ -341,6 +347,7 @@ void QIOSScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask)
m_orientationListener = 0;
} else if (!m_orientationListener) {
m_orientationListener = [[QIOSOrientationListener alloc] initWithQIOSScreen:this];
+ updateProperties();
}
}