on xenial help sign in
Don't eat mouse events in the edgebarrer

Approved by: Albert Astals Cid

commit1b8086ed6fa7d50302b568e3eecd57dc6e8d5bac authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 12 Feb 2016, 00:11 (11 years ago) parentda6cbd48c6ea24
4 files changed+75
qml/Components/EdgeBarrierController.qml+2 tests/mocks/Unity/Application/MirSurfaceItem.cpp+6 tests/mocks/Unity/Application/MirSurfaceItem.h+14 tests/qmltests/tst_Shell.qml+53
qml/Components/EdgeBarrierController.qml+2
@@ -30,6 +30,8 @@ MouseArea {
3030 // Should trigger the action associated with this edge
3131 signal passed()
3232
33+ onPressed: mouse.accepted = false;
34+
3335 function push(amount) {
3436 if (!root._containsMouse) {
3537 return;
tests/mocks/Unity/Application/MirSurfaceItem.cpp+6
@@ -37,6 +37,8 @@ MirSurfaceItem::MirSurfaceItem(QQuickItem *parent)
3737 , m_surfaceHeight(0)
3838 , m_touchPressCount(0)
3939 , m_touchReleaseCount(0)
40+ , m_mousePressCount(0)
41+ , m_mouseReleaseCount(0)
4042{
4143// qDebug() << "MirSurfaceItem::MirSurfaceItem() " << (void*)(this) << name();
4244 setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton |
@@ -165,6 +167,8 @@ void MirSurfaceItem::touchEvent(QTouchEvent * event)
165167
166168void MirSurfaceItem::mousePressEvent(QMouseEvent * event)
167169{
170+ m_mousePressCount++;
171+ Q_EMIT mousePressCountChanged(m_mousePressCount);
168172 event->accept();
169173}
170174
@@ -175,6 +179,8 @@ void MirSurfaceItem::mouseMoveEvent(QMouseEvent * event)
175179
176180void MirSurfaceItem::mouseReleaseEvent(QMouseEvent * event)
177181{
182+ m_mouseReleaseCount++;
183+ Q_EMIT mouseReleaseCountChanged(m_mouseReleaseCount);
178184 event->accept();
179185}
180186
tests/mocks/Unity/Application/MirSurfaceItem.h+14
@@ -36,6 +36,10 @@ class MirSurfaceItem : public unity::shell::application::MirSurfaceItemInterface
3636 Q_PROPERTY(int touchReleaseCount READ touchReleaseCount WRITE setTouchReleaseCount
3737 NOTIFY touchReleaseCountChanged DESIGNABLE false)
3838
39+ Q_PROPERTY(int mousePressCount READ mousePressCount WRITE setMousePressCount
40+ NOTIFY mousePressCountChanged)
41+ Q_PROPERTY(int mouseReleaseCount READ mouseReleaseCount WRITE setMouseReleaseCount
42+ NOTIFY mouseReleaseCountChanged)
3943public:
4044 explicit MirSurfaceItem(QQuickItem *parent = 0);
4145 ~MirSurfaceItem();
@@ -76,9 +80,17 @@ public:
7680 int touchReleaseCount() const { return m_touchReleaseCount; }
7781 void setTouchReleaseCount(int count) { m_touchReleaseCount = count; Q_EMIT touchReleaseCountChanged(count); }
7882
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+
7989Q_SIGNALS:
8090 void touchPressCountChanged(int count);
8191 void touchReleaseCountChanged(int count);
92+ void mousePressCountChanged(int count);
93+ void mouseReleaseCountChanged(int count);
8294
8395protected:
8496 void touchEvent(QTouchEvent * event) override;
@@ -109,6 +121,8 @@ private:
109121
110122 int m_touchPressCount;
111123 int m_touchReleaseCount;
124+ int m_mousePressCount;
125+ int m_mouseReleaseCount;
112126
113127 FillMode m_fillMode{Stretch};
114128
tests/qmltests/tst_Shell.qml+53
@@ -49,6 +49,11 @@ Rectangle {
4949 shellLoader.active = true;
5050 }
5151
52+ MouseArea {
53+ id: clickThroughCatcher
54+ anchors.fill: shellContainer
55+ }
56+
5257 Item {
5358 id: shellContainer
5459 anchors.left: root.left
@@ -291,6 +296,12 @@ Rectangle {
291296 signalName: "applicationRemoved"
292297 }
293298
299+ SignalSpy {
300+ id: clickThroughSpy
301+ target: clickThroughCatcher
302+ signalName: "clicked"
303+ }
304+
294305 Telephony.CallEntry {
295306 id: phoneCall
296307 phoneNumber: "+447812221111"
@@ -1977,5 +1988,47 @@ Rectangle {
19771988 compare(ApplicationManager.findApplication("libreoffice") === null, true);
19781989 }
19791990 }
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+ }
19802033 }
19812034}