on xenial help sign in
merge prereq
commit644acba357774ce3f9d5dcc096427060c0c16acb authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 3 Jun 2016, 18:42 (10 years ago) parent6ddaad5eeab2a9
5 files changed+77−20
qml/Stages/ApplicationWindow.qml+25−9 tests/mocks/Unity/Application/MirSurfaceListModel.cpp+11−1 tests/mocks/Unity/Application/MirSurfaceListModel.h+1 tests/qmltests/Stages/ApplicationCheckBox.qml+1−1 tests/qmltests/Stages/tst_ApplicationWindow.qml+39−9
qml/Stages/ApplicationWindow.qml+25−9
@@ -121,15 +121,12 @@ FocusScope {
121121
122122 property bool surfaceOldEnoughToBeResized: false
123123
124− property var focusedSurface: {
125− if (promptSurfacesRepeater.count == 0) {
126− return surfaceContainer;
127− } else {
128− return promptSurfacesRepeater.itemAt(promptSurfacesRepeater.count - 1);
129− }
130− }
124+ property Item focusedSurface: promptSurfacesRepeater.count === 0 ? surfaceContainer
125+ : promptSurfacesRepeater.first
131126 onFocusedSurfaceChanged: {
132− focusedSurface.focus = true;
127+ if (focusedSurface) {
128+ focusedSurface.focus = true;
129+ }
133130 }
134131 }
135132
@@ -158,6 +155,7 @@ FocusScope {
158155 objectName: "screenshotImage"
159156 anchors.fill: parent
160157 antialiasing: !root.interactive
158+ z: 1
161159
162160 function take() {
163161 // Save memory by using a half-resolution (thus quarter size) screenshot.
@@ -175,6 +173,7 @@ FocusScope {
175173 visible: active
176174 active: false
177175 anchors.fill: parent
176+ z: screenshotImage.z + 1
178177 sourceComponent: Component {
179178 Splash {
180179 id: splash
@@ -191,6 +190,7 @@ FocusScope {
191190
192191 SurfaceContainer {
193192 id: surfaceContainer
193+ z: splashLoader.z + 1
194194 requestedWidth: root.requestedWidth
195195 requestedHeight: root.requestedHeight
196196 surfaceOrientationAngle: application && application.rotatesWindowContents ? root.surfaceOrientationAngle : 0
@@ -208,12 +208,28 @@ FocusScope {
208208 }
209209 }
210210 delegate: SurfaceContainer {
211− interactive: index == (promptSurfacesRepeater.count - 1) && root.interactive
211+ id: promptSurfaceContainer
212+ interactive: index === 0 && root.interactive
212213 surface: model.surface
213214 width: root.width
214215 height: root.height
215216 isPromptSurface: true
217+ z: surfaceContainer.z + (promptSurfacesRepeater.count - index)
218+ property int index: model.index
219+ onIndexChanged: updateFirst()
220+ Component.onCompleted: updateFirst()
221+ function updateFirst() {
222+ if (index === 0) {
223+ promptSurfacesRepeater.first = promptSurfaceContainer;
224+ }
225+ }
226+ }
227+ onCountChanged: {
228+ if (count === 0) {
229+ first = null;
230+ }
216231 }
232+ property Item first: null
217233 }
218234
219235 // SurfaceContainer size drives ApplicationWindow size
tests/mocks/Unity/Application/MirSurfaceListModel.cpp+11−1
@@ -72,6 +72,16 @@ void MirSurfaceListModel::appendSurface(MirSurface *surface)
7272 }
7373}
7474
75+void MirSurfaceListModel::prependSurface(MirSurface *surface)
76+{
77+ beginInsertRows(QModelIndex(), 0, 0);
78+ m_surfaceList.prepend(surface);
79+ connectSurface(surface);
80+ endInsertRows();
81+ Q_EMIT countChanged(m_surfaceList.count());
82+ Q_EMIT firstChanged();
83+}
84+
7585void MirSurfaceListModel::connectSurface(MirSurface *surface)
7686{
7787 connect(surface, &MirSurface::raiseRequested, this, [this, surface](){ this->raise(surface); });
@@ -143,7 +153,7 @@ MirSurfaceInterface *MirSurfaceListModel::createSurface()
143153 Mir::RestoredState,
144154 screenshotUrl);
145155
146− appendSurface(surface);
156+ prependSurface(surface);
147157
148158 return surface;
149159}
tests/mocks/Unity/Application/MirSurfaceListModel.h+1
@@ -49,6 +49,7 @@ public:
4949 Q_INVOKABLE unity::shell::application::MirSurfaceInterface *createSurface();
5050
5151private:
52+ void prependSurface(MirSurface *surface);
5253 void raise(MirSurface *surface);
5354 void moveSurface(int from, int to);
5455 void connectSurface(MirSurface *surface);
tests/qmltests/Stages/ApplicationCheckBox.qml+1−1
@@ -156,7 +156,7 @@ Column {
156156 width: height
157157 height: promptsLabel.height * 0.7
158158 anchors.verticalCenter: parent.verticalCenter
159− onClicked: d.application.promptSurfaceList.get(d.application.promptSurfaceList.count - 1).close()
159+ onClicked: d.application.promptSurfaceList.get(0).close()
160160 enabled: d.application && d.application.promptSurfaceList.count > 0
161161 Label { text: "➖"; anchors.centerIn: parent; enabled: parent.enabled }
162162 }
tests/qmltests/Stages/tst_ApplicationWindow.qml+39−9
@@ -106,7 +106,7 @@ Rectangle {
106106 enabled: parent.promptSurfaceList !== null && parent.promptSurfaceList.count > 0
107107 activeFocusOnPress: false
108108 text: "Remove"
109− onClicked: { parent.promptSurfaceList.get(parent.promptSurfaceList.count - 1).close(); }
109+ onClicked: { parent.promptSurfaceList.get(0).close(); }
110110 }
111111
112112 Button {
@@ -449,20 +449,21 @@ Rectangle {
449449 for (i = 0; i < 3; i++) {
450450 promptSurfaceList.createSurface();
451451 compare(promptSurfaces.count, i+1);
452− waitUntilSurfaceContainerStopsAnimating(promptSurfaces.itemAt(promptSurfaces.count - 1));
452+ waitUntilSurfaceContainerStopsAnimating(promptSurfaces.itemAt(0));
453453 }
454454
455− for (i = 2; i >= 0; --i) {
456− var promptSurface = promptSurfaceList.get(i);
455+ for (i = 3; i > 0; --i) {
456+ var promptSurface = promptSurfaceList.get(0);
457457 compare(promptSurface.activeFocus, true);
458458
459459 promptSurface.close();
460− tryCompareFunction(function() { return promptSurfaces.count; }, i);
460+ promptSurface = null;
461+ tryCompareFunction(function() { return promptSurfaces.count; }, i-1);
461462
462− if (i > 0) {
463− // active focus should have gone to the yongest remaining sibling
464− var previousPromptSurface = promptSurfaceList.get(i-1);
465− tryCompare(previousPromptSurface, "activeFocus", true);
463+ if (promptSurfaces.count > 0) {
464+ // active focus should have gone to the new head of the list
465+ promptSurface = promptSurfaceList.get(0);
466+ tryCompare(promptSurface, "activeFocus", true);
466467 } else {
467468 // active focus should have gone to the application surface
468469 tryCompare(applicationWindow.surface, "activeFocus", true);
@@ -498,5 +499,34 @@ Rectangle {
498499 delegate.surface.close();
499500 tryCompare(promptSurfaces, "count", 0);
500501 }
502+
503+ // Check that the z value of SurfaceContainers for prompt surfaces go from highest
504+ // for index 0 to lowest for the last index in the prompt surface list.
505+ // Regression test for https://bugs.launchpad.net/bugs/1586219
506+ function test_promptSurfacesZOrdering() {
507+ var promptSurfaceList = root.fakeApplication.promptSurfaceList;
508+ var promptSurfaces = testCase.findChild(applicationWindow, "promptSurfacesRepeater");
509+
510+ promptSurfaceList.createSurface();
511+
512+ for (var i = 2; i <= 3; i++) {
513+ promptSurfaceList.createSurface();
514+ tryCompare(promptSurfaces, "count", i);
515+ waitUntilSurfaceContainerStopsAnimating(promptSurfaces.itemAt(0));
516+
517+ for (var j = 1; j < promptSurfaces.count; j++) {
518+ var delegate = promptSurfaces.itemAt(j);
519+ var previousDelegate = promptSurfaces.itemAt(j-1);
520+ verify(previousDelegate.z > delegate.z);
521+ }
522+ }
523+
524+ // clean up
525+ while (promptSurfaceList.count > 0) {
526+ var currentCount = promptSurfaceList.count;
527+ promptSurfaceList.get(0).close();
528+ tryCompare(promptSurfaceList, "count", currentCount - 1);
529+ }
530+ }
501531 }
502532}