on xenial help sign in
merge ~dandrader/unity8/dontRotateDesktop-lp1515977 as a prereq
commite7549d5032a35bd90b110ff9a948eab9f24ae764 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 28 Jan 2016, 11:57 (11 years ago) parent5f24abc093cae7
6 files changed+90−10
qml/Shell.qml+3−3 qml/Stages/AbstractStage.qml+5−1 qml/Stages/DesktopStage.qml+6−1 qml/Stages/PhoneStage.qml+5−1 qml/Stages/TabletStage.qml+5−1 tests/qmltests/tst_OrientedShell.qml+66−3
qml/Shell.qml+3−3
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013-2015 Canonical, Ltd.
2+ * Copyright (C) 2013-2016 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -84,8 +84,8 @@ Item {
8484 return Qt.PrimaryOrientation;
8585 } else if (greeter && greeter.shown) {
8686 return Qt.PrimaryOrientation;
87− } else if (mainApp) {
88− return shell.orientations.map(mainApp.supportedOrientations);
87+ } else if (applicationsDisplayLoader.item) {
88+ return shell.orientations.map(applicationsDisplayLoader.item.supportedOrientations);
8989 } else {
9090 // we just don't care
9191 return Qt.PortraitOrientation
qml/Stages/AbstractStage.qml+5−1
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2015 Canonical, Ltd.
2+ * Copyright (C) 2015-2016 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -44,6 +44,10 @@ Rectangle {
4444 property var mainApp: null
4545 property int mainAppWindowOrientationAngle
4646 property bool orientationChangesEnabled
47+ property int supportedOrientations: Qt.PortraitOrientation
48+ | Qt.LandscapeOrientation
49+ | Qt.InvertedPortraitOrientation
50+ | Qt.InvertedLandscapeOrientation
4751
4852 // Shared code for use in stage implementations
4953 GSettings {
qml/Stages/DesktopStage.qml+6−1
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014-2015 Canonical, Ltd.
2+ * Copyright (C) 2014-2016 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -40,6 +40,11 @@ AbstractStage {
4040 ? ApplicationManager.findApplication(ApplicationManager.focusedApplicationId)
4141 : null
4242
43+ // application windows never rotate independently
44+ mainAppWindowOrientationAngle: shellOrientationAngle
45+
46+ orientationChangesEnabled: true
47+
4348 Connections {
4449 target: ApplicationManager
4550 onApplicationAdded: {
qml/Stages/PhoneStage.qml+5−1
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014-2015 Canonical, Ltd.
2+ * Copyright (C) 2014-2016 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -83,6 +83,10 @@ AbstractStage {
8383 && !(priv.focusedAppDelegate && priv.focusedAppDelegate.xBehavior.running)
8484 && spreadView.phase === 0
8585
86+ supportedOrientations: mainApp ? mainApp.supportedOrientations
87+ : (Qt.PortraitOrientation | Qt.LandscapeOrientation
88+ | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation)
89+
8690 // How far left the stage has been dragged
8791 readonly property real dragProgress: spreadRepeater.count > 0 ? -spreadRepeater.itemAt(0).xTranslate : 0
8892
qml/Stages/TabletStage.qml+5−1
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014-2015 Canonical, Ltd.
2+ * Copyright (C) 2014-2016 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -72,6 +72,10 @@ AbstractStage {
7272
7373 orientationChangesEnabled: priv.mainAppOrientationChangesEnabled
7474
75+ supportedOrientations: mainApp ? mainApp.supportedOrientations
76+ : (Qt.PortraitOrientation | Qt.LandscapeOrientation
77+ | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation)
78+
7579 onWidthChanged: {
7680 spreadView.selectedIndex = -1;
7781 spreadView.phase = 0;
tests/qmltests/tst_OrientedShell.qml+66−3
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2015 Canonical, Ltd.
2+ * Copyright (C) 2015-2016 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -292,6 +292,9 @@ Rectangle {
292292 activeFocusOnPress: false
293293 text: "Usage Mode"
294294 model: ["Staged", "Windowed", "Automatic"]
295+ function selectStaged() {selectedIndex = 0;}
296+ function selectWindowed() {selectedIndex = 1;}
297+ function selectAutomatic() {selectedIndex = 2;}
295298 }
296299 MouseTouchEmulationCheckbox {
297300 checked: true
@@ -393,7 +396,7 @@ Rectangle {
393396 activeFocusOnPress: false
394397 property string prevDevName: "mako"
395398 onClicked: {
396− usageModeSelector.selectedIndex = 2; // "Automatic"
399+ usageModeSelector.selectAutomatic();
397400
398401 if (applicationArguments.deviceName === "desktop") {
399402 applicationArguments.deviceName = prevDevName;
@@ -457,6 +460,8 @@ Rectangle {
457460 signalSpy.signalName = "";
458461
459462 LightDM.Greeter.authenticate(""); // reset greeter
463+
464+ usageModeSelector.selectStaged();
460465 }
461466
462467 function cleanup() {
@@ -997,7 +1002,7 @@ Rectangle {
9971002 }
9981003
9991004 function test_attachRemoveInputDevices() {
1000− usageModeSelector.selectedIndex = 2;
1005+ usageModeSelector.selectAutomatic();
10011006 tryCompare(mockUnity8Settings, "usageMode", "Automatic")
10021007
10031008 loadShell("mako")
@@ -1140,6 +1145,61 @@ Rectangle {
11401145 tryCompare(shell, "transformRotationAngle" , 0);
11411146 }
11421147
1148+ /*
1149+ Regression test for https://launchpad.net/bugs/1515977
1150+
1151+ Preconditions:
1152+ UI in Desktop mode and landscape
1153+
1154+ Steps:
1155+ - Launch a portrait-only application
1156+
1157+ Expected outcome:
1158+ - Shell stays in landscape
1159+
1160+ Buggy outcome:
1161+ - Shell would rotate to portrait as the newly-focused app doesn't support landscape
1162+ */
1163+ function test_portraitOnlyAppInLandscapeDesktop_data() {
1164+ return [
1165+ {tag: "mako", deviceName: "mako"},
1166+ {tag: "manta", deviceName: "manta"},
1167+ {tag: "flo", deviceName: "flo"}
1168+ ];
1169+ }
1170+ function test_portraitOnlyAppInLandscapeDesktop(data) {
1171+ loadShell(data.deviceName);
1172+
1173+ ////
1174+ // setup preconditions (put shell in Desktop mode and landscape)
1175+
1176+ usageModeSelector.selectWindowed();
1177+
1178+ orientedShell.physicalOrientation = orientedShell.orientations.landscape;
1179+ waitUntilShellIsInOrientation(orientedShell.orientations.landscape);
1180+ waitForRotationAnimationsToFinish();
1181+
1182+ ////
1183+ // Launch a portrait-only application
1184+
1185+ var dialerApp = ApplicationManager.startApplication("dialer-app");
1186+ verify(dialerApp);
1187+
1188+ // ensure the mock dialer-app is as we expect
1189+ compare(dialerApp.rotatesWindowContents, false);
1190+ compare(dialerApp.supportedOrientations, Qt.PortraitOrientation | Qt.InvertedPortraitOrientation);
1191+
1192+ waitUntilAppSurfaceShowsUp("dialer-app");
1193+ waitUntilAppWindowCanRotate("dialer-app");
1194+ verify(isAppSurfaceFocused("dialer-app"));
1195+
1196+ ////
1197+ // check outcome (shell should stay in landscape)
1198+
1199+ waitForRotationAnimationsToFinish();
1200+ compare(shell.orientation, orientedShell.orientations.landscape);
1201+ }
1202+
11431203 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
11441204 function rotateTo(angle) {
11451205 switch (angle) {
@@ -1158,7 +1218,10 @@ Rectangle {
11581218 default:
11591219 verify(false);
11601220 }
1221+ waitForRotationAnimationsToFinish();
1222+ }
11611223
1224+ function waitForRotationAnimationsToFinish() {
11621225 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
11631226 verify(rotationStates.d);
11641227 verify(rotationStates.d.stateUpdateTimer);