on xenial help sign in
merge ~mzanetti/unity8/fix-alt-tab as prereq
commit455dd39cfb50450fe8ef71d505772dc338da774e authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 5 Apr 2017, 00:18 (10 years ago) parent7fab136da10fdf
7 files changed+115−40
qml/Panel/Panel.qml+8−8 qml/Stage/DecoratedWindow.qml+1 qml/Stage/Stage.qml+11−2 qml/Stage/WindowDecoration.qml+1 tests/qmltests/Panel/tst_Panel.qml+3−25 tests/qmltests/Stage/tst_DesktopStage.qml+1−5 tests/qmltests/tst_Shell.qml+90
qml/Panel/Panel.qml+8−8
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013-2016 Canonical, Ltd.
2+ * Copyright (C) 2013-2017 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -85,15 +85,15 @@ Item {
8585 property bool showWindowDecorationControls: (revealControls && PanelState.decorationsVisible) ||
8686 PanelState.decorationsAlwaysVisible
8787
88− property bool showPointerMenu: revealControls &&
88+ property bool showPointerMenu: revealControls && enablePointerMenu &&
8989 (PanelState.decorationsVisible || mode == "staged")
9090
91− property bool enablePointerMenu: revealControls &&
92− applicationMenus.available &&
91+ property bool enablePointerMenu: applicationMenus.available &&
9392 applicationMenus.model
9493
9594 property bool showTouchMenu: !greeterShown &&
96− !showPointerMenu
95+ !showPointerMenu &&
96+ !showWindowDecorationControls
9797
9898 property bool enableTouchMenus: showTouchMenu &&
9999 applicationMenus.available &&
@@ -211,7 +211,7 @@ Item {
211211 opacity: d.showPointerMenu ? 1 : 0
212212 visible: opacity != 0
213213 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
214− active: __applicationMenus.model && !callHint.visible
214+ active: d.showPointerMenu && !callHint.visible
215215
216216 width: parent.width - windowControlButtons.width - units.gu(2) - __indicators.barWidth
217217
@@ -220,7 +220,7 @@ Item {
220220 sourceComponent: MenuBar {
221221 id: bar
222222 objectName: "menuBar"
223− anchors.left: parent.left
223+ anchors.left: parent ? parent.left : undefined
224224 anchors.margins: units.gu(1)
225225 height: menuBarLoader.height
226226 enableKeyFilter: valid && PanelState.decorationsVisible
@@ -339,7 +339,7 @@ Item {
339339 maximumLineCount: 1
340340 fontSize: "medium"
341341 font.weight: Font.Medium
342− color: Theme.palette.selected.backgroundText
342+ color: theme.palette.selected.backgroundText
343343 opacity: __applicationMenus.visible && !__applicationMenus.expanded ? 1 : 0
344344 visible: opacity != 0
345345 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
qml/Stage/DecoratedWindow.qml+1
@@ -38,6 +38,7 @@ FocusScope {
3838 property alias maximizeButtonShown: decoration.maximizeButtonShown
3939 property alias interactive: applicationWindow.interactive
4040 readonly property alias orientationChangesEnabled: applicationWindow.orientationChangesEnabled
41+ property alias windowControlButtonsVisible: decoration.windowControlButtonsVisible
4142
4243 // Changing this will actually add/remove a decoration, meaning, requestedHeight will take the decoration into account.
4344 property bool hasDecoration: true
qml/Stage/Stage.qml+11−2
@@ -91,6 +91,7 @@ FocusScope {
9191
9292
9393 onAltTabPressedChanged: {
94+ root.focus = true;
9495 if (altTabPressed) {
9596 if (root.spreadEnabled) {
9697 altTabDelayTimer.start();
@@ -390,7 +391,7 @@ FocusScope {
390391 Binding {
391392 target: PanelState
392393 property: "decorationsVisible"
393− value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.maximized // FIXME for Locally integrated menus
394+ value: mode == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.maximized && !root.spreadShown
394395 }
395396
396397 Binding {
@@ -477,6 +478,7 @@ FocusScope {
477478 State {
478479 name: "spread"; when: priv.goneToSpread
479480 PropertyChanges { target: floatingFlickable; enabled: true }
481+ PropertyChanges { target: root; focus: true }
480482 PropertyChanges { target: spreadItem; focus: true }
481483 PropertyChanges { target: hoverMouseArea; enabled: true }
482484 PropertyChanges { target: rightEdgeDragArea; enabled: false }
@@ -516,14 +518,20 @@ FocusScope {
516518 State {
517519 name: "staged"; when: root.mode === "staged"
518520 PropertyChanges { target: wallpaper; visible: !priv.focusedAppDelegate || priv.focusedAppDelegate.x !== 0 }
521+ PropertyChanges { target: root; focus: true }
522+ PropertyChanges { target: appContainer; focus: true }
519523 },
520524 State {
521525 name: "stagedWithSideStage"; when: root.mode === "stagedWithSideStage"
522526 PropertyChanges { target: triGestureArea; enabled: priv.sideStageEnabled }
523527 PropertyChanges { target: sideStage; visible: true }
528+ PropertyChanges { target: root; focus: true }
529+ PropertyChanges { target: appContainer; focus: true }
524530 },
525531 State {
526532 name: "windowed"; when: root.mode === "windowed"
533+ PropertyChanges { target: root; focus: true }
534+ PropertyChanges { target: appContainer; focus: true }
527535 }
528536 ]
529537 transitions: [
@@ -1383,6 +1391,7 @@ FocusScope {
13831391 requestedHeight: appContainer.height;
13841392 }
13851393 PropertyChanges { target: touchControls; enabled: true }
1394+ PropertyChanges { target: decoratedWindow; windowControlButtonsVisible: false }
13861395 },
13871396 State {
13881397 name: "fullscreen"; when: appDelegate.fullscreen && !appDelegate.minimized
@@ -1405,7 +1414,7 @@ FocusScope {
14051414 }
14061415 PropertyChanges { target: touchControls; enabled: true }
14071416 PropertyChanges { target: resizeArea; enabled: true }
1408− PropertyChanges { target: decoratedWindow; shadowOpacity: .3}
1417+ PropertyChanges { target: decoratedWindow; shadowOpacity: .3; windowControlButtonsVisible: true}
14091418 },
14101419 State {
14111420 name: "restored";
qml/Stage/WindowDecoration.qml+1
@@ -34,6 +34,7 @@ MouseArea {
3434 property var menu: undefined
3535 property bool enableMenus: true
3636 property bool windowMoving: false
37+ property alias windowControlButtonsVisible: buttons.visible
3738
3839 readonly property real buttonsWidth: buttons.width + row.spacing
3940
tests/qmltests/Panel/tst_Panel.qml+3−25
@@ -779,40 +779,18 @@ PanelTest {
779779
780780 var appTitle = findChild(panel, "panelTitle"); verify(appTitle);
781781 var appMenuRow = findChild(panel.applicationMenus, "panelRow"); verify(appMenuRow);
782− var appMenuBar = findChild(panel, "menuBar"); verify(appMenuBar);
782+ var menuBarLoader = findChild(panel, "menuBarLoader"); verify(menuBarLoader);
783783
784784 tryCompare(appTitle, "visible", true, undefined, "App title should be visible");
785− tryCompare(appMenuBar, "visible", false, undefined, "App menu bar should not be visible");
785+ tryCompare(menuBarLoader, "visible", false, undefined, "App menu bar should not be visible");
786786
787787 mouseMove(panel, panel.width/2, panel.panelHeight);
788788
789+ var appMenuBar = findChild(panel, "menuBar"); verify(appMenuBar);
789790 tryCompare(appTitle, "visible", false, undefined, "App title should not be visible on mouse hover");
790791 tryCompare(appMenuBar, "visible", true, undefined, "App menu bar should be visible on mouse hover");
791792 }
792793
793− function test_windowedApplicationMenuShowOnMouseHoverWhenDecorationsShown() {
794− PanelState.title = "Fake Title";
795− panel.mode = "windowed";
796− mouseEmulation.checked = false;
797−
798− var appTitle = findChild(panel, "panelTitle"); verify(appTitle);
799− var appMenuRow = findChild(panel.applicationMenus, "panelRow"); verify(appMenuRow);
800− var appMenuBar = findChild(panel, "menuBar"); verify(appMenuBar);
801−
802− tryCompare(appTitle, "visible", true, undefined, "App title should be visible");
803− tryCompare(appMenuBar, "visible", false, undefined, "App menu bar should not be visible");
804−
805− mouseMove(panel, panel.width/2, panel.panelHeight);
806−
807− tryCompare(appTitle, "visible", true, undefined, "App title should still be visible on mouse hover when panel decorations are not visible");
808− tryCompare(appMenuBar, "visible", false, undefined, "App menu bar should be visible on mouse hover when panel decorations are not visible");
809−
810− PanelState.decorationsVisible = true;
811−
812− tryCompare(appTitle, "visible", false, undefined, "App title should still be visible on mouse hover when panel decorations are visible");
813− tryCompare(appMenuBar, "visible", true, undefined, "App menu bar should be visible on mouse hover when panel decorations not visible");
814− }
815−
816794 function test_keyboardNavigation_data() {
817795 return [
818796 {tag: "tab to start", doTab: false},
tests/qmltests/Stage/tst_DesktopStage.qml+1−5
@@ -863,11 +863,7 @@ Item {
863863 maximizeAppDelegate(appDelegate);
864864
865865 // Close the window and restart the application
866− var closeButton = findChild(appDelegate, "closeWindowButton");
867− appDelegate = null;
868− verify(closeButton);
869− mouseClick(closeButton);
870− closeButton = null;
866+ appDelegate.close();
871867 tryCompare(topSurfaceList, "count", originalWindowCount);
872868 wait(100); // plus some spare room
873869 appDelegate = startApplication("dialer-app");
tests/qmltests/tst_Shell.qml+90
@@ -3175,6 +3175,96 @@ Rectangle {
31753175 tryCompare(menuBarLoader.item, "visible", true);
31763176 }
31773177
3178+ function test_enforceFocusOnStageOnAltTab() {
3179+ loadShell("desktop");
3180+ shell.usageScenario = "desktop";
3181+ waitForRendering(shell);
3182+ swipeAwayGreeter();
3183+
3184+ var appSurfaceId = topLevelSurfaceList.nextId;
3185+ var app = ApplicationManager.startApplication("unity8-dash")
3186+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
3187+
3188+ var appDelegate = startApplication("music-app")
3189+ verify(appDelegate);
3190+ waitForRendering(shell);
3191+
3192+ var launcher = findChild(shell, "launcher");
3193+ launcher.focus = true;
3194+
3195+ var stage = findChild(shell, "stage");
3196+
3197+ var spreadItem = findChild(shell, "spreadItem");
3198+
3199+ compare(spreadItem.highlightedIndex, -1);
3200+
3201+ keyPress(Qt.Key_Alt);
3202+ keyClick(Qt.Key_Tab);
3203+
3204+ tryCompare(spreadItem, "highlightedIndex", 1);
3205+ tryCompare(stage, "focus", true);
3206+
3207+ keyClick(Qt.Key_Tab);
3208+
3209+ tryCompare(spreadItem, "highlightedIndex", 0);
3210+
3211+ keyRelease(Qt.Key_Alt);
3212+ }
3213+
3214+ function test_maximizedWindowMenuThenAltTab_data() {
3215+ return [
3216+ { tag: "show spread", showSpread: true },
3217+ { tag: "do not show spread", showSpread: false },
3218+ ];
3219+ }
3220+
3221+ function test_maximizedWindowMenuThenAltTab(data) {
3222+ loadShell("desktop");
3223+ shell.usageScenario = "desktop";
3224+ waitForRendering(shell);
3225+ swipeAwayGreeter();
3226+
3227+ var appDelegate = startApplication("gmail-webapp");
3228+ var appDelegate2 = startApplication("dialer-app");
3229+
3230+ tryCompare(appDelegate2.surface, "activeFocus", true);
3231+
3232+ var maximizeButton = findChild(appDelegate2, "maximizeWindowButton");
3233+ mouseClick(maximizeButton);
3234+ tryCompare(appDelegate2, "state", "maximized");
3235+
3236+ var panel = findChild(shell, "panel");
3237+ var panelMouse = findChild(panel, "windowControlArea");
3238+ mouseMove(panelMouse);
3239+ var panelMenu = findChild(panel, "menuBar");
3240+ var menuBarLoader = findChild(panel, "menuBarLoader");
3241+ mouseMove(panelMenu);
3242+ var panelMenuItem = findChild(panelMenu, "menuBar-item0");
3243+ tryCompare(panelMenuItem, "visible", true);
3244+ Util.waitForBehaviors(shell);
3245+ mouseClick(panelMenuItem);
3246+ var panelMenuItemItem = findChild(panelMenu, "menuBar-item0-menu-item0-actionItem");
3247+ mouseMove(panelMenuItemItem, panelMenuItemItem.width/2, panelMenuItemItem.height/2);
3248+ verify(panelMenuItemItem.activeFocus);
3249+ verify(panelMenuItem.__popup);
3250+
3251+ keyPress(Qt.Key_Alt);
3252+ keyClick(Qt.Key_Tab);
3253+ if (data.showSpread) {
3254+ tryCompare(stage, "spreadShown", true);
3255+ }
3256+ tryCompareFunction(function() { return menuBarLoader.active === false; }, true);
3257+ keyRelease(Qt.Key_Alt)
3258+
3259+ tryCompare(appDelegate.surface, "activeFocus", true);
3260+
3261+ keyPress(Qt.Key_Alt);
3262+ keyClick(Qt.Key_Tab);
3263+ keyRelease(Qt.Key_Alt)
3264+
3265+ tryCompare(appDelegate2.surface, "activeFocus", true);
3266+ }
3267+
31783268 function test_maximizedWindowAndMenuInPanel() {
31793269 loadShell("desktop");
31803270 shell.usageScenario = "desktop";