on xenial help sign in
Use proper z ordering instead of app index for occlusion detection
3866e29Michael Zanetti
qml/Stages/DesktopStage.qml+10−7
@@ -123,17 +123,17 @@ AbstractStage {
123 }
123 }
124 onFocusedAppDelegateChanged: updateForegroundMaximizedApp();
124 onFocusedAppDelegateChanged: updateForegroundMaximizedApp();
125
125
126− property int foregroundMaximizedAppIdIndex: -1
126+ property int foregroundMaximizedAppZ: -1
127
127
128 function updateForegroundMaximizedApp() {
128 function updateForegroundMaximizedApp() {
129+ var tmp = -1;
129− for (var i = 0; i < appRepeater.count; i++) {
130+ for (var i = appRepeater.count - 1; i >= 0; i--) {
130 var item = appRepeater.itemAt(i);
131 var item = appRepeater.itemAt(i);
131 if (item && item.visuallyMaximized) {
132 if (item && item.visuallyMaximized) {
132− foregroundMaximizedAppIdIndex = i;
133+ tmp = Math.max(tmp, item.normalZ);
133− return;
134 }
134 }
135 }
135 }
136− foregroundMaximizedAppIdIndex = -1;
136+ foregroundMaximizedAppZ = tmp;
137 }
137 }
138
138
139 function indexOf(appId) {
139 function indexOf(appId) {
@@ -237,7 +237,10 @@ AbstractStage {
237 delegate: FocusScope {
237 delegate: FocusScope {
238 id: appDelegate
238 id: appDelegate
239 objectName: "appDelegate_" + appId
239 objectName: "appDelegate_" + appId
240+ // z might be overriden in some cases by effects, but we need z ordering
241+ // to calculate occlusion detection
240− z: ApplicationManager.count - index
242+ property int normalZ: ApplicationManager.count - index
243+ z: normalZ
241 y: PanelState.panelHeight
244 y: PanelState.panelHeight
242 focus: appId === priv.focusedAppId
245 focus: appId === priv.focusedAppId
243 width: decoratedWindow.width
246 width: decoratedWindow.width
@@ -274,7 +277,7 @@ AbstractStage {
274
277
275 visible: !visuallyMinimized &&
278 visible: !visuallyMinimized &&
276 !greeter.fullyShown &&
279 !greeter.fullyShown &&
277− (priv.foregroundMaximizedAppIdIndex === -1 || priv.foregroundMaximizedAppIdIndex >= index) ||
280+ (priv.foregroundMaximizedAppZ === -1 || priv.foregroundMaximizedAppZ <= z) ||
278 (spread.state == "altTab" && index === spread.highlightedIndex)
281 (spread.state == "altTab" && index === spread.highlightedIndex)
279
282
280 Binding {
283 Binding {
tests/qmltests/Stages/tst_DesktopStage.qml+40
@@ -460,5 +460,45 @@ Item {
460 compare(dialerDelegate.visible, true, "Dialer should be visible");
460 compare(dialerDelegate.visible, true, "Dialer should be visible");
461 compare(dashDelegate.visible, true, "Dash should still be visible");
461 compare(dashDelegate.visible, true, "Dash should still be visible");
462 }
462 }
463+
464+ function test_occlusionWithMultipleMaximized() {
465+ var dashApp = startApplication("unity8-dash");
466+ var dashAppDelegate = findChild(desktopStage, "appDelegate_unity8-dash");
467+
468+ var dialerApp = startApplication("dialer-app");
469+ var dialerAppDelegate = findChild(desktopStage, "appDelegate_dialer-app");
470+
471+ var facebookApp = startApplication("facebook-webapp");
472+ var facebookAppDelegate = findChild(desktopStage, "appDelegate_facebook-webapp");
473+
474+ // all of them are in restored state now. all should be visible
475+ tryCompare(dashAppDelegate, "visible", true);
476+ tryCompare(dialerAppDelegate, "visible", true);
477+ tryCompare(facebookAppDelegate, "visible", true);
478+
479+ // Maximize the topmost and make sure the other two are hidden
480+ facebookAppDelegate.maximize();
481+ tryCompare(dashAppDelegate, "visible", false);
482+ tryCompare(dialerAppDelegate, "visible", false);
483+ tryCompare(facebookAppDelegate, "visible", true);
484+
485+ // Bring dash to front. make sure dash and the maximized facebook are visible, the restored one behind is hidden
486+ ApplicationManager.focusApplication("unity8-dash");
487+ tryCompare(dashAppDelegate, "visible", true);
488+ tryCompare(dialerAppDelegate, "visible", false);
489+ tryCompare(facebookAppDelegate, "visible", true);
490+
491+ // Now focus the dialer app. all 3 should be visible again
492+ ApplicationManager.focusApplication("dialer-app");
493+ tryCompare(dashAppDelegate, "visible", true);
494+ tryCompare(dialerAppDelegate, "visible", true);
495+ tryCompare(facebookAppDelegate, "visible", true);
496+
497+ // Maximize the dialer app. The other 2 should hide
498+ dialerAppDelegate.maximize();
499+ tryCompare(dashAppDelegate, "visible", false);
500+ tryCompare(dialerAppDelegate, "visible", true);
501+ tryCompare(facebookAppDelegate, "visible", false);
502+ }
463 }
503 }
464}
504}
tests/qmltests/tst_Shell.qml+1
@@ -1730,6 +1730,7 @@ Rectangle {
1730 tryCompare(desktopSpread, "state", "altTab")
1730 tryCompare(desktopSpread, "state", "altTab")
1731
1731
1732 revealLauncherByEdgePushWithMouse();
1732 revealLauncherByEdgePushWithMouse();
1733+ tryCompare(launcher, "x", 0);
1733 waitForRendering(shell)
1734 waitForRendering(shell)
1734
1735
1735 mouseClick(bfb, bfb.width / 2, bfb.height / 2)
1736 mouseClick(bfb, bfb.width / 2, bfb.height / 2)