on xenial help sign in
Sanitize the logic for pointer vs. touch menus, fixes hiding the window title in staged mode, when hovering the panel with mouse and no menus available.

Also enable the binding for PanelState.decorationsVisible only in windowed mode; the panel otherwise still displays the window controls in staged mode for apps that have been started in windowed mode. Approved by: Albert Astals Cid, Unity8 CI Bot

commit81e8b93115ba8f160d88091a70d75610787f0620 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateTue 4 Apr 2017, 22:54 (10 years ago) parent756d062f992477
6 files changed+17−40
qml/Panel/Panel.qml+8−8 qml/Stage/DecoratedWindow.qml+1 qml/Stage/Stage.qml+3−2 qml/Stage/WindowDecoration.qml+1 tests/qmltests/Panel/tst_Panel.qml+3−25 tests/qmltests/Stage/tst_DesktopStage.qml+1−5
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+3−2
@@ -390,7 +390,7 @@ FocusScope {
390390 Binding {
391391 target: PanelState
392392 property: "decorationsVisible"
393− value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.maximized // FIXME for Locally integrated menus
393+ value: mode == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.maximized && !root.spreadShown
394394 }
395395
396396 Binding {
@@ -1384,6 +1384,7 @@ FocusScope {
13841384 requestedHeight: appContainer.height;
13851385 }
13861386 PropertyChanges { target: touchControls; enabled: true }
1387+ PropertyChanges { target: decoratedWindow; windowControlButtonsVisible: false }
13871388 },
13881389 State {
13891390 name: "fullscreen"; when: appDelegate.fullscreen && !appDelegate.minimized
@@ -1405,7 +1406,7 @@ FocusScope {
14051406 }
14061407 PropertyChanges { target: touchControls; enabled: true }
14071408 PropertyChanges { target: resizeArea; enabled: true }
1408− PropertyChanges { target: decoratedWindow; shadowOpacity: .3}
1409+ PropertyChanges { target: decoratedWindow; shadowOpacity: .3; windowControlButtonsVisible: true}
14091410 },
14101411 State {
14111412 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
@@ -870,11 +870,7 @@ Item {
870870 maximizeAppDelegate(appDelegate);
871871
872872 // Close the window and restart the application
873− var closeButton = findChild(appDelegate, "closeWindowButton");
874− appDelegate = null;
875− verify(closeButton);
876− mouseClick(closeButton);
877− closeButton = null;
873+ appDelegate.close();
878874 tryCompare(topSurfaceList, "count", originalWindowCount);
879875 wait(100); // plus some spare room
880876 appDelegate = startApplication("dialer-app");