on xenial help sign in
merge ~lukas-kde/unity8/unsnap-from-panel
commit479291575bebf77624de232226a371b16aa7c636 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 15 Mar 2017, 20:23 (10 years ago) parentfe9d37e63107cb
3 files changed+102−10
qml/ApplicationMenus/MenuBar.qml+5 qml/Panel/Panel.qml+7−1 tests/qmltests/tst_Shell.qml+90−9
qml/ApplicationMenus/MenuBar.qml+5
@@ -52,6 +52,10 @@ Item {
5252 d.dismissAll();
5353 }
5454
55+ function invokeMenu(mouseEvent) {
56+ mouseArea.onClicked(mouseEvent);
57+ }
58+
5559 GlobalShortcut {
5660 shortcut: Qt.Key_Alt|Qt.AltModifier
5761 active: enableKeyFilter
@@ -226,6 +230,7 @@ Item {
226230 } // Row
227231
228232 MouseArea {
233+ id: mouseArea
229234 anchors.fill: parent
230235 hoverEnabled: d.currentItem
231236
qml/Panel/Panel.qml+7−1
@@ -174,6 +174,10 @@ Item {
174174 // let it fall through to the window decoration of the maximized window behind, if any
175175 mouse.accepted = false;
176176 }
177+ var menubar = menuBarLoader.item;
178+ if (menubar) {
179+ menubar.invokeMenu(mouse);
180+ }
177181 }
178182
179183 Row {
@@ -200,6 +204,7 @@ Item {
200204
201205 Loader {
202206 id: menuBarLoader
207+ objectName: "menuBarLoader"
203208 height: parent.height
204209 enabled: d.enablePointerMenu
205210 opacity: d.showPointerMenu ? 1 : 0
@@ -209,7 +214,7 @@ Item {
209214
210215 width: parent.width - windowControlButtons.width - units.gu(2) - __indicators.barWidth
211216
212− property bool menusRequested: menuBarLoader.item ? menuBarLoader.item.showRequested : false
217+ readonly property bool menusRequested: menuBarLoader.item ? menuBarLoader.item.showRequested : false
213218
214219 sourceComponent: MenuBar {
215220 id: bar
@@ -231,6 +236,7 @@ Item {
231236 }
232237
233238 onDoubleClicked: PanelState.restoreClicked()
239+ onPressed: mouse.accepted = false // let the parent mouse area handle this, so it can both unsnap window and show menu
234240 }
235241 }
236242 }
tests/qmltests/tst_Shell.qml+90−9
@@ -2513,27 +2513,43 @@ Rectangle {
25132513 tryCompare(app2Surface, "keymap", "fr");
25142514 }
25152515
2516− function test_dragPanelToRestoreMaximizedWindow() {
2516+ function test_dragPanelToRestoreMaximizedWindow_data() {
2517+ return [
2518+ { tag: "with mouse", mouse: true },
2519+ { tag: "with touch", mouse: false }
2520+ ]
2521+ }
2522+
2523+ function test_dragPanelToRestoreMaximizedWindow(data) {
25172524 loadShell("desktop");
25182525 shell.usageScenario = "desktop";
25192526 waitForRendering(shell);
25202527 var panel = findChild(shell, "windowControlArea");
25212528 verify(panel);
25222529
2523− var appSurfaceId = topLevelSurfaceList.nextId;
2524− var app = ApplicationManager.startApplication("dialer-app")
2525− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2526−
25272530 // start dialer, maximize it
2528− var appContainer = findChild(shell, "appContainer");
2529− var appDelegate = findChild(appContainer, "appDelegate_" + appSurfaceId);
2531+ var appDelegate = startApplication("dialer-app");
25302532 verify(appDelegate);
2533+
25312534 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
2532− mouseClick(maximizeButton);
2535+ if (data.mouse) {
2536+ mouseClick(maximizeButton);
2537+ } else {
2538+ tap(maximizeButton);
2539+ }
25332540
25342541 tryCompare(appDelegate, "state", "maximized");
25352542
2536− mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2543+ if (data.mouse) {
2544+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
2545+ var menuBarLoader = findInvisibleChild(panel, "menuBarLoader");
2546+ verify(menuBarLoader);
2547+ tryCompare(menuBarLoader.item, "visible", true);
2548+ mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2549+ } else {
2550+ touchFlick(panel, panel.width/2, panel.height/2, panel.width/2, shell.height/3);
2551+ }
2552+
25372553 tryCompare(appDelegate, "state", "restored");
25382554 }
25392555
@@ -2964,5 +2980,70 @@ Rectangle {
29642980 mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
29652981 tryCompare(appDelegate, "state", "restored");
29662982 }
2983+
2984+ function test_noMenusWithActiveCall() {
2985+ loadShell("desktop");
2986+ shell.usageScenario = "desktop";
2987+ waitForRendering(shell);
2988+ swipeAwayGreeter();
2989+
2990+ // start music-app, maximize it
2991+ var appDelegate = startApplication("music-app")
2992+ verify(appDelegate);
2993+ appDelegate.requestMaximize();
2994+
2995+ // move the mouse over panel to reveal the menus
2996+ var panel = findChild(shell, "panel");
2997+ verify(panel);
2998+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
2999+ var menuBarLoader = findInvisibleChild(panel, "menuBarLoader");
3000+ verify(menuBarLoader);
3001+ tryCompare(menuBarLoader.item, "visible", true);
3002+
3003+ // place a phone call
3004+ callManager.foregroundCall = phoneCall;
3005+
3006+ // menu bar should be hidden
3007+ tryCompare(menuBarLoader, "active", false);
3008+ tryCompare(menuBarLoader, "item", null);
3009+
3010+ // remove call
3011+ callManager.foregroundCall = null;
3012+
3013+ // menu bar should be revealed
3014+ tryCompare(menuBarLoader, "active", true);
3015+ tryCompare(menuBarLoader.item, "visible", true);
3016+ }
3017+
3018+ function test_maximizedWindowAndMenuInPanel() {
3019+ loadShell("desktop");
3020+ shell.usageScenario = "desktop";
3021+ waitForRendering(shell);
3022+ swipeAwayGreeter();
3023+
3024+ // start music-app, maximize it
3025+ var appDelegate = startApplication("music-app")
3026+ verify(appDelegate);
3027+ appDelegate.requestMaximize();
3028+ tryCompare(appDelegate, "state", "maximized");
3029+
3030+ // move the mouse over panel to reveal the menus
3031+ var panel = findChild(shell, "panel");
3032+ verify(panel);
3033+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3034+ var menuBar = findChild(panel, "menuBar");
3035+ verify(menuBar);
3036+ tryCompare(menuBar, "visible", true);
3037+
3038+ // check that the menu popup appears
3039+ var priv = findInvisibleChild(menuBar, "d");
3040+ var menuItem0 = findChild(menuBar, "menuBar-item0");
3041+ verify(menuItem0);
3042+ mouseMove(menuItem0, menuItem0.width/2, menuItem0.height/2, 200);
3043+ tryCompare(menuItem0, "visible", true);
3044+ mouseClick(menuItem0);
3045+ tryCompare(priv, "currentItem", menuItem0);
3046+ tryCompare(priv.currentItem, "popupVisible", true);
3047+ }
29673048 }
29683049}