on xenial help sign in
Fix unsnapping a maximized window from the panel (LP: #1671721)

Approved by: Albert Astals Cid, Michał Sawicz, Unity8 CI Bot

commitfa02b87fe5983b59a1f79fc8e11f5042d7bdfae3 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateTue 21 Mar 2017, 10:53 (10 years ago) parentfd8148aefb4a50
3 files changed+104−11
qml/ApplicationMenus/MenuBar.qml+5 qml/Panel/Panel.qml+8−2 tests/qmltests/tst_Shell.qml+91−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+8−2
@@ -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,16 +204,17 @@ Item {
200204
201205 Loader {
202206 id: menuBarLoader
207+ objectName: "menuBarLoader"
203208 height: parent.height
204209 enabled: d.enablePointerMenu
205210 opacity: d.showPointerMenu ? 1 : 0
206211 visible: opacity != 0
207212 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
208− active: __applicationMenus.model
213+ active: __applicationMenus.model && !callHint.visible
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+91−9
@@ -2513,27 +2513,44 @@ 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
2541+ waitUntilTransitionsEnd(appDelegate);
25342542 tryCompare(appDelegate, "state", "maximized");
25352543
2536− mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2544+ if (data.mouse) {
2545+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
2546+ var menuBarLoader = findInvisibleChild(panel, "menuBarLoader");
2547+ verify(menuBarLoader);
2548+ tryCompare(menuBarLoader.item, "visible", true);
2549+ mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2550+ } else {
2551+ touchFlick(panel, panel.width/2, panel.panelHeight/2, panel.width/2, shell.height/3);
2552+ }
2553+
25372554 tryCompare(appDelegate, "state", "restored");
25382555 }
25392556
@@ -3044,5 +3061,70 @@ Rectangle {
30443061 mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
30453062 tryCompare(appDelegate, "state", "restored");
30463063 }
3064+
3065+ function test_noMenusWithActiveCall() {
3066+ loadShell("desktop");
3067+ shell.usageScenario = "desktop";
3068+ waitForRendering(shell);
3069+ swipeAwayGreeter();
3070+
3071+ // start music-app, maximize it
3072+ var appDelegate = startApplication("music-app")
3073+ verify(appDelegate);
3074+ appDelegate.requestMaximize();
3075+
3076+ // move the mouse over panel to reveal the menus
3077+ var panel = findChild(shell, "panel");
3078+ verify(panel);
3079+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3080+ var menuBarLoader = findInvisibleChild(panel, "menuBarLoader");
3081+ verify(menuBarLoader);
3082+ tryCompare(menuBarLoader.item, "visible", true);
3083+
3084+ // place a phone call
3085+ callManager.foregroundCall = phoneCall;
3086+
3087+ // menu bar should be hidden
3088+ tryCompare(menuBarLoader, "active", false);
3089+ tryCompare(menuBarLoader, "item", null);
3090+
3091+ // remove call
3092+ callManager.foregroundCall = null;
3093+
3094+ // menu bar should be revealed
3095+ tryCompare(menuBarLoader, "active", true);
3096+ tryCompare(menuBarLoader.item, "visible", true);
3097+ }
3098+
3099+ function test_maximizedWindowAndMenuInPanel() {
3100+ loadShell("desktop");
3101+ shell.usageScenario = "desktop";
3102+ waitForRendering(shell);
3103+ swipeAwayGreeter();
3104+
3105+ // start music-app, maximize it
3106+ var appDelegate = startApplication("music-app")
3107+ verify(appDelegate);
3108+ appDelegate.requestMaximize();
3109+ tryCompare(appDelegate, "state", "maximized");
3110+
3111+ // move the mouse over panel to reveal the menus
3112+ var panel = findChild(shell, "panel");
3113+ verify(panel);
3114+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3115+ var menuBar = findChild(panel, "menuBar");
3116+ verify(menuBar);
3117+ tryCompare(menuBar, "visible", true);
3118+
3119+ // check that the menu popup appears
3120+ var priv = findInvisibleChild(menuBar, "d");
3121+ var menuItem0 = findChild(menuBar, "menuBar-item0");
3122+ verify(menuItem0);
3123+ mouseMove(menuItem0, menuItem0.width/2, menuItem0.height/2, 200);
3124+ tryCompare(menuItem0, "visible", true);
3125+ mouseClick(menuItem0);
3126+ tryCompare(priv, "currentItem", menuItem0);
3127+ tryCompare(priv.currentItem, "popupVisible", true);
3128+ }
30473129 }
30483130}