diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-06-18 10:49:11 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-06-18 10:49:11 (GMT) |
commit | 3b04dba36b31360d94583f382b9054bcdea0e2a7 (patch) | |
tree | f56d1329980987a21d0c457e21ebb99f820e3ef2 /src/gui/kernel/qapplication.cpp | |
parent | 9756f523fd1c31192a87c65449434280a59b49f7 (diff) | |
download | Qt-3b04dba36b31360d94583f382b9054bcdea0e2a7.zip Qt-3b04dba36b31360d94583f382b9054bcdea0e2a7.tar.gz Qt-3b04dba36b31360d94583f382b9054bcdea0e2a7.tar.bz2 |
Change behavior of how touch and mouse events work together
We now send both types of events, i.e. accepting TouchBegin doesn't block mouse events anymore. We
are also introducing the idea of a "primary" touch point, which is the one that the system is also
generating mouse events for.
This lets us reuse existing mouse event code while still being able to add multi-touch support.
Diffstat (limited to 'src/gui/kernel/qapplication.cpp')
-rw-r--r-- | src/gui/kernel/qapplication.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 72acbdc..5ef453d 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -5296,7 +5296,7 @@ int QApplicationPrivate::findClosestTouchPointId(const QPointF &screenPos) return closestTouchPointId; } -bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, +void QApplicationPrivate::translateRawTouchEvent(QWidget *window, const QList<QTouchEvent::TouchPoint> &touchPoints) { QApplicationPrivate *d = self; @@ -5365,13 +5365,13 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[widget]; maskAndPoints.first |= touchPoint.state(); + if (touchPoint.isPrimary()) + maskAndPoints.first |= Qt::TouchPointPrimary; maskAndPoints.second.append(touchPoint); } if (widgetsNeedingEvents.isEmpty()) - return false; - - bool returnValue = false; + return; QHash<QWidget *, StatesAndTouchPoints>::ConstIterator it = widgetsNeedingEvents.constBegin(); const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd(); @@ -5381,7 +5381,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, continue; QEvent::Type eventType; - switch(it.value().first) { + switch (it.value().first & Qt::TouchPointStateMask) { case Qt::TouchPointPressed: eventType = QEvent::TouchBegin; break; @@ -5402,15 +5402,13 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, it.value().second); updateTouchPointsForWidget(widget, &touchEvent); - bool res = false; switch (touchEvent.type()) { case QEvent::TouchBegin: { // if the TouchBegin handler recurses, we assume that means the event // has been implicitly accepted and continue to send touch events widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent); - res = QApplication::sendSpontaneousEvent(widget, &touchEvent) - && touchEvent.isAccepted(); + (void ) QApplication::sendSpontaneousEvent(widget, &touchEvent); break; } default: @@ -5418,20 +5416,16 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, if (touchEvent.type() == QEvent::TouchEnd) widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, false); (void) QApplication::sendSpontaneousEvent(widget, &touchEvent); - res = true; } break; } - returnValue = returnValue || res; } - - return returnValue; } -Q_GUI_EXPORT bool qt_translateRawTouchEvent(const QList<QTouchEvent::TouchPoint> &touchPoints, +Q_GUI_EXPORT void qt_translateRawTouchEvent(const QList<QTouchEvent::TouchPoint> &touchPoints, QWidget *window) { - return QApplicationPrivate::translateRawTouchEvent(window, touchPoints); + QApplicationPrivate::translateRawTouchEvent(window, touchPoints); } QT_END_NAMESPACE |