on xenial help sign in
make sure the stage has focus when going to spread (LP: #1672053, #1672673, #1676995)
commit581f0d9a4955e2fb7cf25a3dcdf68628923ed3c4 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 4 Apr 2017, 22:54 (10 years ago) parent81e8b93da10fdf
2 files changed+94
qml/Stage/Stage.qml+8 tests/qmltests/tst_Shell.qml+86
qml/Stage/Stage.qml+8
@@ -91,6 +91,7 @@ FocusScope {
9191
9292
9393 onAltTabPressedChanged: {
94+ root.focus = true;
9495 if (altTabPressed) {
9596 if (root.spreadEnabled) {
9697 altTabDelayTimer.start();
@@ -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: [
tests/qmltests/tst_Shell.qml+86
@@ -3193,6 +3193,92 @@ Rectangle {
31933193 tryCompare(menuBarLoader.item, "visible", true);
31943194 }
31953195
3196+ function test_enforceFocusOnStageOnAltTab() {
3197+ loadShell("desktop");
3198+ shell.usageScenario = "desktop";
3199+ waitForRendering(shell);
3200+ swipeAwayGreeter();
3201+
3202+ var appDelegate = startApplication("music-app")
3203+ verify(appDelegate);
3204+ waitForRendering(shell);
3205+
3206+ var launcher = findChild(shell, "launcher");
3207+ launcher.focus = true;
3208+
3209+ var stage = findChild(shell, "stage");
3210+
3211+ var spreadItem = findChild(shell, "spreadItem");
3212+
3213+ compare(spreadItem.highlightedIndex, -1);
3214+
3215+ keyPress(Qt.Key_Alt);
3216+ keyClick(Qt.Key_Tab);
3217+
3218+ tryCompare(spreadItem, "highlightedIndex", 1);
3219+ tryCompare(stage, "focus", true);
3220+
3221+ keyClick(Qt.Key_Tab);
3222+
3223+ tryCompare(spreadItem, "highlightedIndex", 0);
3224+
3225+ keyRelease(Qt.Key_Alt);
3226+ }
3227+
3228+ function test_maximizedWindowMenuThenAltTab_data() {
3229+ return [
3230+ { tag: "show spread", showSpread: true },
3231+ { tag: "do not show spread", showSpread: false },
3232+ ];
3233+ }
3234+
3235+ function test_maximizedWindowMenuThenAltTab(data) {
3236+ loadShell("desktop");
3237+ shell.usageScenario = "desktop";
3238+ waitForRendering(shell);
3239+ swipeAwayGreeter();
3240+
3241+ var appDelegate = startApplication("gmail-webapp");
3242+ var appDelegate2 = startApplication("dialer-app");
3243+
3244+ tryCompare(appDelegate2.surface, "activeFocus", true);
3245+
3246+ var maximizeButton = findChild(appDelegate2, "maximizeWindowButton");
3247+ mouseClick(maximizeButton);
3248+ tryCompare(appDelegate2, "state", "maximized");
3249+
3250+ var panel = findChild(shell, "panel");
3251+ var panelMouse = findChild(panel, "windowControlArea");
3252+ mouseMove(panelMouse);
3253+ var panelMenu = findChild(panel, "menuBar");
3254+ var menuBarLoader = findChild(panel, "menuBarLoader");
3255+ mouseMove(panelMenu);
3256+ var panelMenuItem = findChild(panelMenu, "menuBar-item0");
3257+ tryCompare(panelMenuItem, "visible", true);
3258+ Util.waitForBehaviors(shell);
3259+ mouseClick(panelMenuItem);
3260+ var panelMenuItemItem = findChild(panelMenu, "menuBar-item0-menu-item0-actionItem");
3261+ mouseMove(panelMenuItemItem, panelMenuItemItem.width/2, panelMenuItemItem.height/2);
3262+ verify(panelMenuItemItem.activeFocus);
3263+ verify(panelMenuItem.__popup);
3264+
3265+ keyPress(Qt.Key_Alt);
3266+ keyClick(Qt.Key_Tab);
3267+ if (data.showSpread) {
3268+ tryCompare(stage, "spreadShown", true);
3269+ }
3270+ tryCompareFunction(function() { return menuBarLoader.active === false; }, true);
3271+ keyRelease(Qt.Key_Alt)
3272+
3273+ tryCompare(appDelegate.surface, "activeFocus", true);
3274+
3275+ keyPress(Qt.Key_Alt);
3276+ keyClick(Qt.Key_Tab);
3277+ keyRelease(Qt.Key_Alt)
3278+
3279+ tryCompare(appDelegate2.surface, "activeFocus", true);
3280+ }
3281+
31963282 function test_maximizedWindowAndMenuInPanel() {
31973283 loadShell("desktop");
31983284 shell.usageScenario = "desktop";