Merge lp:~dandrader/unity8/promptsZOrder into lp:unity8

Proposed by Daniel d'Andrada on 2016-06-01
Status: Merged
Approved by: Nick Dedekind on 2016-06-02
Approved revision: 2444
Merged at revision: 2449
Proposed branch: lp:~dandrader/unity8/promptsZOrder
Merge into: lp:unity8
Diff against target: 212 lines (+78/-21)
5 files modified
qml/Stages/ApplicationWindow.qml (+26/-10)
tests/mocks/Unity/Application/MirSurfaceListModel.cpp (+11/-1)
tests/mocks/Unity/Application/MirSurfaceListModel.h (+1/-0)
tests/qmltests/Stages/ApplicationCheckBox.qml (+1/-1)
tests/qmltests/Stages/tst_ApplicationWindow.qml (+39/-9)
To merge this branch: bzr merge lp:~dandrader/unity8/promptsZOrder
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Needs Fixing on 2016-06-06
Nick Dedekind (community) 2016-06-01 Approve on 2016-06-02
Review via email: mp+296243@code.launchpad.net

Commit Message

Fix Z-ordering of prompt surfaces

And also update Unity.Application mock to prepend instead of append new
prompt surfaces, like qtmir does.

Description of the Change

* Are there any related MPs required for this MP to build/function as expected? Please list.
Not a requirement technically speaking (as in it works without it), but makes sense to have it as well:
https://code.launchpad.net/~dandrader/qtmir/fixFirstChangedOnPrepend/+merge/296313

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Not applicable

* If you changed the UI, has there been a design review?
Not applicable

To post a comment you must log in.
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2410
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1328/
Executed test runs:
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build/1766/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1792
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1739
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1739
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1739
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1732/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1732/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1732/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1732/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1732/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1732/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1732/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1732/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1732/console

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1328/rebuild

review: Needs Fixing (continuous-integration)
lp:~dandrader/unity8/promptsZOrder updated on 2016-06-02
2441. By Launchpad Translations on behalf of unity-team on 2016-06-02

Launchpad automatic translations update.

Nick Dedekind (nick-dedekind) wrote :

small comment, rest is fine.

review: Needs Fixing
Daniel d'Andrada (dandrader) wrote :

On 02/06/2016 08:15, Nick Dedekind wrote:
> prepending will always change "first". Might want to check qtmir to see if this matches if you copied.

Fixed. qtmir had the same problem even though I didn't copy-pasted from
it (see its url in the updated MP description).

lp:~dandrader/unity8/promptsZOrder updated on 2016-06-02
2442. By Daniel d'Andrada on 2016-06-02

Fix Z-ordering of prompt surfaces

And also update Unity.Application mock to prepend instead of append new
prompt surfaces, like qtmir does.

2443. By Daniel d'Andrada on 2016-06-02

Fix emission of firstChanged() on prepend

2444. By Daniel d'Andrada on 2016-06-02

Write regression test and fix/update existing one

Daniel d'Andrada (dandrader) wrote :

Wrote regression test and rebased on top of latest trunk

Nick Dedekind (nick-dedekind) wrote :

Fine now. Tests succeed.

