@@ -119,21 +119,17 @@ AbstractStage {
119 var index = indexOf(focusedAppId);
119 var index = indexOf(focusedAppId);
120 return index >= 0 && index < appRepeater.count ? appRepeater.itemAt(index) : null
120 return index >= 0 && index < appRepeater.count ? appRepeater.itemAt(index) : null
122− property int foregroundMaximizedAppIdIndex: -1
122+ property int foregroundMaximizedAppZ: -1
124 function updateForegroundMaximizedApp() {
124 function updateForegroundMaximizedApp() {
125− for (var i = 0; i < appRepeater.count; i++) {
126+ for (var i = appRepeater.count - 1; i >= 0; i--) {
126 var item = appRepeater.itemAt(i);
127 var item = appRepeater.itemAt(i);
128 if (item && item.visuallyMaximized) {
128 if (item && item.visuallyMaximized) {
129− var app = ApplicationManager.get(i);
129+ tmp = Math.max(tmp, item.normalZ);
131− foregroundMaximizedAppIdIndex = i;
136− foregroundMaximizedAppIdIndex = -1;
132+ foregroundMaximizedAppZ = tmp;
139 function indexOf(appId) {
135 function indexOf(appId) {
@@ -217,7 +213,10 @@ AbstractStage {
217 delegate: FocusScope {
213 delegate: FocusScope {
218 id: appDelegate
214 id: appDelegate
219 objectName: "appDelegate_" + appId
215 objectName: "appDelegate_" + appId
216+ // z might be overriden in some cases by effects, but we need z ordering
217+ // to calculate occlusion detection
220− z: ApplicationManager.count - index
218+ property int normalZ: ApplicationManager.count - index
221 y: units.gu(3)
220 y: units.gu(3)
222 width: units.gu(60)
221 width: units.gu(60)
223 height: units.gu(50)
222 height: units.gu(50)
@@ -252,7 +251,7 @@ AbstractStage {
253 visible: !visuallyMinimized &&
252 visible: !visuallyMinimized &&
254 !greeter.fullyShown &&
253 !greeter.fullyShown &&
255− (priv.foregroundMaximizedAppIdIndex === -1 || priv.foregroundMaximizedAppIdIndex >= index) ||
254+ (priv.foregroundMaximizedAppZ === -1 || priv.foregroundMaximizedAppZ <= z) ||
256 (spread.state == "altTab" && index === spread.highlightedIndex)
255 (spread.state == "altTab" && index === spread.highlightedIndex)
258 Binding {
257 Binding {