From 6c1670d8c273819435867c42725c0db0eee597dc Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Wed, 8 Aug 2012 11:44:39 +0200 Subject: Add hint for touch -> mouse event synthesizing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 7808ec79 changes QApplication to synthesize mouse events from (unhandled) touch events. On Mac OS X this creates a conflict for two-finger scroll swipes, which generates both touch events and mouse wheel events: scrolling in QTextEdit will also select the text. Add a SynthesizeMouseFromTouchEvents platform style hint that enables the event synthesising. Set to true by default and false in Cocoa. Change-Id: I1ffa5a141476aa38b81ce92a87eff676c7ec2276 Reviewed-by: Morten Johan Sørvig --- .../kernel/qapplication/tst_qapplication.cpp | 27 ++++++++++++---------- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 4 ++++ 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index fc91ba23b3..929b587dfb 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -1926,6 +1926,9 @@ void tst_QApplication::touchEventPropagation() int argc = 1; QApplication app(argc, &argv0, QApplication::GuiServer); + const bool mouseEventSynthesizing = QGuiApplicationPrivate::platformIntegration() + ->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool(); + QList pressedTouchPoints; QTouchEvent::TouchPoint press(0); press.setState(Qt::TouchPointPressed); @@ -1963,7 +1966,7 @@ void tst_QApplication::touchEventPropagation() touchPointList(releasedTouchPoints)); QCoreApplication::processEvents(); QVERIFY(!window.seenTouchEvent); - QVERIFY(window.seenMouseEvent); // Since QApplication transforms ignored touch events in mouse events + QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing); // QApplication may transform ignored touch events in mouse events window.reset(); window.setAttribute(Qt::WA_AcceptTouchEvents); @@ -1977,7 +1980,7 @@ void tst_QApplication::touchEventPropagation() touchPointList(releasedTouchPoints)); QCoreApplication::processEvents(); QVERIFY(window.seenTouchEvent); - QVERIFY(window.seenMouseEvent); + QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing); window.reset(); window.acceptTouchEvent = true; @@ -2015,9 +2018,9 @@ void tst_QApplication::touchEventPropagation() touchPointList(releasedTouchPoints)); QCoreApplication::processEvents(); QVERIFY(!widget.seenTouchEvent); - QVERIFY(widget.seenMouseEvent); + QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing); QVERIFY(!window.seenTouchEvent); - QVERIFY(window.seenMouseEvent); + QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing); window.reset(); widget.reset(); @@ -2032,9 +2035,9 @@ void tst_QApplication::touchEventPropagation() touchPointList(releasedTouchPoints)); QCoreApplication::processEvents(); QVERIFY(widget.seenTouchEvent); - QVERIFY(widget.seenMouseEvent); + QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing); QVERIFY(!window.seenTouchEvent); - QVERIFY(window.seenMouseEvent); + QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing); window.reset(); widget.reset(); @@ -2049,7 +2052,7 @@ void tst_QApplication::touchEventPropagation() touchPointList(releasedTouchPoints)); QCoreApplication::processEvents(); QVERIFY(widget.seenTouchEvent); - QVERIFY(widget.seenMouseEvent); + QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing); QVERIFY(!window.seenTouchEvent); QVERIFY(!window.seenMouseEvent); @@ -2084,9 +2087,9 @@ void tst_QApplication::touchEventPropagation() touchPointList(releasedTouchPoints)); QCoreApplication::processEvents(); QVERIFY(!widget.seenTouchEvent); - QVERIFY(widget.seenMouseEvent); + QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing); QVERIFY(window.seenTouchEvent); - QVERIFY(window.seenMouseEvent); + QCOMPARE(window.seenMouseEvent, mouseEventSynthesizing); window.reset(); widget.reset(); @@ -2101,7 +2104,7 @@ void tst_QApplication::touchEventPropagation() touchPointList(releasedTouchPoints)); QCoreApplication::processEvents(); QVERIFY(!widget.seenTouchEvent); - QVERIFY(widget.seenMouseEvent); + QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing); QVERIFY(window.seenTouchEvent); QVERIFY(!window.seenMouseEvent); @@ -2119,8 +2122,8 @@ void tst_QApplication::touchEventPropagation() touchPointList(releasedTouchPoints)); QCoreApplication::processEvents(); QVERIFY(!widget.seenTouchEvent); - QVERIFY(widget.seenMouseEvent); - QVERIFY(!window.seenTouchEvent); + QCOMPARE(widget.seenMouseEvent, mouseEventSynthesizing); + QCOMPARE(!window.seenTouchEvent, mouseEventSynthesizing); QVERIFY(!window.seenMouseEvent); } } diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 0c35107157..3b45acfa1a 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -9409,6 +9409,10 @@ public: void tst_QWidget::touchEventSynthesizedMouseEvent() { + // Pass if the platform does not want mouse event synhesizing + if (!QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool()) + return; + { // Simple case, we ignore the touch events, we get mouse events instead QTouchDevice *device = new QTouchDevice; -- cgit v1.2.3