on xenial help sign in
PhoneStage: focus the new topmost app after the current one closes itself Fixes: 1375267
f2f86a6Daniel d'Andrada
qml/Stages/PhoneStage.qml+8
@@ -85,6 +85,14 @@ Rectangle {
85 if (spreadView.closingIndex == -1) {
85 if (spreadView.closingIndex == -1) {
86 spreadView.phase = 0;
86 spreadView.phase = 0;
87 spreadView.contentX = -spreadView.shift;
87 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);
88 }
96 }
89 }
97 }
90 }
98 }
qml/Stages/TabletStage.qml+7
@@ -139,9 +139,16 @@ Rectangle {
139 if (priv.sideStageAppId == appId) {
139 if (priv.sideStageAppId == appId) {
140 priv.sideStageAppId = "";
140 priv.sideStageAppId = "";
141 }
141 }
142+
142 if (ApplicationManager.count == 0) {
143 if (ApplicationManager.count == 0) {
143 spreadView.phase = 0;
144 spreadView.phase = 0;
144 spreadView.contentX = -spreadView.shift;
145 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);
145 }
152 }
146 }
153 }
147 }
154 }
tests/qmltests/Stages/tst_PhoneStage.qml+17
@@ -322,5 +322,22 @@ Item {
322 }
322 }
323 phoneStage.orientation = Qt.PortraitOrientation;
323 phoneStage.orientation = Qt.PortraitOrientation;
324 }
324 }
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+ }
325 }
342 }
326}
343}