@@ -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