diff options
author | Robin Burchell <robin.burchell@jollamobile.com> | 2013-11-13 12:41:19 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-13 11:30:12 +0100 |
commit | 2602b4402f3c8d867d11ea62b613b03dacc8a232 (patch) | |
tree | 21efca582761444680ebccbcc290100811d66eb3 /src/quick/items/qquickwindow.cpp | |
parent | 9b5a688cdb77bca74529d4720ed65668a62e4b4b (diff) |
Fix touch to mouse synthesis/propagation.
Having mouse events synthesised from both QtGui and internally in QtQuick is
not a great way togo about things, especially when QtGui doesn't have the same
degree of knowledge as QtQuick about the items in the scene.
Thus, we now accept all events inside QtQuick to block QtGui synthesis, which
should fix a significant amount of edge-case touch breakage/bad behavior.
Change-Id: I14e1c87761c8f43160049b5e6f9da15b4e5edbb7
Done-with: Martin Jones <martin.jones@jollamobile.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/quick/items/qquickwindow.cpp')
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index dfc70d7e68..f355afcea5 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -599,6 +599,28 @@ bool QQuickWindowPrivate::translateTouchToMouse(QQuickItem *item, QTouchEvent *e return false; } +void QQuickWindowPrivate::setMouseGrabber(QQuickItem *grabber) +{ + Q_Q(QQuickWindow); + if (mouseGrabberItem == grabber) + return; + + QQuickItem *oldGrabber = mouseGrabberItem; + mouseGrabberItem = grabber; + + if (touchMouseId != -1) { + // update the touch item for mouse touch id to the new grabber + itemForTouchPointId.remove(touchMouseId); + if (grabber) + itemForTouchPointId[touchMouseId] = grabber; + } + + if (oldGrabber) { + QEvent ev(QEvent::UngrabMouse); + q->sendEvent(oldGrabber, &ev); + } +} + void QQuickWindowPrivate::transformTouchPoints(QList<QTouchEvent::TouchPoint> &touchPoints, const QTransform &transform) { QMatrix4x4 transformMatrix(transform); @@ -1221,8 +1243,11 @@ bool QQuickWindow::event(QEvent *e) case QEvent::TouchEnd: { QTouchEvent *touch = static_cast<QTouchEvent*>(e); d->translateTouchEvent(touch); - // return in order to avoid the QWindow::event below - return d->deliverTouchEvent(touch); + d->deliverTouchEvent(touch); + // we consume all touch events ourselves to avoid duplicate + // mouse delivery by QtGui mouse synthesis + e->accept(); + return true; } break; case QEvent::TouchCancel: @@ -1776,7 +1801,10 @@ bool QQuickWindowPrivate::deliverMatchingPointsToItem(QQuickItem *item, QTouchEv // First check whether the parent wants to be a filter, // and if the parent accepts the event we are done. if (sendFilteredTouchEvent(item->parentItem(), item, event)) { - event->accept(); + // If the touch was accepted (regardless by whom or in what form), + // update acceptedNewPoints + foreach (int id, matchingNewPoints) + acceptedNewPoints->insert(id); return true; } |