@@ -112,25 +112,22 @@ AbstractStage {
112 if (spread.state == "altTab") {
112 if (spread.state == "altTab") {
113 spread.state = "";
113 spread.state = "";
115− updateForegroundMaximizedApp();
118− property int foregroundMaximizedAppZ: -1
119− property int foregroundMaximizedAppIndex: -1 // for stuff like drop shadow and focusing maximized app by clicking panel
117+ property var foregroundMaximizedAppDelegate: null // for stuff like drop shadow and focusing maximized app by clicking panel
122 function updateForegroundMaximizedApp() {
119 function updateForegroundMaximizedApp() {
123− var tmp = -1;
120+ var found = false;
125− for (var i = appRepeater.count - 1; i >= 0; i--) {
121+ for (var i = 0; i < appRepeater.count && !found; i++) {
126 var item = appRepeater.itemAt(i);
122 var item = appRepeater.itemAt(i);
127 if (item && item.visuallyMaximized) {
123 if (item && item.visuallyMaximized) {
128− tmpAppId = i;
124+ foregroundMaximizedAppDelegate = item;
129− tmp = Math.max(tmp, item.normalZ);
125+ found = true;
132− foregroundMaximizedAppZ = tmp;
128+ if (!found) {
133− foregroundMaximizedAppIndex = tmpAppId;
129+ foregroundMaximizedAppDelegate = null;
136 function minimizeAllWindows() {
133 function minimizeAllWindows() {
@@ -158,6 +155,11 @@ AbstractStage {
158 onClose: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
155 onClose: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
159 onMinimize: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
156 onMinimize: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
160 onMaximize: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
157 onMaximize: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
158+ onFocusMaximizedApp: {
159+ if (priv.foregroundMaximizedAppDelegate) {
160+ priv.foregroundMaximizedAppDelegate.focus = true;
163 Binding {
165 Binding {
@@ -185,7 +187,7 @@ AbstractStage {
185 Binding {
187 Binding {
186 target: PanelState
188 target: PanelState
187 property: "dropShadow"
189 property: "dropShadow"
188− value: priv.focusedAppDelegate && !priv.focusedAppDelegate.maximized && priv.foregroundMaximizedAppIndex !== -1
190+ value: priv.focusedAppDelegate && !priv.focusedAppDelegate.maximized && priv.foregroundMaximizedAppDelegate !== null
191 Component.onDestruction: {
193 Component.onDestruction: {
@@ -241,12 +243,12 @@ AbstractStage {
241 // z might be overriden in some cases by effects, but we need z ordering
243 // z might be overriden in some cases by effects, but we need z ordering
242 // to calculate occlusion detection
244 // to calculate occlusion detection
243 property int normalZ: topLevelSurfaceList.count - index
245 property int normalZ: topLevelSurfaceList.count - index
244− z: normalZ
246+ onNormalZChanged: {
246 if (visuallyMaximized) {
247 if (visuallyMaximized) {
247 priv.updateForegroundMaximizedApp();
248 priv.updateForegroundMaximizedApp();
250 y: PanelState.panelHeight
252 y: PanelState.panelHeight
252 width: decoratedWindow.width
254 width: decoratedWindow.width
@@ -338,6 +340,10 @@ AbstractStage {
343+ if (visuallyMaximized) {
344+ priv.updateForegroundMaximizedApp();
341 if (focus) {
347 if (focus) {
342 // focus some other window
348 // focus some other window
343 for (var i = 0; i < appRepeater.count; i++) {
349 for (var i = 0; i < appRepeater.count; i++) {
@@ -348,18 +354,17 @@ AbstractStage {
351− if (visuallyMaximized) {
352− priv.updateForegroundMaximizedApp();
356 onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
359 onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
358− visible: !visuallyMinimized &&
362+ !visuallyMinimized
359− !greeter.fullyShown &&
363+ && !greeter.fullyShown
360− (priv.foregroundMaximizedAppZ === -1 || priv.foregroundMaximizedAppZ <= z) ||
364+ && (priv.foregroundMaximizedAppDelegate === null || priv.foregroundMaximizedAppDelegate.normalZ <= z)
361− decoratedWindow.fullscreen ||
366+ || decoratedWindow.fullscreen
362− (spread.state == "altTab" && index === spread.highlightedIndex)
367+ || (spread.state == "altTab" && index === spread.highlightedIndex)
364 function close() {
369 function close() {
365 model.surface.close();
370 model.surface.close();