on xenial help sign in
PhoneStage: focus the new topmost app after the current one closes itself
commitd717471630d4f272bcc414cfd479ac96657b0f5c authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateTue 7 Oct 2014, 15:18 (12 years ago) parent48f22f3
2 files changed+25
qml/Stages/PhoneStage.qml+8 tests/qmltests/Stages/tst_PhoneStage.qml+17
qml/Stages/PhoneStage.qml+8
@@ -85,6 +85,14 @@ Rectangle {
8585 if (spreadView.closingIndex == -1) {
8686 spreadView.phase = 0;
8787 spreadView.contentX = -spreadView.shift;
88+ focusTopMostApp();
89+ }
90+ }
91+
92+ function focusTopMostApp() {
93+ if (ApplicationManager.count > 0) {
94+ var topmostApp = ApplicationManager.get(0);
95+ ApplicationManager.focusApplication(topmostApp.appId);
8896 }
8997 }
9098 }
tests/qmltests/Stages/tst_PhoneStage.qml+17
@@ -322,5 +322,22 @@ Item {
322322 }
323323 phoneStage.orientation = Qt.PortraitOrientation;
324324 }
325+
326+ function test_focusNewTopMostAppAfterFocusedOneClosesItself() {
327+ addApps(2);
328+
329+ var secondApp = ApplicationManager.get(0);
330+ tryCompare(secondApp, "state", ApplicationInfoInterface.Running);
331+ tryCompare(secondApp, "focused", true);
332+
333+ var firstApp = ApplicationManager.get(1);
334+ tryCompare(firstApp, "state", ApplicationInfoInterface.Suspended);
335+ tryCompare(firstApp, "focused", false);
336+
337+ ApplicationManager.stopApplication(secondApp.appId);
338+
339+ tryCompare(firstApp, "state", ApplicationInfoInterface.Running);
340+ tryCompare(firstApp, "focused", true);
341+ }
325342 }
326343}