on xenial help sign in
Return focus to the application after a tusted session overlay is closing. Fixes: 1381292

Approved by: Michael Zanetti, PS Jenkins bot

commitdca0c146f171475007a954df3623007ca6fa4d9f authorJosh Arenson <joshua.arenson@canonical.com> dateMon 17 Nov 2014, 13:46 (12 years ago) parentc26442ad791c2b
3 files changed+40−1
qml/Stages/SessionContainer.qml+4 tests/mocks/Unity/Application/Session.h+1−1 tests/qmltests/Stages/tst_SessionContainer.qml+35
qml/Stages/SessionContainer.qml+4
@@ -69,6 +69,10 @@ Item {
6969 target: item; when: item
7070 property: "orientation"; value: root.orientation
7171 }
72+
73+ Component.onDestruction: {
74+ root.session.surface.forceActiveFocus();
75+ }
7276 }
7377 }
7478
tests/mocks/Unity/Application/Session.h+1−1
@@ -56,7 +56,7 @@ public:
5656
5757 Q_INVOKABLE void addChildSession(Session* session);
5858 void insertChildSession(uint index, Session* session);
59− void removeChildSession(Session* session);
59+ Q_INVOKABLE void removeChildSession(Session* session);
6060
6161Q_SIGNALS:
6262 void applicationChanged(ApplicationInfo*);
tests/qmltests/Stages/tst_SessionContainer.qml+35
@@ -185,6 +185,41 @@ Rectangle {
185185 tryCompare(sessionSpy, "count", data.count);
186186 }
187187
188+ function test_childSessionDestructionReturnsFocusToSiblingOrParent() {
189+ sessionCheckbox.checked = true;
190+ var sessionContainer = sessionContainerLoader.item;
191+ compare(sessionContainer.childSessions.count(), 0);
192+
193+ sessionContainer.interactive = true;
194+
195+ var i;
196+ var sessions = [];
197+ // 3 sessions should cover all edge cases
198+ for(i = 0; i < 3; i++) {
199+ var a_session = ApplicationTest.addChildSession(
200+ sessionContainer.session, "gallery"
201+ )
202+
203+ a_session.createSurface();
204+ sessionContainer.session.addChildSession(a_session);
205+ compare(sessionContainer.childSessions.count(), i + 1);
206+
207+ sessions.push(a_session);
208+ }
209+
210+ var a_session;
211+ while(a_session = sessions.pop()) {
212+ a_session.surface.forceActiveFocus();
213+ compare(a_session.surface.activeFocus, true);
214+
215+ var parentSession = a_session.parentSession;
216+ sessionContainer.session.removeChildSession(a_session);
217+ compare(a_session.surface.activeFocus, false);
218+
219+ compare(parentSession.surface.activeFocus, true);
220+ }
221+ }
222+
188223 function test_nestedChildSessions_data() {
189224 return [ { tag: "depth=2", depth: 2 },
190225 { tag: "depth=8", depth: 8 }