on xenial help sign in
Make indicators bar eat all events

So that they don't hit items behind it inadvertently. Approved by: Albert Astals Cid

commitd9c2596e643dce7ac16860ed223f42e5bf699b55 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateWed 11 Feb 2015, 17:10 (12 years ago) parent5f76e132c0ab60
2 files changed+38−5
qml/Panel/Panel.qml+5−3 tests/qmltests/Panel/tst_Panel.qml+33−2
qml/Panel/Panel.qml+5−3
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013-2014 Canonical, Ltd.
2+ * Copyright (C) 2013-2015 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
@@ -90,6 +90,9 @@ Item {
9090 right: indicators.left
9191 }
9292 saturation: 1 - indicators.unitProgress
93+
94+ // Don't let input event pass trough
95+ MouseArea { anchors.fill: parent }
9396 }
9497
9598 Image {
@@ -110,8 +113,7 @@ Item {
110113 right: indicators.left
111114 }
112115 height: indicators.minimizedPanelHeight
113− enabled: callHint.visible
114− onClicked: callHint.showLiveCall()
116+ onClicked: { if (callHint.visible) { callHint.showLiveCall(); } }
115117 }
116118
117119 IndicatorsMenu {
tests/qmltests/Panel/tst_Panel.qml+33−2
@@ -1,5 +1,5 @@
11/*
2− * Copyright 2013-2014 Canonical Ltd.
2+ * Copyright 2013-2015 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
@@ -41,7 +41,12 @@ IndicatorTest {
4141 Layout.fillHeight: true
4242
4343 id: itemArea
44− color: "blue"
44+ color: backgroundMouseArea.pressed ? "red" : "blue"
45+
46+ MouseArea {
47+ id: backgroundMouseArea
48+ anchors.fill: parent
49+ }
4550
4651 Panel {
4752 id: panel
@@ -128,6 +133,12 @@ IndicatorTest {
128133 name: "Panel"
129134 when: windowShown
130135
136+ SignalSpy {
137+ id: backgroundPressedSpy
138+ target: backgroundMouseArea
139+ signalName: "pressedChanged"
140+ }
141+
131142 function init() {
132143 panel.fullscreenMode = false;
133144 callManager.foregroundCall = null;
@@ -140,6 +151,9 @@ IndicatorTest {
140151 // (switches between normal and fullscreen modes are animated)
141152 var indicatorArea = findChild(panel, "indicatorArea");
142153 tryCompare(indicatorArea, "y", 0);
154+
155+ backgroundPressedSpy.clear();
156+ compare(backgroundPressedSpy.valid, true);
143157 }
144158
145159 function get_indicator_item(index) {
@@ -299,5 +313,22 @@ IndicatorTest {
299313
300314 touchRelease(panel, mappedPosition.x, panel.minimizedPanelHeight / 2);
301315 }
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+ }
302333 }
303334}