on xenial help sign in
Don't eat mouse events in the edgebarrer
1b8086eMichael Zanetti
qml/Components/EdgeBarrierController.qml+2
@@ -30,6 +30,8 @@ MouseArea {
30 // Should trigger the action associated with this edge
30 // Should trigger the action associated with this edge
31 signal passed()
31 signal passed()
32
32
33+ onPressed: mouse.accepted = false;
34+
33 function push(amount) {
35 function push(amount) {
34 if (!root._containsMouse) {
36 if (!root._containsMouse) {
35 return;
37 return;
tests/mocks/Unity/Application/MirSurfaceItem.cpp+6
@@ -37,6 +37,8 @@ MirSurfaceItem::MirSurfaceItem(QQuickItem *parent)
37 , m_surfaceHeight(0)
37 , m_surfaceHeight(0)
38 , m_touchPressCount(0)
38 , m_touchPressCount(0)
39 , m_touchReleaseCount(0)
39 , m_touchReleaseCount(0)
40+ , m_mousePressCount(0)
41+ , m_mouseReleaseCount(0)
40{
42{
41// qDebug() << "MirSurfaceItem::MirSurfaceItem() " << (void*)(this) << name();
43// qDebug() << "MirSurfaceItem::MirSurfaceItem() " << (void*)(this) << name();
42 setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton |
44 setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton |
@@ -165,6 +167,8 @@ void MirSurfaceItem::touchEvent(QTouchEvent * event)
165
167
166void MirSurfaceItem::mousePressEvent(QMouseEvent * event)
168void MirSurfaceItem::mousePressEvent(QMouseEvent * event)
167{
169{
170+ m_mousePressCount++;
171+ Q_EMIT mousePressCountChanged(m_mousePressCount);
168 event->accept();
172 event->accept();
169}
173}
170
174
@@ -175,6 +179,8 @@ void MirSurfaceItem::mouseMoveEvent(QMouseEvent * event)
175
179
176void MirSurfaceItem::mouseReleaseEvent(QMouseEvent * event)
180void MirSurfaceItem::mouseReleaseEvent(QMouseEvent * event)
177{
181{
182+ m_mouseReleaseCount++;
183+ Q_EMIT mouseReleaseCountChanged(m_mouseReleaseCount);
178 event->accept();
184 event->accept();
179}
185}
180
186
tests/mocks/Unity/Application/MirSurfaceItem.h+14
@@ -36,6 +36,10 @@ class MirSurfaceItem : public unity::shell::application::MirSurfaceItemInterface
36 Q_PROPERTY(int touchReleaseCount READ touchReleaseCount WRITE setTouchReleaseCount
36 Q_PROPERTY(int touchReleaseCount READ touchReleaseCount WRITE setTouchReleaseCount
37 NOTIFY touchReleaseCountChanged DESIGNABLE false)
37 NOTIFY touchReleaseCountChanged DESIGNABLE false)
38
38
39+ Q_PROPERTY(int mousePressCount READ mousePressCount WRITE setMousePressCount
40+ NOTIFY mousePressCountChanged)
41+ Q_PROPERTY(int mouseReleaseCount READ mouseReleaseCount WRITE setMouseReleaseCount
42+ NOTIFY mouseReleaseCountChanged)
39public:
43public:
40 explicit MirSurfaceItem(QQuickItem *parent = 0);
44 explicit MirSurfaceItem(QQuickItem *parent = 0);
41 ~MirSurfaceItem();
45 ~MirSurfaceItem();
@@ -76,9 +80,17 @@ public:
76 int touchReleaseCount() const { return m_touchReleaseCount; }
80 int touchReleaseCount() const { return m_touchReleaseCount; }
77 void setTouchReleaseCount(int count) { m_touchReleaseCount = count; Q_EMIT touchReleaseCountChanged(count); }
81 void setTouchReleaseCount(int count) { m_touchReleaseCount = count; Q_EMIT touchReleaseCountChanged(count); }
78
82
83+ int mousePressCount() const { return m_mousePressCount; }
84+ void setMousePressCount(int count) { m_mousePressCount = count; Q_EMIT mousePressCountChanged(count); }
85+
86+ int mouseReleaseCount() const { return m_mouseReleaseCount; }
87+ void setMouseReleaseCount(int count) { m_mouseReleaseCount = count; Q_EMIT mouseReleaseCountChanged(count); }
88+
79Q_SIGNALS:
89Q_SIGNALS:
80 void touchPressCountChanged(int count);
90 void touchPressCountChanged(int count);
81 void touchReleaseCountChanged(int count);
91 void touchReleaseCountChanged(int count);
92+ void mousePressCountChanged(int count);
93+ void mouseReleaseCountChanged(int count);
82
94
83protected:
95protected:
84 void touchEvent(QTouchEvent * event) override;
96 void touchEvent(QTouchEvent * event) override;
@@ -109,6 +121,8 @@ private:
109
121
110 int m_touchPressCount;
122 int m_touchPressCount;
111 int m_touchReleaseCount;
123 int m_touchReleaseCount;
124+ int m_mousePressCount;
125+ int m_mouseReleaseCount;
112
126
113 FillMode m_fillMode{Stretch};
127 FillMode m_fillMode{Stretch};
114
128
tests/qmltests/tst_Shell.qml+53
@@ -49,6 +49,11 @@ Rectangle {
49 shellLoader.active = true;
49 shellLoader.active = true;
50 }
50 }
51
51
52+ MouseArea {
53+ id: clickThroughCatcher
54+ anchors.fill: shellContainer
55+ }
56+
52 Item {
57 Item {
53 id: shellContainer
58 id: shellContainer
54 anchors.left: root.left
59 anchors.left: root.left
@@ -291,6 +296,12 @@ Rectangle {
291 signalName: "applicationRemoved"
296 signalName: "applicationRemoved"
292 }
297 }
293
298
299+ SignalSpy {
300+ id: clickThroughSpy
301+ target: clickThroughCatcher
302+ signalName: "clicked"
303+ }
304+
294 Telephony.CallEntry {
305 Telephony.CallEntry {
295 id: phoneCall
306 id: phoneCall
296 phoneNumber: "+447812221111"
307 phoneNumber: "+447812221111"
@@ -1977,5 +1988,47 @@ Rectangle {
1977 compare(ApplicationManager.findApplication("libreoffice") === null, true);
1988 compare(ApplicationManager.findApplication("libreoffice") === null, true);
1978 }
1989 }
1979 }
1990 }
1991+
1992+ function test_inputEventsOnEdgesEndUpInAppSurface_data() {
1993+ return [
1994+ { tag: "phone", repeaterName: "spreadRepeater" },
1995+ { tag: "tablet", repeaterName: "spreadRepeater" },
1996+ { tag: "desktop", repeaterName: "appRepeater" },
1997+ ]
1998+ }
1999+
2000+ function test_inputEventsOnEdgesEndUpInAppSurface(data) {
2001+ loadShell(data.tag);
2002+ shell.usageScenario = data.tag;
2003+ waitForRendering(shell);
2004+ swipeAwayGreeter();
2005+
2006+ // Let's open a fullscreen app
2007+ var app = ApplicationManager.startApplication("camera-app");
2008+ waitUntilAppWindowIsFullyLoaded(app);
2009+
2010+ var appRepeater = findChild(shell, data.repeaterName);
2011+ var topmostAppDelegate = appRepeater.itemAt(0);
2012+ verify(topmostAppDelegate);
2013+
2014+ var topmostSurfaceItem = findChild(topmostAppDelegate, "surfaceItem");
2015+ verify(topmostSurfaceItem);
2016+
2017+ mouseClick(shell, 1, shell.height / 2);
2018+ compare(topmostSurfaceItem.mousePressCount, 1);
2019+ compare(topmostSurfaceItem.mouseReleaseCount, 1);
2020+
2021+ mouseClick(shell, shell.width - 1, shell.height / 2);
2022+ compare(topmostSurfaceItem.mousePressCount, 2);
2023+ compare(topmostSurfaceItem.mouseReleaseCount, 2);
2024+
2025+ tap(shell, 1, shell.height / 2);
2026+ compare(topmostSurfaceItem.touchPressCount, 1);
2027+ compare(topmostSurfaceItem.touchReleaseCount, 1);
2028+
2029+ tap(shell, shell.width - 1, shell.height / 2);
2030+ compare(topmostSurfaceItem.touchPressCount, 2);
2031+ compare(topmostSurfaceItem.touchReleaseCount, 2);
2032+ }
1980 }
2033 }
1981}
2034}