on xenial help sign in
Make indicators bar eat all events
d9c2596Daniel d'Andrada
qml/Panel/Panel.qml+5−3
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013-2014 Canonical, Ltd.
2+ * Copyright (C) 2013-2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -90,6 +90,9 @@ Item {
90 right: indicators.left
90 right: indicators.left
91 }
91 }
92 saturation: 1 - indicators.unitProgress
92 saturation: 1 - indicators.unitProgress
93+
94+ // Don't let input event pass trough
95+ MouseArea { anchors.fill: parent }
93 }
96 }
94
97
95 Image {
98 Image {
@@ -110,8 +113,7 @@ Item {
110 right: indicators.left
113 right: indicators.left
111 }
114 }
112 height: indicators.minimizedPanelHeight
115 height: indicators.minimizedPanelHeight
113− enabled: callHint.visible
114− onClicked: callHint.showLiveCall()
116+ onClicked: { if (callHint.visible) { callHint.showLiveCall(); } }
115 }
117 }
116
118
117 IndicatorsMenu {
119 IndicatorsMenu {
tests/qmltests/Panel/tst_Panel.qml+33−2
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013-2014 Canonical Ltd.
2+ * Copyright 2013-2015 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -41,7 +41,12 @@ IndicatorTest {
41 Layout.fillHeight: true
41 Layout.fillHeight: true
42
42
43 id: itemArea
43 id: itemArea
44− color: "blue"
44+ color: backgroundMouseArea.pressed ? "red" : "blue"
45+
46+ MouseArea {
47+ id: backgroundMouseArea
48+ anchors.fill: parent
49+ }
45
50
46 Panel {
51 Panel {
47 id: panel
52 id: panel
@@ -128,6 +133,12 @@ IndicatorTest {
128 name: "Panel"
133 name: "Panel"
129 when: windowShown
134 when: windowShown
130
135
136+ SignalSpy {
137+ id: backgroundPressedSpy
138+ target: backgroundMouseArea
139+ signalName: "pressedChanged"
140+ }
141+
131 function init() {
142 function init() {
132 panel.fullscreenMode = false;
143 panel.fullscreenMode = false;
133 callManager.foregroundCall = null;
144 callManager.foregroundCall = null;
@@ -140,6 +151,9 @@ IndicatorTest {
140 // (switches between normal and fullscreen modes are animated)
151 // (switches between normal and fullscreen modes are animated)
141 var indicatorArea = findChild(panel, "indicatorArea");
152 var indicatorArea = findChild(panel, "indicatorArea");
142 tryCompare(indicatorArea, "y", 0);
153 tryCompare(indicatorArea, "y", 0);
154+
155+ backgroundPressedSpy.clear();
156+ compare(backgroundPressedSpy.valid, true);
143 }
157 }
144
158
145 function get_indicator_item(index) {
159 function get_indicator_item(index) {
@@ -299,5 +313,22 @@ IndicatorTest {
299
313
300 touchRelease(panel, mappedPosition.x, panel.minimizedPanelHeight / 2);
314 touchRelease(panel, mappedPosition.x, panel.minimizedPanelHeight / 2);
301 }
315 }
316+
317+ /* Checks that no input reaches items behind the indicator bar.
318+ Ie., the indicator bar should eat all input events that hit it.
319+ */
320+ function test_indicatorBarEatsAllEvents() {
321+ // Perform several taps throughout the length of the indicator bar to ensure
322+ // that it doesn't have a "weak spot" from where taps pass through.
323+ var numTaps = 5;
324+ var stepLength = (panel.width / (numTaps + 1));
325+ var tapY = panel.indicators.minimizedPanelHeight / 2;
326+ for (var i = 1; i <= numTaps; ++i) {
327+ tap(panel, stepLength * i, tapY);
328+ tryCompare(panel.indicators, "fullyClosed", true);
329+ }
330+
331+ compare(backgroundPressedSpy.count, 0);
332+ }
302 }
333 }
303}
334}