on xenial help sign in
addressing review comments
commitd4c3c6ddd3bf03bc1710f8a3aaeca275b8533cc3 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateThu 14 Aug 2014, 15:23 (12 years ago) parent845cc0e
7 files changed+91−71
qml/Stages/ApplicationWindow.qml+40−35 qml/Stages/PhoneStage.qml+4−4 qml/Stages/SpreadDelegate.qml+1−2 qml/Stages/TabletStage.qml+12−3 qml/Stages/TransformedTabletSpreadDelegate.qml+2−2 tests/mocks/Unity/Application/ApplicationInfo.cpp−1 tests/qmltests/Stages/tst_ApplicationWindow.qml+32−24
qml/Stages/ApplicationWindow.qml+40−35
@@ -28,45 +28,50 @@ Item {
2828 property bool interactive: true
2929 property QtObject application
3030
31− // helpers so that we don't have to check for the existence of an application everywhere
32− // (in order to avoid breaking qml binding due to a javascript exception)
33− readonly property string name: application ? application.name : ""
34− readonly property url icon: application ? application.icon : ""
35− readonly property Item surface: application ? application.surface : null
36− readonly property int applicationState: application ? application.state : -1
37− readonly property var promptSurfaces: application ? application.promptSurfaces : null
38−
39− property bool _needToTakeScreenshot:
40− root.surface && root._surfaceInitialized && screenshotImage.status === Image.Null
41− && root.applicationState === ApplicationInfo.Stopped
42− on_NeedToTakeScreenshotChanged: {
43− if (_needToTakeScreenshot) {
44− screenshotImage.take();
31+ QtObject {
32+ id: d
33+
34+ // helpers so that we don't have to check for the existence of an application everywhere
35+ // (in order to avoid breaking qml binding due to a javascript exception)
36+ readonly property string name: root.application ? root.application.name : ""
37+ readonly property url icon: root.application ? root.application.icon : ""
38+ readonly property Item surface: root.application ? root.application.surface : null
39+ readonly property int applicationState: root.application ? root.application.state : -1
40+ readonly property var promptSurfaces: root.application ? root.application.promptSurfaces : null
41+
42+ property bool needToTakeScreenshot:
43+ d.surface && d.surfaceInitialized && screenshotImage.status === Image.Null
44+ && d.applicationState === ApplicationInfo.Stopped
45+ onNeedToTakeScreenshotChanged: {
46+ if (needToTakeScreenshot) {
47+ screenshotImage.take();
48+ }
4549 }
46− }
4750
48− //FIXME - this is a hack to avoid the first few rendered frames as they
49− // might show the UI accommodating due to surface resizes on startup.
50− // Remove this when possible
51− property bool _surfaceInitialized: false
52− onSurfaceChanged: {
53− if (surface) {
54− _surfaceInitTimer.start();
55− } else {
56− _surfaceInitialized = false;
51+ //FIXME - this is a hack to avoid the first few rendered frames as they
52+ // might show the UI accommodating due to surface resizes on startup.
53+ // Remove this when possible
54+ property bool surfaceInitialized: false
55+ onSurfaceChanged: {
56+ if (surface) {
57+ surfaceInitTimer.start();
58+ } else {
59+ surfaceInitialized = false;
60+ }
5761 }
5862 }
63+
5964 Timer {
60− id: _surfaceInitTimer
65+ id: surfaceInitTimer
6166 interval: 100
62− onTriggered: { if (root.surface) {root._surfaceInitialized = true;} }
67+ onTriggered: { if (d.surface) {d.surfaceInitialized = true;} }
6368 }
6469
6570 SurfaceContainer {
6671 id: surfaceContainer
6772 objectName: "surfaceContainer"
6873 anchors.fill: parent
69− surface: root.surface
74+ surface: d.surface
7075
7176 Binding {
7277 target: surface
@@ -116,12 +121,12 @@ Item {
116121 active: false
117122 anchors.fill: surfaceContainer
118123 sourceComponent: Component {
119− Splash { name: root.name; image: root.icon }
124+ Splash { name: d.name; image: d.icon }
120125 }
121126 }
122127
123128 Repeater {
124− model: root.promptSurfaces
129+ model: d.promptSurfaces
125130
126131 delegate: SurfaceContainer {
127132 anchors {
@@ -142,16 +147,16 @@ Item {
142147 State {
143148 name: "splashScreen"
144149 when:
145− (!root.surface || !root._surfaceInitialized)
150+ (!d.surface || !d.surfaceInitialized)
146151 &&
147152 screenshotImage.status !== Image.Ready
148153 },
149154 State {
150155 name: "surface"
151156 when:
152− (root.surface && root._surfaceInitialized)
157+ (d.surface && d.surfaceInitialized)
153158 &&
154− (root.applicationState !== ApplicationInfo.Stopped
159+ (d.applicationState !== ApplicationInfo.Stopped
155160 || screenshotImage.status !== Image.Ready)
156161 },
157162 State {
@@ -160,8 +165,8 @@ Item {
160165 screenshotImage.status === Image.Ready
161166 &&
162167 (
163− root.applicationState === ApplicationInfo.Stopped
164− || !root.surface || !root._surfaceInitialized
168+ d.applicationState === ApplicationInfo.Stopped
169+ || !d.surface || !d.surfaceInitialized
165170 )
166171 }
167172 ]
@@ -214,7 +219,7 @@ Item {
214219 duration: UbuntuAnimation.BriskDuration }
215220 PropertyAction { target: surfaceContainer
216221 property: "visible"; value: false }
217− ScriptAction { script: { if (root.surface) { root.surface.release(); } } }
222+ ScriptAction { script: { if (d.surface) { d.surface.release(); } } }
218223 }
219224 },
220225 Transition {
qml/Stages/PhoneStage.qml+4−4
@@ -111,7 +111,7 @@ Rectangle {
111111 objectName: "spreadView"
112112 anchors.fill: parent
113113 interactive: (spreadDragArea.status == DirectionalDragArea.Recognized || phase > 1)
114− && numDelegatesBeingDragged === 0
114+ && draggedDelegateCount === 0
115115 contentWidth: spreadRow.width - shift
116116 contentX: -shift
117117
@@ -149,7 +149,7 @@ Rectangle {
149149 property int phase: 0
150150
151151 property int selectedIndex: -1
152− property int numDelegatesBeingDragged: 0
152+ property int draggedDelegateCount: 0
153153 property int closingIndex: -1
154154
155155 property bool focusChanging: false
@@ -379,9 +379,9 @@ Rectangle {
379379
380380 onDraggedChanged: {
381381 if (dragged) {
382− spreadView.numDelegatesBeingDragged++;
382+ spreadView.draggedDelegateCount++;
383383 } else {
384− spreadView.numDelegatesBeingDragged--;
384+ spreadView.draggedDelegateCount--;
385385 }
386386 }
387387
qml/Stages/SpreadDelegate.qml+1−2
@@ -40,7 +40,6 @@ Item {
4040 Item {
4141 objectName: "appWindowWithShadow"
4242
43− x: 0
4443 y: dragArea.distance
4544 width: parent.width
4645 height: parent.height
@@ -55,7 +54,7 @@ Item {
5554 }
5655 source: "graphics/dropshadow.png"
5756 border { left: 50; right: 50; top: 50; bottom: 50 }
58− opacity: root.dropShadow ? 1 : 0
57+ opacity: root.dropShadow ? .4 : 0
5958 Behavior on opacity { UbuntuNumberAnimation {} }
6059 }
6160
qml/Stages/TabletStage.qml+12−3
@@ -145,7 +145,8 @@ Rectangle {
145145 Flickable {
146146 id: spreadView
147147 anchors.fill: parent
148− interactive: (spreadDragArea.status == DirectionalDragArea.Recognized || phase > 1) && draggedIndex == -1
148+ interactive: (spreadDragArea.status == DirectionalDragArea.Recognized || phase > 1)
149+ && draggedDelegateCount === 0
149150 contentWidth: spreadRow.width - shift
150151 contentX: -shift
151152
@@ -189,7 +190,7 @@ Rectangle {
189190 readonly property real snapPosition: 0.75
190191
191192 property int selectedIndex: -1
192− property int draggedIndex: -1
193+ property int draggedDelegateCount: 0
193194 property int closingIndex: -1
194195
195196 property bool sideStageDragging: sideStageDragHandle.dragging
@@ -475,6 +476,7 @@ Rectangle {
475476 swipeToCloseEnabled: spreadView.interactive
476477 maximizedAppTopMargin: root.maximizedAppTopMargin
477478 dragOffset: !isDash && model.appId == priv.mainStageAppId && root.inverseProgress > 0 ? root.inverseProgress : 0
479+ application: ApplicationManager.get(index)
478480 closeable: !isDash
479481
480482 readonly property bool isDash: model.appId == "unity8-dash"
@@ -534,8 +536,15 @@ Rectangle {
534536 }
535537 }
536538
539+ onDraggedChanged: {
540+ if (dragged) {
541+ spreadView.draggedDelegateCount++;
542+ } else {
543+ spreadView.draggedDelegateCount--;
544+ }
545+ }
546+
537547 onClosed: {
538− spreadView.draggedIndex = -1;
539548 spreadView.closingIndex = index;
540549 ApplicationManager.stopApplication(ApplicationManager.get(index).appId);
541550 }
qml/Stages/TransformedTabletSpreadDelegate.qml+2−2
@@ -137,7 +137,7 @@ SpreadDelegate {
137137 Behavior on xTranslate {
138138 enabled: !spreadView.active &&
139139 !snapAnimation.running &&
140− root.closeable &&
140+ model.appId !== "unity8-dash" &&
141141 !spreadView.sideStageDragging
142142 UbuntuNumberAnimation {
143143 duration: UbuntuAnimation.FastDuration
@@ -172,7 +172,7 @@ SpreadDelegate {
172172 }
173173 newTranslate += root.dragOffset;
174174 }
175− if (!spreadView.active && !root.closeable && !root.active) {
175+ if (!spreadView.active && model.appId == "unity8-dash" && !root.active) {
176176 newTranslate -= root.width;
177177 }
178178
tests/mocks/Unity/Application/ApplicationInfo.cpp−1
@@ -18,7 +18,6 @@
1818#include "MirSurfaceItem.h"
1919#include "SurfaceManager.h"
2020
21−// unity8
2221#include <paths.h>
2322
2423#include <QGuiApplication>
tests/qmltests/Stages/tst_ApplicationWindow.qml+32−24
@@ -158,30 +158,32 @@ Rectangle {
158158 applicationWindowLoader.active = true;
159159 }
160160
161− function test_showSplashUntilAppFullyInit1() {
162− var stateGroup = findInvisibleChild(applicationWindowLoader.item, "applicationWindowStateGroup");
163−
164− verify(stateGroup.state === "splashScreen");
165−
166− setApplicationState(appRunning);
167−
168− verify(stateGroup.state === "splashScreen");
161+ function test_showSplashUntilAppFullyInit_data() {
162+ return [
163+ {tag: "state=Running then create surface", swapInitOrder: false},
169164
170− surfaceCheckbox.checked = true;
171−
172− tryCompare(stateGroup, "state", "surface");
165+ {tag: "create surface then state=Running", swapInitOrder: true},
166+ ]
173167 }
174168
175− function test_showSplashUntilAppFullyInit2() {
169+ function test_showSplashUntilAppFullyInit() {
176170 var stateGroup = findInvisibleChild(applicationWindowLoader.item, "applicationWindowStateGroup");
177171
178172 verify(stateGroup.state === "splashScreen");
179173
180− surfaceCheckbox.checked = true;
174+ if (data.swapInitOrder) {
175+ surfaceCheckbox.checked = true;
176+ } else {
177+ setApplicationState(appRunning);
178+ }
181179
182180 verify(stateGroup.state === "splashScreen");
183181
184− setApplicationState(appRunning);
182+ if (data.swapInitOrder) {
183+ setApplicationState(appRunning);
184+ } else {
185+ surfaceCheckbox.checked = true;
186+ }
185187
186188 tryCompare(stateGroup, "state", "surface");
187189 }
@@ -191,14 +193,16 @@ Rectangle {
191193
192194 surfaceCheckbox.checked = true;
193195 setApplicationState(appRunning);
196+
194197 tryCompare(stateGroup, "state", "surface");
195198
199+ // wait until any transition animation has finished
200+ tryCompare(stateGroup, "transitioning", false, 2000);
201+
196202 setApplicationState(appSuspended);
197203
198− for (var i = 0; i < 10; ++i) {
199− wait(50);
200− verify(stateGroup.state === "surface");
201− }
204+ verify(stateGroup.state === "surface");
205+ verify(stateGroup.transitioning === false);
202206 }
203207
204208 function test_killedAppShowsScreenshot() {
@@ -227,6 +231,7 @@ Rectangle {
227231 surfaceCheckbox.checked = true;
228232 setApplicationState(appRunning);
229233 tryCompare(stateGroup, "state", "surface");
234+ tryCompare(stateGroup, "transitioning", false, 2000);
230235
231236 setApplicationState(appSuspended);
232237
@@ -234,19 +239,20 @@ Rectangle {
234239 setApplicationState(appStopped);
235240
236241 tryCompare(stateGroup, "state", "screenshot");
242+ tryCompare(stateGroup, "transitioning", false, 2000);
237243 tryCompare(fakeApplication, "surface", null);
238244
239245 // and restart it
240246 setApplicationState(appStarting);
241247
242− wait(50);
248+ verify(stateGroup.transitioning === false);
249+ verify(stateGroup.state === "screenshot");
243250 verify(fakeApplication.surface === null);
244− tryCompare(stateGroup, "state", "screenshot");
245251
246252 setApplicationState(appRunning);
247253
248− wait(50);
249− tryCompare(stateGroup, "state", "screenshot");
254+ verify(stateGroup.transitioning === false);
255+ verify(stateGroup.state === "screenshot");
250256
251257 surfaceCheckbox.checked = true;
252258
@@ -260,6 +266,7 @@ Rectangle {
260266 surfaceCheckbox.checked = true;
261267 setApplicationState(appRunning);
262268 tryCompare(stateGroup, "state", "surface");
269+ tryCompare(stateGroup, "transitioning", false, 2000);
263270
264271 // oh, it crashed...
265272 setApplicationState(appStopped);
@@ -274,17 +281,18 @@ Rectangle {
274281 surfaceCheckbox.checked = true;
275282 setApplicationState(appRunning);
276283 tryCompare(stateGroup, "state", "surface");
284+ tryCompare(stateGroup, "transitioning", false, 2000);
277285 verify(fakeApplication.surface !== null);
278286
279287 applicationWindowLoader.item.visible = false;
280288
281− wait(50);
289+ verify(stateGroup.transitioning === false);
282290 verify(stateGroup.state === "surface");
283291 verify(fakeApplication.surface !== null);
284292
285293 applicationWindowLoader.item.visible = true;
286294
287− wait(50);
295+ verify(stateGroup.transitioning === false);
288296 verify(stateGroup.state === "surface");
289297 verify(fakeApplication.surface !== null);
290298 }