review: Approve
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2444
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1403/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/1869
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/951
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/951
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=qmluitests.sh/951
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1895
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1832
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1832
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1832
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1823
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1823
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1823
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1823
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1823
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1823
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1823
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1823
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1823
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1823/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1403/rebuild

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Stages/ApplicationWindow.qml'
2--- qml/Stages/ApplicationWindow.qml 2016-05-17 19:56:05 +0000
3+++ qml/Stages/ApplicationWindow.qml 2016-06-02 12:31:17 +0000
4@@ -121,15 +121,12 @@
5
6 property bool surfaceOldEnoughToBeResized: false
7
8- property var focusedSurface: {
9- if (promptSurfacesRepeater.count == 0) {
10- return surfaceContainer;
11- } else {
12- return promptSurfacesRepeater.itemAt(promptSurfacesRepeater.count - 1);
13- }
14- }
15+ property Item focusedSurface: promptSurfacesRepeater.count === 0 ? surfaceContainer
16+ : promptSurfacesRepeater.first
17 onFocusedSurfaceChanged: {
18- focusedSurface.focus = true;
19+ if (focusedSurface) {
20+ focusedSurface.focus = true;
21+ }
22 }
23 }
24
25@@ -158,6 +155,7 @@
26 objectName: "screenshotImage"
27 anchors.fill: parent
28 antialiasing: !root.interactive
29+ z: 1
30
31 function take() {
32 // Save memory by using a half-resolution (thus quarter size) screenshot.
33@@ -175,6 +173,7 @@
34 visible: active
35 active: false
36 anchors.fill: parent
37+ z: screenshotImage.z + 1
38 sourceComponent: Component {
39 Splash {
40 id: splash
41@@ -191,6 +190,7 @@
42
43 SurfaceContainer {
44 id: surfaceContainer
45+ z: splashLoader.z + 1
46 requestedWidth: root.requestedWidth
47 requestedHeight: root.requestedHeight
48 surfaceOrientationAngle: application && application.rotatesWindowContents ? root.surfaceOrientationAngle : 0
49@@ -208,12 +208,28 @@
50 }
51 }
52 delegate: SurfaceContainer {
53- interactive: index == (promptSurfacesRepeater.count - 1) && root.interactive
54+ id: promptSurfaceContainer
55+ interactive: index === 0 && root.interactive
56 surface: model.surface
57 width: root.width
58 height: root.height
59 isPromptSurface: true
60- }
61+ z: surfaceContainer.z + (promptSurfacesRepeater.count - index)
62+ property int index: model.index
63+ onIndexChanged: updateFirst()
64+ Component.onCompleted: updateFirst()
65+ function updateFirst() {
66+ if (index === 0) {
67+ promptSurfacesRepeater.first = promptSurfaceContainer;
68+ }
69+ }
70+ }
71+ onCountChanged: {
72+ if (count === 0) {
73+ first = null;
74+ }
75+ }
76+ property Item first: null
77 }
78
79 // SurfaceContainer size drives ApplicationWindow size
80
81=== modified file 'tests/mocks/Unity/Application/MirSurfaceListModel.cpp'
82--- tests/mocks/Unity/Application/MirSurfaceListModel.cpp 2016-05-17 19:56:10 +0000
83+++ tests/mocks/Unity/Application/MirSurfaceListModel.cpp 2016-06-02 12:31:17 +0000
84@@ -72,6 +72,16 @@
85 }
86 }
87
88+void MirSurfaceListModel::prependSurface(MirSurface *surface)
89+{
90+ beginInsertRows(QModelIndex(), 0, 0);
91+ m_surfaceList.prepend(surface);
92+ connectSurface(surface);
93+ endInsertRows();
94+ Q_EMIT countChanged();
95+ Q_EMIT firstChanged();
96+}
97+
98 void MirSurfaceListModel::connectSurface(MirSurface *surface)
99 {
100 connect(surface, &MirSurface::raiseRequested, this, [this, surface](){ this->raise(surface); });
101@@ -143,7 +153,7 @@
102 Mir::RestoredState,
103 screenshotUrl);
104
105- appendSurface(surface);
106+ prependSurface(surface);
107
108 return surface;
109 }
110
111=== modified file 'tests/mocks/Unity/Application/MirSurfaceListModel.h'
112--- tests/mocks/Unity/Application/MirSurfaceListModel.h 2016-05-17 19:25:23 +0000
113+++ tests/mocks/Unity/Application/MirSurfaceListModel.h 2016-06-02 12:31:17 +0000
114@@ -49,6 +49,7 @@
115 Q_INVOKABLE unity::shell::application::MirSurfaceInterface *createSurface();
116
117 private:
118+ void prependSurface(MirSurface *surface);
119 void raise(MirSurface *surface);
120 void moveSurface(int from, int to);
121 void connectSurface(MirSurface *surface);
122
123=== modified file 'tests/qmltests/Stages/ApplicationCheckBox.qml'
124--- tests/qmltests/Stages/ApplicationCheckBox.qml 2016-05-17 19:56:10 +0000
125+++ tests/qmltests/Stages/ApplicationCheckBox.qml 2016-06-02 12:31:17 +0000
126@@ -156,7 +156,7 @@
127 width: height
128 height: promptsLabel.height * 0.7
129 anchors.verticalCenter: parent.verticalCenter
130- onClicked: d.application.promptSurfaceList.get(d.application.promptSurfaceList.count - 1).close()
131+ onClicked: d.application.promptSurfaceList.get(0).close()
132 enabled: d.application && d.application.promptSurfaceList.count > 0
133 Label { text: "➖"; anchors.centerIn: parent; enabled: parent.enabled }
134 }
135
136=== modified file 'tests/qmltests/Stages/tst_ApplicationWindow.qml'
137--- tests/qmltests/Stages/tst_ApplicationWindow.qml 2016-05-17 19:25:23 +0000
138+++ tests/qmltests/Stages/tst_ApplicationWindow.qml 2016-06-02 12:31:17 +0000
139@@ -106,7 +106,7 @@
140 enabled: parent.promptSurfaceList !== null && parent.promptSurfaceList.count > 0
141 activeFocusOnPress: false
142 text: "Remove"
143- onClicked: { parent.promptSurfaceList.get(parent.promptSurfaceList.count - 1).close(); }
144+ onClicked: { parent.promptSurfaceList.get(0).close(); }
145 }
146
147 Button {
148@@ -449,20 +449,21 @@
149 for (i = 0; i < 3; i++) {
150 promptSurfaceList.createSurface();
151 compare(promptSurfaces.count, i+1);
152- waitUntilSurfaceContainerStopsAnimating(promptSurfaces.itemAt(promptSurfaces.count - 1));
153+ waitUntilSurfaceContainerStopsAnimating(promptSurfaces.itemAt(0));
154 }
155
156- for (i = 2; i >= 0; --i) {
157- var promptSurface = promptSurfaceList.get(i);
158+ for (i = 3; i > 0; --i) {
159+ var promptSurface = promptSurfaceList.get(0);
160 compare(promptSurface.activeFocus, true);
161
162 promptSurface.close();
163- tryCompareFunction(function() { return promptSurfaces.count; }, i);
164+ promptSurface = null;
165+ tryCompareFunction(function() { return promptSurfaces.count; }, i-1);
166
167- if (i > 0) {
168- // active focus should have gone to the yongest remaining sibling
169- var previousPromptSurface = promptSurfaceList.get(i-1);
170- tryCompare(previousPromptSurface, "activeFocus", true);
171+ if (promptSurfaces.count > 0) {
172+ // active focus should have gone to the new head of the list
173+ promptSurface = promptSurfaceList.get(0);
174+ tryCompare(promptSurface, "activeFocus", true);
175 } else {
176 // active focus should have gone to the application surface
177 tryCompare(applicationWindow.surface, "activeFocus", true);
178@@ -498,5 +499,34 @@
179 delegate.surface.close();
180 tryCompare(promptSurfaces, "count", 0);
181 }
182+
183+ // Check that the z value of SurfaceContainers for prompt surfaces go from highest
184+ // for index 0 to lowest for the last index in the prompt surface list.
185+ // Regression test for https://bugs.launchpad.net/bugs/1586219
186+ function test_promptSurfacesZOrdering() {
187+ var promptSurfaceList = root.fakeApplication.promptSurfaceList;
188+ var promptSurfaces = testCase.findChild(applicationWindow, "promptSurfacesRepeater");
189+
190+ promptSurfaceList.createSurface();
191+
192+ for (var i = 2; i <= 3; i++) {
193+ promptSurfaceList.createSurface();
194+ tryCompare(promptSurfaces, "count", i);
195+ waitUntilSurfaceContainerStopsAnimating(promptSurfaces.itemAt(0));
196+
197+ for (var j = 1; j < promptSurfaces.count; j++) {
198+ var delegate = promptSurfaces.itemAt(j);
199+ var previousDelegate = promptSurfaces.itemAt(j-1);
200+ verify(previousDelegate.z > delegate.z);
201+ }
202+ }
203+
204+ // clean up
205+ while (promptSurfaceList.count > 0) {
206+ var currentCount = promptSurfaceList.count;
207+ promptSurfaceList.get(0).close();
208+ tryCompare(promptSurfaceList, "count", currentCount - 1);
209+ }
210+ }
211 }
212 }

Subscribers

People subscribed via source and target branches