From eda4b3dc3c9421a0b3009c11b858f4e5fe1d8ba2 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 3 Feb 2012 14:41:17 +0100 Subject: Fix acceptance of unhandled mouse events. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mouse events not handled by the canvas need to be ignored, in order for features like touch synthetization to work. In case of the initially delivered mouse press event, the canvas did not ignore the event if it was not handled. This patch corrects that and adds an auto-test to verify the new behaviour. Change-Id: I8499701f5a161ce1e90a70303aa7ca4ccf2f0b6f Reviewed-by: Andras Becsi Reviewed-by: Samuel Rødal --- .../qtquick2/qquickcanvas/tst_qquickcanvas.cpp | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests') diff --git a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp b/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp index 795580cc6e..4a238429bb 100644 --- a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp +++ b/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp @@ -210,6 +210,8 @@ private slots: void focusObject(); + void ignoreUnhandledMouseEvents(); + private: QTouchDevice *touchDevice; }; @@ -696,6 +698,43 @@ void tst_qquickcanvas::focusObject() delete canvas; } +void tst_qquickcanvas::ignoreUnhandledMouseEvents() +{ + QQuickCanvas* canvas = new QQuickCanvas; + canvas->resize(100, 100); + canvas->show(); + + QQuickItem* item = new QQuickItem; + item->setSize(QSizeF(100, 100)); + item->setParentItem(canvas->rootItem()); + + { + QMouseEvent me(QEvent::MouseButtonPress, QPointF(50, 50), Qt::LeftButton, Qt::LeftButton, + Qt::NoModifier); + me.setAccepted(true); + QVERIFY(QCoreApplication::sendEvent(canvas, &me)); + QVERIFY(!me.isAccepted()); + } + + { + QMouseEvent me(QEvent::MouseMove, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton, + Qt::NoModifier); + me.setAccepted(true); + QVERIFY(QCoreApplication::sendEvent(canvas, &me)); + QVERIFY(!me.isAccepted()); + } + + { + QMouseEvent me(QEvent::MouseButtonRelease, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton, + Qt::NoModifier); + me.setAccepted(true); + QVERIFY(QCoreApplication::sendEvent(canvas, &me)); + QVERIFY(!me.isAccepted()); + } + + delete canvas; +} + QTEST_MAIN(tst_qquickcanvas) #include "tst_qquickcanvas.moc" -- cgit v1.2.3