diff options
author | Jeremy Katz <jeremy.katz@nokia.com> | 2010-06-02 14:08:56 (GMT) |
---|---|---|
committer | Jeremy Katz <jeremy.katz@nokia.com> | 2010-06-02 14:08:56 (GMT) |
commit | 31608f9ca899b4d85b3c339bbab24cf42450831f (patch) | |
tree | 3c2417c7bb99cab2e7a0aa7ef6d8d8f9fd1ae847 | |
parent | 56a57f127354a42a5de8dc59510ba5a3cfd8b442 (diff) | |
download | Qt-31608f9ca899b4d85b3c339bbab24cf42450831f.zip Qt-31608f9ca899b4d85b3c339bbab24cf42450831f.tar.gz Qt-31608f9ca899b4d85b3c339bbab24cf42450831f.tar.bz2 |
pass the QList of TouchPoints as a constant reference for handleTouchEvent
-rw-r--r-- | src/gui/kernel/qapplication_lite.cpp | 23 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 30 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.h | 8 |
3 files changed, 33 insertions, 28 deletions
diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 792b28b..4b935ae 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -804,28 +804,7 @@ void QApplicationPrivate::processCloseEvent(QWidget *tlw) void QApplicationPrivate::processTouchEvent(QWindowSystemInterface::TouchEvent *e) { - QList<QTouchEvent::TouchPoint> touchPoints; - Qt::TouchPointStates states; - - int primaryPoint = -1; - foreach(struct QWindowSystemInterface::TouchPoint point, e->points) { - QTouchEvent::TouchPoint p; - p.setId(point.id); - p.setPressure(point.pressure); - states |= point.state; - if (point.isPrimary) { - point.state |= Qt::TouchPointPrimary; - primaryPoint = point.id; - } - p.setState(point.state); - p.setRect(point.area); - p.setScreenPos(point.area.center()); - p.setNormalizedPos(point.normalPosition); - - touchPoints.append(p); - } - - translateRawTouchEvent(e->widget.data(), e->devType, touchPoints); + translateRawTouchEvent(e->widget.data(), e->devType, e->points); } void QApplicationPrivate::reportScreenCount(int count) diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index cd466e3..c9d177d 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -134,11 +134,37 @@ void QWindowSystemInterfacePrivate::queueUserEvent(QWindowSystemInterface::UserE dispatcher->wakeUp(); } -void QWindowSystemInterface::handleTouchEvent(QWidget *tlw, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, QList<struct TouchPoint> points) +void QWindowSystemInterface::handleTouchEvent(QWidget *tlw, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points) { if (!points.size()) // Touch events must have at least one point return; - TouchEvent *e = new TouchEvent(tlw, timestamp, type, devType, points); + + QList<QTouchEvent::TouchPoint> touchPoints; + Qt::TouchPointStates states; + QTouchEvent::TouchPoint p; + + int primaryPoint = -1; + QList<struct TouchPoint>::const_iterator point = points.constBegin(); + QList<struct TouchPoint>::const_iterator end = points.constEnd(); + while (point != end) { + p.setId(point->id); + p.setPressure(point->pressure); + states |= point->state; + Qt::TouchPointStates state = point->state; + if (point->isPrimary) { + state |= Qt::TouchPointPrimary; + primaryPoint = point->id; + } + p.setState(state); + p.setRect(point->area); + p.setScreenPos(point->area.center()); + p.setNormalizedPos(point->normalPosition); + + touchPoints.append(p); + ++point; + } + + TouchEvent *e = new TouchEvent(tlw, timestamp, type, devType, touchPoints); QWindowSystemInterfacePrivate::queueUserEvent(e); } diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 8c69218..88d6475 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -85,11 +85,11 @@ public: Qt::TouchPointStates state; //Qt::TouchPoint{Pressed|Moved|Stationary|Released} }; - static void handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, QList<struct TouchPoint> points) { + static void handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points) { handleTouchEvent(w, eventTime.elapsed(), type, devType, points); } - static void handleTouchEvent(QWidget *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, QList<struct TouchPoint> points); + static void handleTouchEvent(QWidget *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points); // delivered directly by the plugin via spontaneous events static void handleGeometryChange(QWidget *w, const QRect &newRect); @@ -143,10 +143,10 @@ public: class TouchEvent : public UserEvent { public: - TouchEvent(QWidget *w, ulong time, QEvent::Type t, QTouchEvent::DeviceType d, QList<struct TouchPoint> p) + TouchEvent(QWidget *w, ulong time, QEvent::Type t, QTouchEvent::DeviceType d, const QList<QTouchEvent::TouchPoint> &p) :UserEvent(w, time, t) { devType = d; points = p; } QTouchEvent::DeviceType devType; - QList<struct TouchPoint> points; + QList<QTouchEvent::TouchPoint> points; }; private: |