summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2015-01-19 17:11:26 +0100
committerTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-01-24 13:23:55 +0100
commit29f96fab2424da3748be73348a4093f3a7fff8ac (patch)
treeb2c55782d8b2d82900ea2c48c1c23960f982cd83 /src/plugins
parentd824c7bcc546d80eabcdad34c9e2c0178a734858 (diff)
iOS: Limit auto-rotation to device screen (excludes external screens)
An external screen should always stay in the native orientation of the screen, and not be affected by rotations of the device. If the user requires the external content to follow the device rotation, this can be done explicitly by listening to orientation changes of the main screen, or using QSensors. Change-Id: I3a98655d11915f0db107930e7d97a24417656bc9 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm42
-rw-r--r--src/plugins/platforms/ios/qiosviewcontroller.mm2
2 files changed, 23 insertions, 21 deletions
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index 48be7fc906..68266de5ee 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -227,30 +227,32 @@ void QIOSScreen::updateProperties()
m_geometry = fromCGRect(m_uiScreen.bounds).toRect();
m_availableGeometry = fromCGRect(m_uiScreen.applicationFrame).toRect();
- Qt::ScreenOrientation statusBarOrientation = toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation));
-
- if (QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_8_0) {
- // On iOS < 8.0 the UIScreen geometry is always in portait, and the system applies
- // the screen rotation to the root view-controller's view instead of directly to the
- // screen, like iOS 8 and above does.
- m_geometry = mapBetween(Qt::PortraitOrientation, statusBarOrientation, m_geometry);
- m_availableGeometry = transformBetween(Qt::PortraitOrientation, statusBarOrientation, m_geometry).mapRect(m_availableGeometry);
- }
+ if (m_uiScreen == [UIScreen mainScreen]) {
+ Qt::ScreenOrientation statusBarOrientation = toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation));
+
+ if (QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_8_0) {
+ // On iOS < 8.0 the UIScreen geometry is always in portait, and the system applies
+ // the screen rotation to the root view-controller's view instead of directly to the
+ // screen, like iOS 8 and above does.
+ m_geometry = mapBetween(Qt::PortraitOrientation, statusBarOrientation, m_geometry);
+ m_availableGeometry = transformBetween(Qt::PortraitOrientation, statusBarOrientation, m_geometry).mapRect(m_availableGeometry);
+ }
- QIOSViewController *qtViewController = [m_uiWindow.rootViewController isKindOfClass:[QIOSViewController class]] ?
- static_cast<QIOSViewController *>(m_uiWindow.rootViewController) : nil;
+ QIOSViewController *qtViewController = [m_uiWindow.rootViewController isKindOfClass:[QIOSViewController class]] ?
+ static_cast<QIOSViewController *>(m_uiWindow.rootViewController) : nil;
- if (qtViewController.lockedOrientation) {
- // Setting the statusbar orientation (content orientation) on will affect the screen geometry,
- // which is not what we want. We want to reflect the screen geometry based on the locked orientation,
- // and adjust the available geometry based on the repositioned status bar for the current status
- // bar orientation.
+ if (qtViewController.lockedOrientation) {
+ // Setting the statusbar orientation (content orientation) on will affect the screen geometry,
+ // which is not what we want. We want to reflect the screen geometry based on the locked orientation,
+ // and adjust the available geometry based on the repositioned status bar for the current status
+ // bar orientation.
- Qt::ScreenOrientation lockedOrientation = toQtScreenOrientation(UIDeviceOrientation(qtViewController.lockedOrientation));
- QTransform transform = transformBetween(lockedOrientation, statusBarOrientation, m_geometry).inverted();
+ Qt::ScreenOrientation lockedOrientation = toQtScreenOrientation(UIDeviceOrientation(qtViewController.lockedOrientation));
+ QTransform transform = transformBetween(lockedOrientation, statusBarOrientation, m_geometry).inverted();
- m_geometry = transform.mapRect(m_geometry);
- m_availableGeometry = transform.mapRect(m_availableGeometry);
+ m_geometry = transform.mapRect(m_geometry);
+ m_availableGeometry = transform.mapRect(m_availableGeometry);
+ }
}
if (screen() && screen()->orientation() != orientation())
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm
index 365de974aa..0fb6122960 100644
--- a/src/plugins/platforms/ios/qiosviewcontroller.mm
+++ b/src/plugins/platforms/ios/qiosviewcontroller.mm
@@ -239,7 +239,7 @@
-(BOOL)shouldAutorotate
{
- return !self.lockedOrientation;
+ return m_screen->uiScreen() == [UIScreen mainScreen] && !self.lockedOrientation;
}
#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_6_0)