on xenial help sign in
Use proper z ordering instead of app index for occlusion detection

Approved by: Nick Dedekind

commit3866e29995262aea680aac069a0af01d464a73f2 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 8 Dec 2015, 15:37 (11 years ago) parent458939ed5ff8bc
3 files changed+51−7
qml/Stages/DesktopStage.qml+10−7 tests/qmltests/Stages/tst_DesktopStage.qml+40 tests/qmltests/tst_Shell.qml+1
qml/Stages/DesktopStage.qml+10−7
@@ -123,17 +123,17 @@ AbstractStage {
123123 }
124124 onFocusedAppDelegateChanged: updateForegroundMaximizedApp();
125125
126− property int foregroundMaximizedAppIdIndex: -1
126+ property int foregroundMaximizedAppZ: -1
127127
128128 function updateForegroundMaximizedApp() {
129− for (var i = 0; i < appRepeater.count; i++) {
129+ var tmp = -1;
130+ for (var i = appRepeater.count - 1; i >= 0; i--) {
130131 var item = appRepeater.itemAt(i);
131132 if (item && item.visuallyMaximized) {
132− foregroundMaximizedAppIdIndex = i;
133− return;
133+ tmp = Math.max(tmp, item.normalZ);
134134 }
135135 }
136− foregroundMaximizedAppIdIndex = -1;
136+ foregroundMaximizedAppZ = tmp;
137137 }
138138
139139 function indexOf(appId) {
@@ -237,7 +237,10 @@ AbstractStage {
237237 delegate: FocusScope {
238238 id: appDelegate
239239 objectName: "appDelegate_" + appId
240− z: ApplicationManager.count - index
240+ // z might be overriden in some cases by effects, but we need z ordering
241+ // to calculate occlusion detection
242+ property int normalZ: ApplicationManager.count - index
243+ z: normalZ
241244 y: PanelState.panelHeight
242245 focus: appId === priv.focusedAppId
243246 width: decoratedWindow.width
@@ -274,7 +277,7 @@ AbstractStage {
274277
275278 visible: !visuallyMinimized &&
276279 !greeter.fullyShown &&
277− (priv.foregroundMaximizedAppIdIndex === -1 || priv.foregroundMaximizedAppIdIndex >= index) ||
280+ (priv.foregroundMaximizedAppZ === -1 || priv.foregroundMaximizedAppZ <= z) ||
278281 (spread.state == "altTab" && index === spread.highlightedIndex)
279282
280283 Binding {
tests/qmltests/Stages/tst_DesktopStage.qml+40
@@ -460,5 +460,45 @@ Item {
460460 compare(dialerDelegate.visible, true, "Dialer should be visible");
461461 compare(dashDelegate.visible, true, "Dash should still be visible");
462462 }
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+ }
463503 }
464504}
tests/qmltests/tst_Shell.qml+1
@@ -1730,6 +1730,7 @@ Rectangle {
17301730 tryCompare(desktopSpread, "state", "altTab")
17311731
17321732 revealLauncherByEdgePushWithMouse();
1733+ tryCompare(launcher, "x", 0);
17331734 waitForRendering(shell)
17341735
17351736 mouseClick(bfb, bfb.width / 2, bfb.height / 2)