@@ -15,7 +15,7 @@ Item {
1515 property bool moving: false
1616
1717 // State information propagated to the outside
18− readonly property bool painting: mainScreenshotImage.visible || fadeInScreenshotImage.visible
18+ readonly property bool painting: mainScreenshotImage.visible || fadeInScreenshotImage.visible || appSplash.visible
1919
2020 onMovingChanged: {
2121 if (moving) {
@@ -34,18 +34,24 @@ Item {
3434
3535 onFocusedApplicationIdChanged: {
3636 if (ApplicationManager.focusedApplicationId.length > 0) {
37− priv.applicationStarting = false;
38− priv.secondApplicationStarting = false;
37+ if (priv.secondApplicationStarting || priv.applicationStarting) {
38+ appSplashTimer.start();
39+ } else {
40+ mainScreenshotImage.src = ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).screenshot
41+ }
3942 }
4043 }
4144
4245 onApplicationAdded: {
4346 if (!priv.focusedApplication) {
44− print("*** applicationStarting")
47+ mainScreenshotImage.src = "";
48+ mainScreenshotImage.visible = false;
4549 priv.applicationStarting = true;
4650 } else {
47− print("*** SECONDapplicationStarting")
51+ mainScreenshotImage.src = "foobar";
52+ priv.newFocusedAppId = appId;
4853 priv.secondApplicationStarting = true;
54+ priv.requestNewScreenshot();
4955 }
5056 }
5157 }
@@ -65,12 +71,14 @@ Item {
6571 property string newFocusedAppId
6672
6773 onFocusedScreenshotChanged: {
68− waitingForScreenshot = false;
69− if (root.moving) {
74+ if (root.moving && priv.waitingForScreenshot) {
7075 mainScreenshotImage.anchors.leftMargin = 0;
7176 mainScreenshotImage.src = ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).screenshot;
7277 mainScreenshotImage.visible = true;
78+ } else if (priv.secondApplicationStarting && priv.waitingForScreenshot) {
79+ applicationSwitchingAnimation.start();
7380 }
81+ waitingForScreenshot = false;
7482 }
7583
7684 function requestNewScreenshot() {
@@ -98,11 +106,26 @@ Item {
98106 }
99107 }
100108
109+ Timer {
110+ id: appSplashTimer
111+ // This is to show the splash screen a bit longer.
112+ // Mir signals us that the newly started app has gotten focus before it paints something on the screen
113+ // This would result in the old app surface becoming visible for a bit.
114+ // FIXME: change appManager to only change the focusedApplicationId when the surface is ready to be shown.
115+ interval: 1500
116+ repeat: false
117+ onTriggered: {
118+ priv.applicationStarting = false;
119+ priv.secondApplicationStarting = false;
120+ }
121+ }
122+
101123 SequentialAnimation {
102124 id: applicationSwitchingAnimation
103125 // setup
104126 PropertyAction { target: mainScreenshotImage; property: "anchors.leftMargin"; value: 0 }
105− PropertyAction { target: mainScreenshotImage; property: "src"; value: priv.focusedScreenshot }
127+ // PropertyAction seems to fail when secondApplicationStarting and we didn't have another screenshot before
128+ ScriptAction { script: mainScreenshotImage.src = priv.focusedScreenshot }
106129 PropertyAction { target: mainScreenshotImage; property: "visible"; value: true }
107130 PropertyAction { target: fadeInScreenshotImage; property: "source"; value: ApplicationManager.findApplication(priv.newFocusedAppId).screenshot }
108131 PropertyAction { target: fadeInScreenshotImage; property: "visible"; value: true }
@@ -124,7 +147,7 @@ Item {
124147
125148 // FIXME: Drop this and make the imageprovider show a splashscreen instead
126149 Rectangle {
127− id: appSplash
150+ id: appSplash2
128151 anchors.fill: parent
129152 color: "white"
130153 visible: priv.secondApplicationStarting
@@ -138,9 +161,9 @@ Item {
138161 }
139162
140163 Rectangle {
141− id: appSplash2
164+ id: appSplash
142165 anchors.fill: parent
143− color: "red"
166+ color: "white"
144167 visible: priv.applicationStarting
145168 }
146169 Image {