on xenial help sign in
Dismiss the apps spread if greeter gets shown

Enables Shell to rotate itself back into place while greeter is shown because PhoneStage doesn't allow rotations while the apps spread is open Fixes: #1471609 Approved by: Michael Zanetti

commit993899a52e657f201f5bddb6badce0aab323505d authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateMon 13 Jul 2015, 14:17 (11 years ago) parentc86703136b4f8f
3 files changed+62−2
qml/Shell.qml+1−1 qml/Stages/PhoneStage.qml+16−1 tests/qmltests/tst_OrientedShell.qml+45
qml/Shell.qml+1−1
@@ -305,7 +305,7 @@ Item {
305305 Binding {
306306 target: applicationsDisplayLoader.item
307307 property: "spreadEnabled"
308− value: tutorial.spreadEnabled && (!greeter || !greeter.hasLockedApp)
308+ value: tutorial.spreadEnabled && (!greeter || (!greeter.hasLockedApp && !greeter.shown))
309309 }
310310 Binding {
311311 target: applicationsDisplayLoader.item
qml/Stages/PhoneStage.qml+16−1
@@ -51,6 +51,14 @@ Rectangle {
5151 spreadView.contentX = -spreadView.shift;
5252 }
5353 }
54+ onSpreadEnabledChanged: {
55+ if (!spreadEnabled) {
56+ // reset. go back to display the focused app
57+ spreadView.selectedIndex = -1;
58+ spreadView.phase = 0;
59+ spreadView.contentX = -spreadView.shift;
60+ }
61+ }
5462 function updateFocusedAppOrientation() {
5563 if (spreadRepeater.count > 0) {
5664 spreadRepeater.itemAt(0).matchShellOrientation();
@@ -281,7 +289,13 @@ Rectangle {
281289
282290 switch (phase) {
283291 case 0:
284− if (shiftedContentX > width * positionMarker2) {
292+ // the "spreadEnabled" part is because when code does "phase = 0; contentX = -shift" to
293+ // dismiss the spread because spreadEnabled went to false, for some reason, during tests,
294+ // Flickable might jump in and change contentX value back, causing the code below to do
295+ // "phase = 1" which will make the spread stay.
296+ // It sucks that we have no control whatsoever over whether or when Flickable animates its
297+ // contentX.
298+ if (root.spreadEnabled && shiftedContentX > width * positionMarker2) {
285299 phase = 1;
286300 }
287301 break;
@@ -456,6 +470,7 @@ Rectangle {
456470 enabled: root.spreadEnabled &&
457471 !spreadView.active &&
458472 !snapAnimation.running &&
473+ !spreadDragArea.pressed &&
459474 priv.animateX &&
460475 !root.beingResized
461476 UbuntuNumberAnimation {
tests/qmltests/tst_OrientedShell.qml+45
@@ -951,6 +951,51 @@ Rectangle {
951951 tryCompare(mockOskSettings, "stayHidden", false);
952952 }
953953
954+ /*
955+ Regression test for https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1471609
956+
957+ Steps:
958+ - Open an app which can rotate
959+ - Rotate the phone to landscape
960+ - Open the app spread
961+ - Press the power button while the app spread is open
962+ - Wait a bit and press power button again
963+
964+ Expected outcome:
965+ You see greeter in portrat (ie, primary orientation)
966+
967+ Actual outcome:
968+ You see greeter in landscape
969+
970+ Comments:
971+ Greeter supports only the primary orientation (portrait in phones) but
972+ the stage doesn't allow orientation changes while the apps spread is open,
973+ hence the bug.
974+ */
975+ function test_phoneWithSpreadInLandscapeWhenGreeterShowsUp() {
976+ loadShell("mako");
977+
978+ var gmailApp = ApplicationManager.startApplication("gmail-webapp");
979+ verify(gmailApp);
980+
981+ // ensure the mock gmail-webapp is as we expect
982+ compare(gmailApp.rotatesWindowContents, false);
983+ compare(gmailApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
984+ | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
985+
986+ // wait until it's able to rotate
987+ tryCompare(shell, "orientationChangesEnabled", true);
988+
989+ rotateTo(90);
990+ tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle + 90);
991+
992+ performEdgeSwipeToShowAppSpread();
993+
994+ showGreeter();
995+
996+ tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
997+ }
998+
954999 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
9551000 function rotateTo(angle) {
9561001 switch (angle) {