on xenial help sign in
PhoneStage: focus the new topmost app after the current one closes itself Fixes: 1375267

Approved by: Michael Zanetti

commitf2f86a6950b5d43a5e59db0ba8f46ea3b601f623 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateThu 9 Oct 2014, 14:04 (12 years ago) parent050ec52cdeb74a
3 files changed+32
qml/Stages/PhoneStage.qml+8 qml/Stages/TabletStage.qml+7 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 }
qml/Stages/TabletStage.qml+7
@@ -139,9 +139,16 @@ Rectangle {
139139 if (priv.sideStageAppId == appId) {
140140 priv.sideStageAppId = "";
141141 }
142+
142143 if (ApplicationManager.count == 0) {
143144 spreadView.phase = 0;
144145 spreadView.contentX = -spreadView.shift;
146+ } else if (spreadView.closingIndex == -1) {
147+ // Unless we're closing the app ourselves in the spread,
148+ // lets make sure the spread doesn't mess up by the changing app list.
149+ spreadView.phase = 0;
150+ spreadView.contentX = -spreadView.shift;
151+ ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
145152 }
146153 }
147154 }
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}