Don't forcibly accept touch events if mouse event synthesis is disabled
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Thu, 24 Apr 2014 14:46:28 +0000 (16:46 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 25 Apr 2014 13:43:10 +0000 (15:43 +0200)
Instead of always accepting touch events, do that only if we are
generating mouse events for non accepted ones. This enables
QQuickWindow subclasses to detect if a touch event was indeed
handled by QQuickWindow.

Change-Id: I73512fb3597131c2296d6cdc7b3d5c8454b159b6
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
src/quick/items/qquickwindow.cpp

index 4592be3..d258b63 100644 (file)
@@ -1291,9 +1291,11 @@ bool QQuickWindow::event(QEvent *e)
         QTouchEvent *touch = static_cast<QTouchEvent*>(e);
         d->translateTouchEvent(touch);
         d->deliverTouchEvent(touch);
-        // we consume all touch events ourselves to avoid duplicate
-        // mouse delivery by QtGui mouse synthesis
-        e->accept();
+        if (Q_LIKELY(qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents))) {
+            // we consume all touch events ourselves to avoid duplicate
+            // mouse delivery by QtGui mouse synthesis
+            e->accept();
+        }
         return true;
     }
         break;