summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-05-12 12:51:44 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-05-12 12:51:44 (GMT)
commitd9c2a93e1dc1ea0248d72fdc7f1bb863f8847658 (patch)
tree082e1636a1dfc5eb9d558706e34009d9a8571d35 /src/gui/kernel
parent06d32cd1f14152ee0d49bc4a4a8adee953be11f4 (diff)
downloadQt-d9c2a93e1dc1ea0248d72fdc7f1bb863f8847658.zip
Qt-d9c2a93e1dc1ea0248d72fdc7f1bb863f8847658.tar.gz
Qt-d9c2a93e1dc1ea0248d72fdc7f1bb863f8847658.tar.bz2
Don't store the current list of touch points for a widget in QWidgetPrivate
This is information that's maintained by QApplication, so it belongs there instead.
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qapplication.cpp4
-rw-r--r--src/gui/kernel/qapplication_p.h7
-rw-r--r--src/gui/kernel/qapplication_win.cpp45
-rw-r--r--src/gui/kernel/qwidget_p.h2
4 files changed, 33 insertions, 25 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index e9a113e..2fb6e91 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -4048,8 +4048,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
touchPoint->d->widget = widget;
}
if (origin != widget)
- origin->d_func()->currentTouchPoints.clear();
- widget->d_func()->currentTouchPoints = touchEvent->_touchPoints;
+ d->widgetCurrentTouchPoints.remove(origin);
+ d->widgetCurrentTouchPoints[widget] = touchEvent->_touchPoints;
break;
} else if (widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) {
break;
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index a375933..e44e7aa 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -433,6 +433,7 @@ public:
// map<gesture name -> number of widget subscribed to it>
QMap<QString, int> grabbedGestures;
+ QMap<QWidget *, QList<QTouchEvent::TouchPoint *> > widgetCurrentTouchPoints;
static void updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent);
#if defined(Q_WS_WIN)
@@ -447,8 +448,10 @@ public:
void initializeMultitouch();
static QTouchEvent::TouchPoint *findClosestTouchPoint(const QList<QTouchEvent::TouchPoint *> &activeTouchPoints,
const QPointF &pos);
- QEvent::Type appendTouchPoint(QTouchEvent::TouchPoint *touchPoint);
- QEvent::Type removeTouchPoint(QTouchEvent::TouchPoint *touchPoint);
+ QEvent::Type appendTouchPoint(QTouchEvent::TouchPoint *touchPoint,
+ QList<QTouchEvent::TouchPoint *> *currentTouchPoints);
+ QEvent::Type removeTouchPoint(QTouchEvent::TouchPoint *touchPoint,
+ QList<QTouchEvent::TouchPoint *> *currentTouchPoints);
bool translateTouchEvent(const MSG &msg);
#endif
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 723a3b4..ef49ac6 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -4008,8 +4008,10 @@ void QApplicationPrivate::initializeMultitouch()
GetTouchInputInfo = static_cast<qt_GetTouchInputInfoPtr>(library.resolve("GetTouchInputInfo"));
CloseTouchInputHandle = static_cast<qt_CloseTouchInputHandlePtr>(library.resolve("CloseTouchInputHandle"));
+ widgetCurrentTouchPoints.clear();
touchInputIDToTouchPointID.clear();
appAllTouchPoints.clear();
+ appCurrentTouchPoints.clear();
}
QTouchEvent::TouchPoint *QApplicationPrivate::findClosestTouchPoint(const QList<QTouchEvent::TouchPoint *> &appActiveTouchPoints,
@@ -4028,10 +4030,10 @@ QTouchEvent::TouchPoint *QApplicationPrivate::findClosestTouchPoint(const QList<
return closestTouchPoint;
}
-QEvent::Type QApplicationPrivate::appendTouchPoint(QTouchEvent::TouchPoint *touchPoint)
+QEvent::Type QApplicationPrivate::appendTouchPoint(QTouchEvent::TouchPoint *touchPoint,
+ QList<QTouchEvent::TouchPoint *> *currentTouchPoints)
{
- QWidget *widget = touchPoint->d->widget;
- QEvent::Type eventType = widget->d_func()->currentTouchPoints.isEmpty()
+ QEvent::Type eventType = currentTouchPoints->isEmpty()
? QEvent::TouchBegin
: QEvent::TouchUpdate;
@@ -4043,11 +4045,11 @@ QEvent::Type QApplicationPrivate::appendTouchPoint(QTouchEvent::TouchPoint *touc
}
appCurrentTouchPoints.insert(at, touchPoint);
// again, for the widget's currentTouchPoints
- for (at = 0; at < widget->d_func()->currentTouchPoints.count(); ++at) {
- if (widget->d_func()->currentTouchPoints.at(at)->id() > touchPoint->id())
+ for (at = 0; at < currentTouchPoints->count(); ++at) {
+ if (currentTouchPoints->at(at)->id() > touchPoint->id())
break;
}
- widget->d_func()->currentTouchPoints.insert(at, touchPoint);
+ currentTouchPoints->insert(at, touchPoint);
if (appCurrentTouchPoints.count() > appAllTouchPoints.count()) {
qFatal("Qt: INTERNAL ERROR: appCurrentTouchPoints.count() (%d) > appAllTouchPoints.count() (%d)",
@@ -4058,10 +4060,9 @@ QEvent::Type QApplicationPrivate::appendTouchPoint(QTouchEvent::TouchPoint *touc
return eventType;
}
-QEvent::Type QApplicationPrivate::removeTouchPoint(QTouchEvent::TouchPoint *touchPoint)
+QEvent::Type QApplicationPrivate::removeTouchPoint(QTouchEvent::TouchPoint *touchPoint,
+ QList<QTouchEvent::TouchPoint *> *currentTouchPoints)
{
- QWidget *widget = touchPoint->d->widget;
-
// remove touch point from all known touch points
for (int i = qMin(appCurrentTouchPoints.count() - 1, touchPoint->id()); i >= 0; --i) {
if (appCurrentTouchPoints.at(i) == touchPoint) {
@@ -4070,14 +4071,14 @@ QEvent::Type QApplicationPrivate::removeTouchPoint(QTouchEvent::TouchPoint *touc
}
}
// again, for the widget's currentTouchPoints
- for (int i = qMin(widget->d_func()->currentTouchPoints.count() - 1, touchPoint->id()); i >= 0; --i) {
- if (widget->d_func()->currentTouchPoints.at(i) == touchPoint) {
- widget->d_func()->currentTouchPoints.removeAt(i);
+ for (int i = qMin(currentTouchPoints->count() - 1, touchPoint->id()); i >= 0; --i) {
+ if (currentTouchPoints->at(i) == touchPoint) {
+ currentTouchPoints->removeAt(i);
break;
}
}
- return widget->d_func()->currentTouchPoints.isEmpty() ? QEvent::TouchEnd : QEvent::TouchUpdate;
+ return currentTouchPoints->isEmpty() ? QEvent::TouchEnd : QEvent::TouchUpdate;
}
bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
@@ -4114,6 +4115,7 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
bool down = touchPoint->d->state != Qt::TouchPointReleased;
QPointF globalPos(qreal(touchInput.x) / qreal(100.), qreal(touchInput.y) / qreal(100.));
QEvent::Type eventType = QEvent::None;
+
QList<QTouchEvent::TouchPoint *> activeTouchPoints;
if (!down && (touchInput.dwFlags & TOUCHEVENTF_DOWN)) {
// determine which widget this event will go to
@@ -4129,10 +4131,11 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
}
touchPoint->d->widget = w;
- eventType = appendTouchPoint(touchPoint);
+ QList<QTouchEvent::TouchPoint *> &currentTouchPoints = widgetCurrentTouchPoints[w];
+ eventType = appendTouchPoint(touchPoint, &currentTouchPoints);
// make sure new points are added to activeTouchPoints as well
appActiveTouchPoints = appCurrentTouchPoints;
- activeTouchPoints = w->d_func()->currentTouchPoints;
+ activeTouchPoints = currentTouchPoints;
touchPoint->d->state = Qt::TouchPointPressed;
touchPoint->d->globalPos
@@ -4142,9 +4145,10 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
touchPoint->d->pressure = qreal(1.);
} else if (down && (touchInput.dwFlags & TOUCHEVENTF_UP)) {
QWidget *w = touchPoint->d->widget;
+ QList<QTouchEvent::TouchPoint *> &currentTouchPoints = widgetCurrentTouchPoints[w];
appActiveTouchPoints = appCurrentTouchPoints;
- activeTouchPoints = w->d_func()->currentTouchPoints;
- eventType = removeTouchPoint(touchPoint);
+ activeTouchPoints = currentTouchPoints;
+ eventType = removeTouchPoint(touchPoint, &currentTouchPoints);
touchPoint->d->state = Qt::TouchPointReleased;
touchPoint->d->lastGlobalPos = touchPoint->d->globalPos;
@@ -4153,7 +4157,7 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
} else if (down) {
QWidget *w = touchPoint->d->widget;
appActiveTouchPoints = appCurrentTouchPoints;
- activeTouchPoints = w->d_func()->currentTouchPoints;
+ activeTouchPoints = widgetCurrentTouchPoints.value(w);
eventType = QEvent::TouchUpdate;
touchPoint->d->state = globalPos == touchPoint->d->globalPos
? Qt::TouchPointStationary
@@ -4199,10 +4203,13 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
break;
}
case QEvent::TouchEnd:
- if (!widget->d_func()->currentTouchPoints.isEmpty()) {
+ {
+ QList<QTouchEvent::TouchPoint *> currentTouchPoints = widgetCurrentTouchPoints.take(widget);
+ if (!currentTouchPoints.isEmpty()) {
qFatal("Qt: INTERNAL ERROR, the widget's currentTouchPoints should be empty!");
}
// fall-through intended
+ }
default:
if (widget->testAttribute(Qt::WA_AcceptedTouchBeginEvent)) {
(void) QApplication::sendSpontaneousEvent(widget, &touchEvent);
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 1ab31e4..d1f3acb 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -670,8 +670,6 @@ public:
}
QSize adjustedSize() const;
-
- QList<QTouchEvent::TouchPoint *> currentTouchPoints;
};
inline QWExtra *QWidgetPrivate::extraData() const