on xenial help sign in
DesktopStage fix: focus maximized app when you click on the panel
commit88ba1d68e15415333c5471ee839100a927b1cfa6 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateWed 13 Apr 2016, 11:13 (11 years ago) parent7bc394e
1 file changed+27−22
qml/Stages/DesktopStage.qml+27−22
qml/Stages/DesktopStage.qml+27−22
@@ -112,25 +112,22 @@ AbstractStage {
112112 if (spread.state == "altTab") {
113113 spread.state = "";
114114 }
115− updateForegroundMaximizedApp();
116115 }
117116
118− property int foregroundMaximizedAppZ: -1
119− property int foregroundMaximizedAppIndex: -1 // for stuff like drop shadow and focusing maximized app by clicking panel
120−
117+ property var foregroundMaximizedAppDelegate: null // for stuff like drop shadow and focusing maximized app by clicking panel
121118
122119 function updateForegroundMaximizedApp() {
123− var tmp = -1;
124− var tmpAppId = -1;
125− for (var i = appRepeater.count - 1; i >= 0; i--) {
120+ var found = false;
121+ for (var i = 0; i < appRepeater.count && !found; i++) {
126122 var item = appRepeater.itemAt(i);
127123 if (item && item.visuallyMaximized) {
128− tmpAppId = i;
129− tmp = Math.max(tmp, item.normalZ);
124+ foregroundMaximizedAppDelegate = item;
125+ found = true;
130126 }
131127 }
132− foregroundMaximizedAppZ = tmp;
133− foregroundMaximizedAppIndex = tmpAppId;
128+ if (!found) {
129+ foregroundMaximizedAppDelegate = null;
130+ }
134131 }
135132
136133 function minimizeAllWindows() {
@@ -158,6 +155,11 @@ AbstractStage {
158155 onClose: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
159156 onMinimize: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
160157 onMaximize: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
158+ onFocusMaximizedApp: {
159+ if (priv.foregroundMaximizedAppDelegate) {
160+ priv.foregroundMaximizedAppDelegate.focus = true;
161+ }
162+ }
161163 }
162164
163165 Binding {
@@ -185,7 +187,7 @@ AbstractStage {
185187 Binding {
186188 target: PanelState
187189 property: "dropShadow"
188− value: priv.focusedAppDelegate && !priv.focusedAppDelegate.maximized && priv.foregroundMaximizedAppIndex !== -1
190+ value: priv.focusedAppDelegate && !priv.focusedAppDelegate.maximized && priv.foregroundMaximizedAppDelegate !== null
189191 }
190192
191193 Component.onDestruction: {
@@ -241,12 +243,12 @@ AbstractStage {
241243 // z might be overriden in some cases by effects, but we need z ordering
242244 // to calculate occlusion detection
243245 property int normalZ: topLevelSurfaceList.count - index
244− z: normalZ
245− onZChanged: {
246+ onNormalZChanged: {
246247 if (visuallyMaximized) {
247248 priv.updateForegroundMaximizedApp();
248249 }
249250 }
251+ z: normalZ
250252 y: PanelState.panelHeight
251253
252254 width: decoratedWindow.width
@@ -338,6 +340,10 @@ AbstractStage {
338340 return;
339341 }
340342
343+ if (visuallyMaximized) {
344+ priv.updateForegroundMaximizedApp();
345+ }
346+
341347 if (focus) {
342348 // focus some other window
343349 for (var i = 0; i < appRepeater.count; i++) {
@@ -348,18 +354,17 @@ AbstractStage {
348354 }
349355 }
350356 }
351− if (visuallyMaximized) {
352− priv.updateForegroundMaximizedApp();
353− }
354357 }
355358
356359 onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
357360
358− visible: !visuallyMinimized &&
359− !greeter.fullyShown &&
360− (priv.foregroundMaximizedAppZ === -1 || priv.foregroundMaximizedAppZ <= z) ||
361− decoratedWindow.fullscreen ||
362− (spread.state == "altTab" && index === spread.highlightedIndex)
361+ visible: (
362+ !visuallyMinimized
363+ && !greeter.fullyShown
364+ && (priv.foregroundMaximizedAppDelegate === null || priv.foregroundMaximizedAppDelegate.normalZ <= z)
365+ )
366+ || decoratedWindow.fullscreen
367+ || (spread.state == "altTab" && index === spread.highlightedIndex)
363368
364369 function close() {
365370 model.surface.close();