on xenial help sign in
do not let mouse and wheel events pass thru the titlebar
d311bc0Lukáš Tinkl
qml/Stages/WindowDecoration.qml+4−1
@@ -23,11 +23,11 @@ import "../Components/PanelState"
23MouseArea {
23MouseArea {
24 id: root
24 id: root
25 clip: true
25 clip: true
26+ acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
26
27
27 property Item target
28 property Item target
28 property alias title: titleLabel.text
29 property alias title: titleLabel.text
29 property bool active: false
30 property bool active: false
30− hoverEnabled: true
31
31
32 signal closeClicked()
32 signal closeClicked()
33 signal minimizeClicked()
33 signal minimizeClicked()
@@ -65,6 +65,9 @@ MouseArea {
65 }
65 }
66 }
66 }
67
67
68+ // do not let unhandled wheel event pass thru the decoration
69+ onWheel: wheel.accepted = true;
70+
68 Rectangle {
71 Rectangle {
69 anchors.fill: parent
72 anchors.fill: parent
70 anchors.bottomMargin: -radius
73 anchors.bottomMargin: -radius
tests/qmltests/Stages/tst_DesktopStage.qml+41
@@ -89,6 +89,15 @@ Item {
89 topLevelSurfaceList: topSurfaceList
89 topLevelSurfaceList: topSurfaceList
90 }
90 }
91 }
91 }
92+
93+ MouseArea {
94+ id: fakeMouseArea
95+ anchors.fill: desktopStageLoader.item
96+ enabled: desktopStageLoader.status === Loader.Ready && testCase.running
97+ visible: enabled
98+ acceptedButtons: Qt.AllButtons
99+ hoverEnabled: true
100+ }
92 }
101 }
93
102
94 Rectangle {
103 Rectangle {
@@ -140,6 +149,11 @@ Item {
140 }
149 }
141 }
150 }
142
151
152+ SignalSpy {
153+ id: mouseEaterSpy
154+ target: fakeMouseArea
155+ }
156+
143 UnityTestCase {
157 UnityTestCase {
144 id: testCase
158 id: testCase
145 name: "DesktopStage"
159 name: "DesktopStage"
@@ -179,6 +193,7 @@ Item {
179 desktopStageLoader.active = true;
193 desktopStageLoader.active = true;
180 tryCompare(desktopStageLoader, "status", Loader.Ready);
194 tryCompare(desktopStageLoader, "status", Loader.Ready);
181
195
196+ mouseEaterSpy.clear();
182 }
197 }
183
198
184 function waitUntilAppSurfaceShowsUp(surfaceId) {
199 function waitUntilAppSurfaceShowsUp(surfaceId) {
@@ -654,5 +669,31 @@ Item {
654 var closeButton = findChild(dashAppDelegate, "closeWindowButton");
669 var closeButton = findChild(dashAppDelegate, "closeWindowButton");
655 tryCompare(closeButton, "visible", false);
670 tryCompare(closeButton, "visible", false);
656 }
671 }
672+
673+ function test_eatWindowDecorationMouseEvents_data() {
674+ return [
675+ {tag: "left mouse press", signalName: "clicked", button: Qt.LeftButton },
676+ {tag: "right mouse press", signalName: "clicked", button: Qt.RightButton },
677+ {tag: "middle mouse press", signalName: "clicked", button: Qt.MiddleButton },
678+ {tag: "mouse wheel", signalName: "wheel", button: Qt.MiddleButton }
679+ ]
680+ }
681+
682+ function test_eatWindowDecorationMouseEvents(data) {
683+ var dialerAppDelegate = startApplication("dialer-app");
684+ verify(dialerAppDelegate);
685+ var decoration = findChild(dialerAppDelegate, "appWindowDecoration");
686+ verify(decoration);
687+
688+ fakeMouseArea.enabled = true;
689+ mouseEaterSpy.signalName = data.signalName;
690+ if (data.signalName === "wheel") {
691+ mouseWheel(decoration, decoration.width/2, decoration.height/2, 20, 20);
692+ } else {
693+ mouseClick(decoration, decoration.width/2, decoration.height/2, data.button);
694+ }
695+ tryCompare(mouseEaterSpy, "count", 0);
696+ fakeMouseArea.enabled = false;
697+ }
657 }
698 }
658}
699}