diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-12-06 14:34:03 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-12-07 23:25:56 +0000 |
commit | 92672198ed0ecf5e014abf3a431a374e91067b27 (patch) | |
tree | dbf5ac280c8f7129ec0ef0f6d4b7a49bbd27a793 | |
parent | 964d9e8f8ad289072d046239931c4377122bbf97 (diff) |
QGuiApplicationPrivate::processTouchEvent: add explanatory comments
It was very confusing to debug a problem involving detached touchpoints
and not very clear how startPos is stored in activeTouchPoints.
Change-Id: I5c04fb6b5647493a731774e0a1765404cbc8c7d6
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 1277e85d0a..4d1caa9232 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2564,6 +2564,9 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To Q_ASSERT(w.data() != 0); // make the *scene* functions return the same as the *screen* functions + // Note: touchPoint is a reference to the one from activeTouchPoints, + // so we can modify it as long as we're careful NOT to call setters and + // otherwise NOT to cause the d-pointer to be detached. touchPoint.d->scenePos = touchPoint.screenPos(); touchPoint.d->verticalDiameter = touchPoint.screenRect().height(); touchPoint.d->horizontalDiameter = touchPoint.screenRect().width(); @@ -2622,8 +2625,8 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To QTouchEvent touchEvent(eventType, e->device, e->modifiers, - it.value().first, - it.value().second); + it.value().first, // state flags + it.value().second); // list of touchpoints touchEvent.setTimestamp(e->timestamp); touchEvent.setWindow(w); @@ -2640,6 +2643,9 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To touchPoint.d->verticalDiameter = rect.height(); touchPoint.d->horizontalDiameter = rect.width(); if (touchPoint.state() == Qt::TouchPointPressed) { + // touchPoint is actually a reference to one that is stored in activeTouchPoints, + // and we are now going to store the startPos and lastPos there, for the benefit + // of future moves and releases. It's important that the d-pointer is NOT detached. touchPoint.d->startPos = w->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta; touchPoint.d->lastPos = w->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; } |