on xenial help sign in
merged parent
commit27a262bad16f963ac6cb69f4a517674046187600 authorNick Dedekind <nick.dedekind@canonical.com> dateWed 29 Mar 2017, 08:53 (10 years ago) parent1897f1003ae81f
16 files changed+71−63
plugins/GlobalShortcut/globalshortcutregistry.cpp+19−2 qml/ApplicationMenus/ApplicationMenuItemFactory.qml+4−4 qml/ApplicationMenus/MenuBar.qml+5−2 qml/ApplicationMenus/MenuPopup.qml+2−2 qml/OrientedShell.qml+1−1 qml/Panel/Panel.qml+2−2 qml/Shell.qml+1−3 tests/qmltests/ApplicationMenus/tst_MenuBar.qml+2 tests/qmltests/ApplicationMenus/tst_MenuPopup.qml+2 tests/qmltests/Panel/tst_Panel.qml+4−5 tests/qmltests/Stage/tst_DesktopStage.qml+5−8 tests/qmltests/Stage/tst_PhoneStage.qml+2 tests/qmltests/Tutorial/tst_Tutorial.qml+7−13 tests/qmltests/tst_OrientedShell.qml+1 tests/qmltests/tst_Shell.qml+7−8 tests/qmltests/tst_ShellWithPin.qml+7−13
plugins/GlobalShortcut/globalshortcutregistry.cpp+19−2
@@ -21,6 +21,20 @@
2121
2222#include "globalshortcutregistry.h"
2323
24+namespace {
25+QWindow* windowForShortcut(GlobalShortcut *sc) {
26+ QObject* parent= sc;
27+ while(parent) {
28+ if (auto item = qobject_cast<QQuickItem*>(parent)) {
29+ auto window = item->window();
30+ if (window) return window;
31+ }
32+ parent = parent->parent();
33+ }
34+ return nullptr;
35+}
36+} // namespace
37+
2438GlobalShortcutRegistry::GlobalShortcutRegistry(QObject *parent)
2539 : QObject(parent)
2640{
@@ -90,8 +104,11 @@ bool GlobalShortcutRegistry::eventFilter(QObject *obj, QEvent *event)
90104 if (m_shortcuts.contains(seq)) {
91105 const auto shortcuts = m_shortcuts.value(seq);
92106 Q_FOREACH(const auto &shortcut, shortcuts) {
93− if (shortcut && shortcut->window() == obj) {
94− qApp->sendEvent(shortcut, &eCopy);
107+ if (shortcut) {
108+ auto window = windowForShortcut(shortcut);
109+ if (!window || window == obj) { // accept shortcut if it's not attached to a window or it's window is active.
110+ qApp->sendEvent(shortcut, &eCopy);
111+ }
95112 }
96113 }
97114 }
qml/ApplicationMenus/ApplicationMenuItemFactory.qml+4−4
@@ -45,7 +45,7 @@ Object {
4545
4646 Action {
4747 id: action
48− text: menuData.label.replace("_", "&")
48+ text: menuData && menuData.label.replace("_", "&") || ""
4949 }
5050
5151 ListItemLayout {
@@ -59,8 +59,8 @@ Object {
5959 }
6060
6161 Label {
62− text: menuData.shortcut
63− visible: menuData.shortcut && QuickUtils.keyboardAttached
62+ text: menuData && menuData.shortcut || ""
63+ visible: menuData && menuData.shortcut && QuickUtils.keyboardAttached
6464 SlotsLayout.position: SlotsLayout.Trailing
6565 color: enabled ? theme.palette.normal.backgroundSecondaryText :
6666 theme.palette.disabled.backgroundSecondaryText
@@ -86,7 +86,7 @@ Object {
8686
8787 Action {
8888 id: action
89− text: menuData.label.replace("_", "&")
89+ text: menuData && menuData.label.replace("_", "&") || ""
9090 }
9191
9292 ListItemLayout {
qml/ApplicationMenus/MenuBar.qml+5−2
@@ -19,6 +19,7 @@ import QtQuick.Layouts 1.1
1919import Utils 0.1
2020import Ubuntu.Components 1.3
2121import GlobalShortcut 1.0
22+import "../Components/PanelState"
2223
2324Item {
2425 id: root
@@ -29,7 +30,7 @@ Item {
2930 property bool enableKeyFilter: false
3031 property real overflowWidth: width
3132 property bool windowMoving: false
32− property var panelState: null
33+ property PanelState panelState
3334
3435 // read from outside
3536 readonly property bool valid: rowRepeater.count > 0
@@ -107,7 +108,9 @@ Item {
107108
108109 Component {
109110 id: menuComponent
110− MenuPopup { panelState: root.panelState }
111+ MenuPopup {
112+ panelState: root.panelState
113+ }
111114 }
112115
113116 Repeater {
qml/ApplicationMenus/MenuPopup.qml+2−2
@@ -26,7 +26,6 @@ UbuntuShape {
2626 id: root
2727 objectName: "menu"
2828 backgroundColor: theme.palette.normal.overlay
29− property PanelState panelState
3029
3130 signal childActivated()
3231
@@ -65,6 +64,7 @@ UbuntuShape {
6564 }
6665
6766 property alias unityMenuModel: repeater.model
67+ property PanelState panelState
6868
6969 function show() {
7070 visible = true;
@@ -484,11 +484,11 @@ UbuntuShape {
484484
485485 onLoaded: {
486486 item.unityMenuModel = Qt.binding(function() { return submenuLoader.unityMenuModel; });
487+ item.panelState = Qt.binding(function() { return root.panelState; });
487488 item.objectName = Qt.binding(function() { return submenuLoader.objectName + "menu"; });
488489 item.desiredX = Qt.binding(function() { return submenuLoader.desiredX; });
489490 item.desiredY = Qt.binding(function() { return submenuLoader.desiredY; });
490491 item.substractWidth = Qt.binding(function() { return submenuLoader.substractWidth; });
491− item.panelState = Qt.binding(function() { return root.panelState; });
492492 }
493493
494494 Keys.onLeftPressed: retreat()
qml/OrientedShell.qml+1−1
@@ -261,7 +261,7 @@ Item {
261261
262262 Shell {
263263 id: shell
264− objectName: "shell-"+screenWindow.objectName
264+ objectName: "shell"
265265 width: root.width
266266 height: root.height
267267 orientation: root.angleToOrientation(orientationAngle)
qml/Panel/Panel.qml+2−2
@@ -221,7 +221,7 @@ Item {
221221 sourceComponent: MenuBar {
222222 id: bar
223223 objectName: "menuBar"
224− anchors.left: parent.left
224+ anchors.left: menuBarLoader.left
225225 anchors.margins: units.gu(1)
226226 height: menuBarLoader.height
227227 enableKeyFilter: valid && panelState.decorationsVisible
@@ -345,7 +345,7 @@ Item {
345345 opacity: __applicationMenus.visible && !__applicationMenus.expanded ? 1 : 0
346346 visible: opacity != 0
347347 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
348− text: PanelState.title
348+ text: panelState.title
349349 }
350350
351351 PanelMenu {
qml/Shell.qml+1−3
@@ -45,7 +45,6 @@ import Unity.DashCommunicator 0.1
4545import Unity.Indicators 0.1 as Indicators
4646import Cursor 1.1
4747import WindowManager 1.0
48−import Unity.Debug 0.1 as Debug
4948
5049
5150StyledItem {
@@ -800,10 +799,9 @@ StyledItem {
800799
801800 Cursor {
802801 id: cursor
803− objectName: "Pointer-"+screenWindow.objectName
802+ objectName: "cursor"
804803
805804 z: itemGrabber.z + 1
806− opacity: 0
807805 topBoundaryOffset: panel.panelHeight
808806 enabled: shell.hasMouse && screenWindow.active
809807 visible: enabled
tests/qmltests/ApplicationMenus/tst_MenuBar.qml+2
@@ -24,6 +24,7 @@ import Unity.Test 0.1
2424import Utils 0.1
2525
2626import "../../../qml/ApplicationMenus"
27+import "../../../qml/Components/PanelState"
2728import ".."
2829
2930Item {
@@ -65,6 +66,7 @@ Item {
6566 id: menuBackend
6667 modelData: appMenuData.generateTestData(10,5,2,3)
6768 }
69+ panelState: PanelState {}
6870 }
6971 }
7072
tests/qmltests/ApplicationMenus/tst_MenuPopup.qml+2
@@ -24,6 +24,7 @@ import Unity.Test 0.1
2424import Utils 0.1
2525
2626import "../../../qml/ApplicationMenus"
27+import "../../../qml/Components/PanelState"
2728import ".."
2829
2930Item {
@@ -59,6 +60,7 @@ Item {
5960 }}
6061 ]
6162 }
63+ panelState: PanelState {}
6264 }
6365 }
6466
tests/qmltests/Panel/tst_Panel.qml+4−5
@@ -42,9 +42,7 @@ PanelTest {
4242 value: keyboardAttached.checked
4343 }
4444
45− readonly property var panelState: PanelState {
46−
47− }
45+ readonly property alias panelState: panel.panelState
4846
4947 ApplicationMenuDataLoader {
5048 id: appMenuData
@@ -88,7 +86,6 @@ PanelTest {
8886
8987 indicatorMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
9088 applicationMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
91− panelState: root.panelState
9289
9390 applicationMenus {
9491 model: UnityMenuModel {
@@ -102,6 +99,8 @@ PanelTest {
10299 model: root.indicatorsModel
103100 hides: [ panel.applicationMenus ]
104101 }
102+
103+ panelState: PanelState {}
105104 }
106105 }
107106 }
@@ -858,7 +857,7 @@ PanelTest {
858857
859858 var indicatorsBar = findChild(panel.applicationMenus, "indicatorsBar");
860859
861− root.panelState.title = "Fake Title"
860+ panelState.title = "Fake Title"
862861 pullDownApplicationsMenu(0 /*xPos*/);
863862 compare(aboutToShowCalledSpy.count, 1);
864863
tests/qmltests/Stage/tst_DesktopStage.qml+5−8
@@ -44,10 +44,6 @@ Item {
4444 value: false
4545 }
4646
47− PanelState {
48− id: panelStateObj
49− }
50−
5147 Component.onCompleted: {
5248 ApplicationMenusLimits.screenWidth = Qt.binding( function() { return stageLoader.width; } );
5349 ApplicationMenusLimits.screenHeight = Qt.binding( function() { return stageLoader.height; } );
@@ -100,7 +96,7 @@ Item {
10096 topLevelSurfaceList: topSurfaceList
10197 interactive: true
10298 mode: "windowed"
103− panelState: panelStateObj
99+ panelState: PanelState {}
104100 }
105101 }
106102 }
@@ -172,6 +168,7 @@ Item {
172168
173169 stage: stageLoader.status === Loader.Ready ? stageLoader.item : null
174170 topLevelSurfaceList: topSurfaceList
171+ property var panelState: stage ? stage.panelState : null
175172
176173 function init() {
177174 // wait until unity8-dash is up and running.
@@ -630,19 +627,19 @@ Item {
630627 maximizeDelegate(facebookAppDelegate);
631628
632629 // verify the drop shadow is still not visible
633− verify(panelStateObj.dropShadow == false);
630+ verify(panelState.dropShadow == false);
634631
635632 // start a foreground app, not maximized
636633 var dialerAppDelegate = startApplication("dialer-app");
637634
638635 // verify the drop shadow becomes visible
639− tryCompareFunction(function() { return panelStateObj.dropShadow; }, true);
636+ tryCompareFunction(function() { return panelState.dropShadow; }, true);
640637
641638 // close the maximized app
642639 ApplicationManager.stopApplication("facebook-webapp");
643640
644641 // verify the drop shadow is gone
645− tryCompare(panelStateObj, "dropShadow", false);
642+ tryCompare(panelState, "dropShadow", false);
646643 }
647644
648645 function test_threeFingerTapShowsWindowControls_data() {
tests/qmltests/Stage/tst_PhoneStage.qml+2
@@ -19,6 +19,7 @@ import QtTest 1.0
1919import Unity.Test 0.1 as UT
2020import ".."
2121import "../../../qml/Components"
22+import "../../../qml/Components/PanelState"
2223import "../../../qml/Stage"
2324import Ubuntu.Components 1.3
2425import Unity.Application 0.1
@@ -52,6 +53,7 @@ Item {
5253 Component.onCompleted: {
5354 ApplicationManager.startApplication("unity8-dash");
5455 }
56+ panelState: PanelState {}
5557 }
5658
5759 Flickable {
tests/qmltests/Tutorial/tst_Tutorial.qml+7−13
@@ -37,20 +37,10 @@ Rectangle {
3737 height: units.gu(71)
3838
3939 QtObject {
40− id: applicationArguments
41−
42− function hasGeometry() {
43− return false;
44− }
45−
46− function width() {
47− return 0;
48− }
49−
50− function height() {
51− return 0;
52− }
40+ id: _screenWindow
41+ property bool primary: true
5342 }
43+ property alias screenWindow: _screenWindow
5444
5545 Telephony.CallEntry {
5646 id: phoneCall
@@ -154,6 +144,10 @@ Rectangle {
154144 Component.onDestruction: {
155145 shellLoader.itemDestroyed = true;
156146 }
147+ SurfaceManager {
148+ id: surfaceMan
149+ }
150+ surfaceManager: surfaceMan
157151 }
158152 }
159153 }
tests/qmltests/tst_OrientedShell.qml+1
@@ -1477,6 +1477,7 @@ Rectangle {
14771477 removeTimeConstraintsFromSwipeAreas(orientedShellLoader.item);
14781478
14791479 shell = findChild(orientedShell, "shell");
1480+ verify(shell);
14801481
14811482 topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
14821483 verify(topLevelSurfaceList);
tests/qmltests/tst_Shell.qml+7−8
@@ -38,7 +38,6 @@ import Unity.Indicators 0.1 as Indicators
3838
3939import "../../qml"
4040import "../../qml/Components"
41−import "../../qml/Components/PanelState"
4241import "Stage"
4342
4443Rectangle {
@@ -64,12 +63,12 @@ Rectangle {
6463 panelState = testCase.findInvisibleChild(shell, "panelState");
6564 } else {
6665 topLevelSurfaceList = null;
67− panelState = undefined;
66+ panelState = null;
6867 }
6968 }
7069
7170 property var topLevelSurfaceList: null
72− property var panelState: undefined
71+ property var panelState: null
7372
7473 QtObject {
7574 id: _screenWindow
@@ -2657,9 +2656,9 @@ Rectangle {
26572656
26582657 function test_oskDisplacesWindow_data() {
26592658 return [
2660− {tag: "no need to displace", windowHeight: units.gu(10), windowY: units.gu(5), targetDisplacement: units.gu(5), oskEnabled: true},
2661− {tag: "displace to top", windowHeight: units.gu(50), windowY: units.gu(10), targetDisplacement: panelState.panelHeight, oskEnabled: true},
2662− {tag: "osk not on this screen", windowHeight: units.gu(40), windowY: units.gu(10), targetDisplacement: units.gu(10), oskEnabled: false},
2659+ {tag: "no need to displace", windowHeight: units.gu(10), windowY: units.gu(5), targetDisplacement: function() { return units.gu(5); }, oskEnabled: true},
2660+ {tag: "displace to top", windowHeight: units.gu(50), windowY: units.gu(10), targetDisplacement: function() { return panelState.panelHeight; }, oskEnabled: true},
2661+ {tag: "osk not on this screen", windowHeight: units.gu(40), windowY: units.gu(10), targetDisplacement: function() { return units.gu(10); }, oskEnabled: false},
26632662 ]
26642663 }
26652664
@@ -2685,7 +2684,7 @@ Rectangle {
26852684 verify(initialY > panelState.panelHeight);
26862685
26872686 topLevelSurfaceList.inputMethodSurface.setInputBounds(Qt.rect(0, root.height / 2, root.width, root.height / 2));
2688− tryCompare(dashAppDelegate, "y", data.targetDisplacement);
2687+ tryCompare(dashAppDelegate, "y", data.targetDisplacement());
26892688
26902689 topLevelSurfaceList.inputMethodSurface.setInputBounds(Qt.rect(0, 0, 0, 0));
26912690 tryCompare(dashAppDelegate, "y", initialY);
@@ -3118,7 +3117,7 @@ Rectangle {
31183117 // double click the panel
31193118 var panel = findChild(shell, "panel");
31203119 verify(panel);
3121− mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
3120+ mouseDoubleClickSequence(panel, panel.width/2, panelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
31223121 tryCompare(appDelegate, "state", "restored");
31233122 }
31243123
tests/qmltests/tst_ShellWithPin.qml+7−13
@@ -41,20 +41,10 @@ Item {
4141 }
4242
4343 QtObject {
44− id: applicationArguments
45−
46− function hasGeometry() {
47− return false;
48− }
49−
50− function width() {
51− return 0;
52− }
53−
54− function height() {
55− return 0;
56− }
44+ id: _screenWindow
45+ property bool primary: true
5746 }
47+ property alias screenWindow: _screenWindow
5848
5949 Row {
6050 id: contentRow
@@ -73,6 +63,10 @@ Item {
7363 Component.onDestruction: {
7464 shellLoader.itemDestroyed = true
7565 }
66+ SurfaceManager {
67+ id: surfaceMan
68+ }
69+ surfaceManager: surfaceMan
7670 }
7771 }
7872 }