on xenial help sign in
merged parent
27a262bNick Dedekind
plugins/GlobalShortcut/globalshortcutregistry.cpp+19−2
@@ -21,6 +21,20 @@
21
21
22#include "globalshortcutregistry.h"
22#include "globalshortcutregistry.h"
23
23
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+
24GlobalShortcutRegistry::GlobalShortcutRegistry(QObject *parent)
38GlobalShortcutRegistry::GlobalShortcutRegistry(QObject *parent)
25 : QObject(parent)
39 : QObject(parent)
26{
40{
@@ -90,8 +104,11 @@ bool GlobalShortcutRegistry::eventFilter(QObject *obj, QEvent *event)
90 if (m_shortcuts.contains(seq)) {
104 if (m_shortcuts.contains(seq)) {
91 const auto shortcuts = m_shortcuts.value(seq);
105 const auto shortcuts = m_shortcuts.value(seq);
92 Q_FOREACH(const auto &shortcut, shortcuts) {
106 Q_FOREACH(const auto &shortcut, shortcuts) {
93− if (shortcut && shortcut->window() == obj) {
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.
94− qApp->sendEvent(shortcut, &eCopy);
110+ qApp->sendEvent(shortcut, &eCopy);
111+ }
95 }
112 }
96 }
113 }
97 }
114 }
qml/ApplicationMenus/ApplicationMenuItemFactory.qml+4−4
@@ -45,7 +45,7 @@ Object {
45
45
46 Action {
46 Action {
47 id: action
47 id: action
48− text: menuData.label.replace("_", "&")
48+ text: menuData && menuData.label.replace("_", "&") || ""
49 }
49 }
50
50
51 ListItemLayout {
51 ListItemLayout {
@@ -59,8 +59,8 @@ Object {
59 }
59 }
60
60
61 Label {
61 Label {
62− text: menuData.shortcut
62+ text: menuData && menuData.shortcut || ""
63− visible: menuData.shortcut && QuickUtils.keyboardAttached
63+ visible: menuData && menuData.shortcut && QuickUtils.keyboardAttached
64 SlotsLayout.position: SlotsLayout.Trailing
64 SlotsLayout.position: SlotsLayout.Trailing
65 color: enabled ? theme.palette.normal.backgroundSecondaryText :
65 color: enabled ? theme.palette.normal.backgroundSecondaryText :
66 theme.palette.disabled.backgroundSecondaryText
66 theme.palette.disabled.backgroundSecondaryText
@@ -86,7 +86,7 @@ Object {
86
86
87 Action {
87 Action {
88 id: action
88 id: action
89− text: menuData.label.replace("_", "&")
89+ text: menuData && menuData.label.replace("_", "&") || ""
90 }
90 }
91
91
92 ListItemLayout {
92 ListItemLayout {
qml/ApplicationMenus/MenuBar.qml+5−2
@@ -19,6 +19,7 @@ import QtQuick.Layouts 1.1
19import Utils 0.1
19import Utils 0.1
20import Ubuntu.Components 1.3
20import Ubuntu.Components 1.3
21import GlobalShortcut 1.0
21import GlobalShortcut 1.0
22+import "../Components/PanelState"
22
23
23Item {
24Item {
24 id: root
25 id: root
@@ -29,7 +30,7 @@ Item {
29 property bool enableKeyFilter: false
30 property bool enableKeyFilter: false
30 property real overflowWidth: width
31 property real overflowWidth: width
31 property bool windowMoving: false
32 property bool windowMoving: false
32− property var panelState: null
33+ property PanelState panelState
33
34
34 // read from outside
35 // read from outside
35 readonly property bool valid: rowRepeater.count > 0
36 readonly property bool valid: rowRepeater.count > 0
@@ -107,7 +108,9 @@ Item {
107
108
108 Component {
109 Component {
109 id: menuComponent
110 id: menuComponent
111+ MenuPopup {
110− MenuPopup { panelState: root.panelState }
112+ panelState: root.panelState
113+ }
111 }
114 }
112
115
113 Repeater {
116 Repeater {
qml/ApplicationMenus/MenuPopup.qml+2−2
@@ -26,7 +26,6 @@ UbuntuShape {
26 id: root
26 id: root
27 objectName: "menu"
27 objectName: "menu"
28 backgroundColor: theme.palette.normal.overlay
28 backgroundColor: theme.palette.normal.overlay
29− property PanelState panelState
30
29
31 signal childActivated()
30 signal childActivated()
32
31
@@ -65,6 +64,7 @@ UbuntuShape {
65 }
64 }
66
65
67 property alias unityMenuModel: repeater.model
66 property alias unityMenuModel: repeater.model
67+ property PanelState panelState
68
68
69 function show() {
69 function show() {
70 visible = true;
70 visible = true;
@@ -484,11 +484,11 @@ UbuntuShape {
484
484
485 onLoaded: {
485 onLoaded: {
486 item.unityMenuModel = Qt.binding(function() { return submenuLoader.unityMenuModel; });
486 item.unityMenuModel = Qt.binding(function() { return submenuLoader.unityMenuModel; });
487+ item.panelState = Qt.binding(function() { return root.panelState; });
487 item.objectName = Qt.binding(function() { return submenuLoader.objectName + "menu"; });
488 item.objectName = Qt.binding(function() { return submenuLoader.objectName + "menu"; });
488 item.desiredX = Qt.binding(function() { return submenuLoader.desiredX; });
489 item.desiredX = Qt.binding(function() { return submenuLoader.desiredX; });
489 item.desiredY = Qt.binding(function() { return submenuLoader.desiredY; });
490 item.desiredY = Qt.binding(function() { return submenuLoader.desiredY; });
490 item.substractWidth = Qt.binding(function() { return submenuLoader.substractWidth; });
491 item.substractWidth = Qt.binding(function() { return submenuLoader.substractWidth; });
491− item.panelState = Qt.binding(function() { return root.panelState; });
492 }
492 }
493
493
494 Keys.onLeftPressed: retreat()
494 Keys.onLeftPressed: retreat()
qml/OrientedShell.qml+1−1
@@ -261,7 +261,7 @@ Item {
261
261
262 Shell {
262 Shell {
263 id: shell
263 id: shell
264− objectName: "shell-"+screenWindow.objectName
264+ objectName: "shell"
265 width: root.width
265 width: root.width
266 height: root.height
266 height: root.height
267 orientation: root.angleToOrientation(orientationAngle)
267 orientation: root.angleToOrientation(orientationAngle)
qml/Panel/Panel.qml+2−2
@@ -221,7 +221,7 @@ Item {
221 sourceComponent: MenuBar {
221 sourceComponent: MenuBar {
222 id: bar
222 id: bar
223 objectName: "menuBar"
223 objectName: "menuBar"
224− anchors.left: parent.left
224+ anchors.left: menuBarLoader.left
225 anchors.margins: units.gu(1)
225 anchors.margins: units.gu(1)
226 height: menuBarLoader.height
226 height: menuBarLoader.height
227 enableKeyFilter: valid && panelState.decorationsVisible
227 enableKeyFilter: valid && panelState.decorationsVisible
@@ -345,7 +345,7 @@ Item {
345 opacity: __applicationMenus.visible && !__applicationMenus.expanded ? 1 : 0
345 opacity: __applicationMenus.visible && !__applicationMenus.expanded ? 1 : 0
346 visible: opacity != 0
346 visible: opacity != 0
347 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
347 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
348− text: PanelState.title
348+ text: panelState.title
349 }
349 }
350
350
351 PanelMenu {
351 PanelMenu {
qml/Shell.qml+1−3
@@ -45,7 +45,6 @@ import Unity.DashCommunicator 0.1
45import Unity.Indicators 0.1 as Indicators
45import Unity.Indicators 0.1 as Indicators
46import Cursor 1.1
46import Cursor 1.1
47import WindowManager 1.0
47import WindowManager 1.0
48−import Unity.Debug 0.1 as Debug
49
48
50
49
51StyledItem {
50StyledItem {
@@ -800,10 +799,9 @@ StyledItem {
800
799
801 Cursor {
800 Cursor {
802 id: cursor
801 id: cursor
803− objectName: "Pointer-"+screenWindow.objectName
802+ objectName: "cursor"
804
803
805 z: itemGrabber.z + 1
804 z: itemGrabber.z + 1
806− opacity: 0
807 topBoundaryOffset: panel.panelHeight
805 topBoundaryOffset: panel.panelHeight
808 enabled: shell.hasMouse && screenWindow.active
806 enabled: shell.hasMouse && screenWindow.active
809 visible: enabled
807 visible: enabled
tests/qmltests/ApplicationMenus/tst_MenuBar.qml+2
@@ -24,6 +24,7 @@ import Unity.Test 0.1
24import Utils 0.1
24import Utils 0.1
25
25
26import "../../../qml/ApplicationMenus"
26import "../../../qml/ApplicationMenus"
27+import "../../../qml/Components/PanelState"
27import ".."
28import ".."
28
29
29Item {
30Item {
@@ -65,6 +66,7 @@ Item {
65 id: menuBackend
66 id: menuBackend
66 modelData: appMenuData.generateTestData(10,5,2,3)
67 modelData: appMenuData.generateTestData(10,5,2,3)
67 }
68 }
69+ panelState: PanelState {}
68 }
70 }
69 }
71 }
70
72
tests/qmltests/ApplicationMenus/tst_MenuPopup.qml+2
@@ -24,6 +24,7 @@ import Unity.Test 0.1
24import Utils 0.1
24import Utils 0.1
25
25
26import "../../../qml/ApplicationMenus"
26import "../../../qml/ApplicationMenus"
27+import "../../../qml/Components/PanelState"
27import ".."
28import ".."
28
29
29Item {
30Item {
@@ -59,6 +60,7 @@ Item {
59 }}
60 }}
60 ]
61 ]
61 }
62 }
63+ panelState: PanelState {}
62 }
64 }
63 }
65 }
64
66
tests/qmltests/Panel/tst_Panel.qml+4−5
@@ -42,9 +42,7 @@ PanelTest {
42 value: keyboardAttached.checked
42 value: keyboardAttached.checked
43 }
43 }
44
44
45− readonly property var panelState: PanelState {
45+ readonly property alias panelState: panel.panelState
46−
47− }
48
46
49 ApplicationMenuDataLoader {
47 ApplicationMenuDataLoader {
50 id: appMenuData
48 id: appMenuData
@@ -88,7 +86,6 @@ PanelTest {
88
86
89 indicatorMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
87 indicatorMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
90 applicationMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
88 applicationMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
91− panelState: root.panelState
92
89
93 applicationMenus {
90 applicationMenus {
94 model: UnityMenuModel {
91 model: UnityMenuModel {
@@ -102,6 +99,8 @@ PanelTest {
102 model: root.indicatorsModel
99 model: root.indicatorsModel
103 hides: [ panel.applicationMenus ]
100 hides: [ panel.applicationMenus ]
104 }
101 }
102+
103+ panelState: PanelState {}
105 }
104 }
106 }
105 }
107 }
106 }
@@ -858,7 +857,7 @@ PanelTest {
858
857
859 var indicatorsBar = findChild(panel.applicationMenus, "indicatorsBar");
858 var indicatorsBar = findChild(panel.applicationMenus, "indicatorsBar");
860
859
861− root.panelState.title = "Fake Title"
860+ panelState.title = "Fake Title"
862 pullDownApplicationsMenu(0 /*xPos*/);
861 pullDownApplicationsMenu(0 /*xPos*/);
863 compare(aboutToShowCalledSpy.count, 1);
862 compare(aboutToShowCalledSpy.count, 1);
864
863
tests/qmltests/Stage/tst_DesktopStage.qml+5−8
@@ -44,10 +44,6 @@ Item {
44 value: false
44 value: false
45 }
45 }
46
46
47− PanelState {
48− id: panelStateObj
49− }
50−
51 Component.onCompleted: {
47 Component.onCompleted: {
52 ApplicationMenusLimits.screenWidth = Qt.binding( function() { return stageLoader.width; } );
48 ApplicationMenusLimits.screenWidth = Qt.binding( function() { return stageLoader.width; } );
53 ApplicationMenusLimits.screenHeight = Qt.binding( function() { return stageLoader.height; } );
49 ApplicationMenusLimits.screenHeight = Qt.binding( function() { return stageLoader.height; } );
@@ -100,7 +96,7 @@ Item {
100 topLevelSurfaceList: topSurfaceList
96 topLevelSurfaceList: topSurfaceList
101 interactive: true
97 interactive: true
102 mode: "windowed"
98 mode: "windowed"
103− panelState: panelStateObj
99+ panelState: PanelState {}
104 }
100 }
105 }
101 }
106 }
102 }
@@ -172,6 +168,7 @@ Item {
172
168
173 stage: stageLoader.status === Loader.Ready ? stageLoader.item : null
169 stage: stageLoader.status === Loader.Ready ? stageLoader.item : null
174 topLevelSurfaceList: topSurfaceList
170 topLevelSurfaceList: topSurfaceList
171+ property var panelState: stage ? stage.panelState : null
175
172
176 function init() {
173 function init() {
177 // wait until unity8-dash is up and running.
174 // wait until unity8-dash is up and running.
@@ -630,19 +627,19 @@ Item {
630 maximizeDelegate(facebookAppDelegate);
627 maximizeDelegate(facebookAppDelegate);
631
628
632 // verify the drop shadow is still not visible
629 // verify the drop shadow is still not visible
633− verify(panelStateObj.dropShadow == false);
630+ verify(panelState.dropShadow == false);
634
631
635 // start a foreground app, not maximized
632 // start a foreground app, not maximized
636 var dialerAppDelegate = startApplication("dialer-app");
633 var dialerAppDelegate = startApplication("dialer-app");
637
634
638 // verify the drop shadow becomes visible
635 // verify the drop shadow becomes visible
639− tryCompareFunction(function() { return panelStateObj.dropShadow; }, true);
636+ tryCompareFunction(function() { return panelState.dropShadow; }, true);
640
637
641 // close the maximized app
638 // close the maximized app
642 ApplicationManager.stopApplication("facebook-webapp");
639 ApplicationManager.stopApplication("facebook-webapp");
643
640
644 // verify the drop shadow is gone
641 // verify the drop shadow is gone
645− tryCompare(panelStateObj, "dropShadow", false);
642+ tryCompare(panelState, "dropShadow", false);
646 }
643 }
647
644
648 function test_threeFingerTapShowsWindowControls_data() {
645 function test_threeFingerTapShowsWindowControls_data() {
tests/qmltests/Stage/tst_PhoneStage.qml+2
@@ -19,6 +19,7 @@ import QtTest 1.0
19import Unity.Test 0.1 as UT
19import Unity.Test 0.1 as UT
20import ".."
20import ".."
21import "../../../qml/Components"
21import "../../../qml/Components"
22+import "../../../qml/Components/PanelState"
22import "../../../qml/Stage"
23import "../../../qml/Stage"
23import Ubuntu.Components 1.3
24import Ubuntu.Components 1.3
24import Unity.Application 0.1
25import Unity.Application 0.1
@@ -52,6 +53,7 @@ Item {
52 Component.onCompleted: {
53 Component.onCompleted: {
53 ApplicationManager.startApplication("unity8-dash");
54 ApplicationManager.startApplication("unity8-dash");
54 }
55 }
56+ panelState: PanelState {}
55 }
57 }
56
58
57 Flickable {
59 Flickable {
tests/qmltests/Tutorial/tst_Tutorial.qml+7−13
@@ -37,20 +37,10 @@ Rectangle {
37 height: units.gu(71)
37 height: units.gu(71)
38
38
39 QtObject {
39 QtObject {
40− id: applicationArguments
40+ id: _screenWindow
41−
41+ property bool primary: true
42− function hasGeometry() {
43− return false;
44− }
45−
46− function width() {
47− return 0;
48− }
49−
50− function height() {
51− return 0;
52− }
53 }
42 }
43+ property alias screenWindow: _screenWindow
54
44
55 Telephony.CallEntry {
45 Telephony.CallEntry {
56 id: phoneCall
46 id: phoneCall
@@ -154,6 +144,10 @@ Rectangle {
154 Component.onDestruction: {
144 Component.onDestruction: {
155 shellLoader.itemDestroyed = true;
145 shellLoader.itemDestroyed = true;
156 }
146 }
147+ SurfaceManager {
148+ id: surfaceMan
149+ }
150+ surfaceManager: surfaceMan
157 }
151 }
158 }
152 }
159 }
153 }
tests/qmltests/tst_OrientedShell.qml+1
@@ -1477,6 +1477,7 @@ Rectangle {
1477 removeTimeConstraintsFromSwipeAreas(orientedShellLoader.item);
1477 removeTimeConstraintsFromSwipeAreas(orientedShellLoader.item);
1478
1478
1479 shell = findChild(orientedShell, "shell");
1479 shell = findChild(orientedShell, "shell");
1480+ verify(shell);
1480
1481
1481 topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
1482 topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
1482 verify(topLevelSurfaceList);
1483 verify(topLevelSurfaceList);
tests/qmltests/tst_Shell.qml+7−8
@@ -38,7 +38,6 @@ import Unity.Indicators 0.1 as Indicators
38
38
39import "../../qml"
39import "../../qml"
40import "../../qml/Components"
40import "../../qml/Components"
41−import "../../qml/Components/PanelState"
42import "Stage"
41import "Stage"
43
42
44Rectangle {
43Rectangle {
@@ -64,12 +63,12 @@ Rectangle {
64 panelState = testCase.findInvisibleChild(shell, "panelState");
63 panelState = testCase.findInvisibleChild(shell, "panelState");
65 } else {
64 } else {
66 topLevelSurfaceList = null;
65 topLevelSurfaceList = null;
67− panelState = undefined;
66+ panelState = null;
68 }
67 }
69 }
68 }
70
69
71 property var topLevelSurfaceList: null
70 property var topLevelSurfaceList: null
72− property var panelState: undefined
71+ property var panelState: null
73
72
74 QtObject {
73 QtObject {
75 id: _screenWindow
74 id: _screenWindow
@@ -2657,9 +2656,9 @@ Rectangle {
2657
2656
2658 function test_oskDisplacesWindow_data() {
2657 function test_oskDisplacesWindow_data() {
2659 return [
2658 return [
2660− {tag: "no need to displace", windowHeight: units.gu(10), windowY: units.gu(5), targetDisplacement: units.gu(5), oskEnabled: true},
2659+ {tag: "no need to displace", windowHeight: units.gu(10), windowY: units.gu(5), targetDisplacement: function() { return units.gu(5); }, oskEnabled: true},
2661− {tag: "displace to top", windowHeight: units.gu(50), windowY: units.gu(10), targetDisplacement: panelState.panelHeight, oskEnabled: true},
2660+ {tag: "displace to top", windowHeight: units.gu(50), windowY: units.gu(10), targetDisplacement: function() { return 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},
2661+ {tag: "osk not on this screen", windowHeight: units.gu(40), windowY: units.gu(10), targetDisplacement: function() { return units.gu(10); }, oskEnabled: false},
2663 ]
2662 ]
2664 }
2663 }
2665
2664
@@ -2685,7 +2684,7 @@ Rectangle {
2685 verify(initialY > panelState.panelHeight);
2684 verify(initialY > panelState.panelHeight);
2686
2685
2687 topLevelSurfaceList.inputMethodSurface.setInputBounds(Qt.rect(0, root.height / 2, root.width, root.height / 2));
2686 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());
2689
2688
2690 topLevelSurfaceList.inputMethodSurface.setInputBounds(Qt.rect(0, 0, 0, 0));
2689 topLevelSurfaceList.inputMethodSurface.setInputBounds(Qt.rect(0, 0, 0, 0));
2691 tryCompare(dashAppDelegate, "y", initialY);
2690 tryCompare(dashAppDelegate, "y", initialY);
@@ -3118,7 +3117,7 @@ Rectangle {
3118 // double click the panel
3117 // double click the panel
3119 var panel = findChild(shell, "panel");
3118 var panel = findChild(shell, "panel");
3120 verify(panel);
3119 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);
3122 tryCompare(appDelegate, "state", "restored");
3121 tryCompare(appDelegate, "state", "restored");
3123 }
3122 }
3124
3123
tests/qmltests/tst_ShellWithPin.qml+7−13
@@ -41,20 +41,10 @@ Item {
41 }
41 }
42
42
43 QtObject {
43 QtObject {
44− id: applicationArguments
44+ id: _screenWindow
45−
45+ property bool primary: true
46− function hasGeometry() {
47− return false;
48− }
49−
50− function width() {
51− return 0;
52− }
53−
54− function height() {
55− return 0;
56− }
57 }
46 }
47+ property alias screenWindow: _screenWindow
58
48
59 Row {
49 Row {
60 id: contentRow
50 id: contentRow
@@ -73,6 +63,10 @@ Item {
73 Component.onDestruction: {
63 Component.onDestruction: {
74 shellLoader.itemDestroyed = true
64 shellLoader.itemDestroyed = true
75 }
65 }
66+ SurfaceManager {
67+ id: surfaceMan
68+ }
69+ surfaceManager: surfaceMan
76 }
70 }
77 }
71 }
78 }
72 }