on xenial help sign in
merge ~lukas-kde/unity8/unsnap-from-panel
4792915Lukáš Tinkl
qml/ApplicationMenus/MenuBar.qml+5
@@ -52,6 +52,10 @@ Item {
52 d.dismissAll();
52 d.dismissAll();
53 }
53 }
54
54
55+ function invokeMenu(mouseEvent) {
56+ mouseArea.onClicked(mouseEvent);
57+ }
58+
55 GlobalShortcut {
59 GlobalShortcut {
56 shortcut: Qt.Key_Alt|Qt.AltModifier
60 shortcut: Qt.Key_Alt|Qt.AltModifier
57 active: enableKeyFilter
61 active: enableKeyFilter
@@ -226,6 +230,7 @@ Item {
226 } // Row
230 } // Row
227
231
228 MouseArea {
232 MouseArea {
233+ id: mouseArea
229 anchors.fill: parent
234 anchors.fill: parent
230 hoverEnabled: d.currentItem
235 hoverEnabled: d.currentItem
231
236
qml/Panel/Panel.qml+7−1
@@ -174,6 +174,10 @@ Item {
174 // let it fall through to the window decoration of the maximized window behind, if any
174 // let it fall through to the window decoration of the maximized window behind, if any
175 mouse.accepted = false;
175 mouse.accepted = false;
176 }
176 }
177+ var menubar = menuBarLoader.item;
178+ if (menubar) {
179+ menubar.invokeMenu(mouse);
180+ }
177 }
181 }
178
182
179 Row {
183 Row {
@@ -200,6 +204,7 @@ Item {
200
204
201 Loader {
205 Loader {
202 id: menuBarLoader
206 id: menuBarLoader
207+ objectName: "menuBarLoader"
203 height: parent.height
208 height: parent.height
204 enabled: d.enablePointerMenu
209 enabled: d.enablePointerMenu
205 opacity: d.showPointerMenu ? 1 : 0
210 opacity: d.showPointerMenu ? 1 : 0
@@ -209,7 +214,7 @@ Item {
209
214
210 width: parent.width - windowControlButtons.width - units.gu(2) - __indicators.barWidth
215 width: parent.width - windowControlButtons.width - units.gu(2) - __indicators.barWidth
211
216
212− property bool menusRequested: menuBarLoader.item ? menuBarLoader.item.showRequested : false
217+ readonly property bool menusRequested: menuBarLoader.item ? menuBarLoader.item.showRequested : false
213
218
214 sourceComponent: MenuBar {
219 sourceComponent: MenuBar {
215 id: bar
220 id: bar
@@ -231,6 +236,7 @@ Item {
231 }
236 }
232
237
233 onDoubleClicked: PanelState.restoreClicked()
238 onDoubleClicked: PanelState.restoreClicked()
239+ onPressed: mouse.accepted = false // let the parent mouse area handle this, so it can both unsnap window and show menu
234 }
240 }
235 }
241 }
236 }
242 }
tests/qmltests/tst_Shell.qml+90−9
@@ -2513,27 +2513,43 @@ Rectangle {
2513 tryCompare(app2Surface, "keymap", "fr");
2513 tryCompare(app2Surface, "keymap", "fr");
2514 }
2514 }
2515
2515
2516+ function test_dragPanelToRestoreMaximizedWindow_data() {
2517+ return [
2518+ { tag: "with mouse", mouse: true },
2519+ { tag: "with touch", mouse: false }
2520+ ]
2521+ }
2522+
2516− function test_dragPanelToRestoreMaximizedWindow() {
2523+ function test_dragPanelToRestoreMaximizedWindow(data) {
2517 loadShell("desktop");
2524 loadShell("desktop");
2518 shell.usageScenario = "desktop";
2525 shell.usageScenario = "desktop";
2519 waitForRendering(shell);
2526 waitForRendering(shell);
2520 var panel = findChild(shell, "windowControlArea");
2527 var panel = findChild(shell, "windowControlArea");
2521 verify(panel);
2528 verify(panel);
2522
2529
2523− var appSurfaceId = topLevelSurfaceList.nextId;
2524− var app = ApplicationManager.startApplication("dialer-app")
2525− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2526−
2527 // start dialer, maximize it
2530 // start dialer, maximize it
2528− var appContainer = findChild(shell, "appContainer");
2531+ var appDelegate = startApplication("dialer-app");
2529− var appDelegate = findChild(appContainer, "appDelegate_" + appSurfaceId);
2530 verify(appDelegate);
2532 verify(appDelegate);
2533+
2531 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
2534 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
2535+ if (data.mouse) {
2532− mouseClick(maximizeButton);
2536+ mouseClick(maximizeButton);
2537+ } else {
2538+ tap(maximizeButton);
2539+ }
2533
2540
2534 tryCompare(appDelegate, "state", "maximized");
2541 tryCompare(appDelegate, "state", "maximized");
2535
2542
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);
2536− mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
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+
2537 tryCompare(appDelegate, "state", "restored");
2553 tryCompare(appDelegate, "state", "restored");
2538 }
2554 }
2539
2555
@@ -2964,5 +2980,70 @@ Rectangle {
2964 mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
2980 mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
2965 tryCompare(appDelegate, "state", "restored");
2981 tryCompare(appDelegate, "state", "restored");
2966 }
2982 }
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+ }
2967 }
3048 }
2968}
3049}