summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/global/qnamespace.h10
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp85
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h14
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.cpp46
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.h9
-rw-r--r--src/gui/kernel/qapplication_p.h8
-rw-r--r--src/gui/kernel/qapplication_win.cpp59
-rw-r--r--src/gui/kernel/qevent.cpp17
-rw-r--r--src/gui/kernel/qevent.h16
9 files changed, 165 insertions, 99 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 29f6701..a6db1a4 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1546,11 +1546,12 @@ public:
};
enum TouchPointState {
- TouchPointPressed,
- TouchPointMoved,
- TouchPointStationary,
- TouchPointReleased
+ TouchPointPressed = 0x01,
+ TouchPointMoved = 0x02,
+ TouchPointStationary = 0x04,
+ TouchPointReleased = 0x08
};
+ Q_DECLARE_FLAGS(TouchPointStates, TouchPointState)
enum GestureType
{
@@ -1608,6 +1609,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::DropActions)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::ItemFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::MatchFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TextInteractionFlags)
+Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TouchPointStates)
typedef bool (*qInternalCallback)(void **);
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 952e0c1..e7a0547 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -4027,7 +4027,7 @@ void QGraphicsScenePrivate::sendGestureEvent(const QSet<QGesture*> &gestures, co
gd->graphicsItem = 0;
//### THIS IS BS, DONT FORGET TO REWRITE THIS CODE
- // need to make sure we try to deliver event just once to each widget
+ // need to make sure we try to deliver event just once to each widget
const QString gestureType = g->type();
QList<QGraphicsItem*> itemsUnderGesture = q->items(g->hotSpot());
for (int i = 0; i < itemsUnderGesture.size(); ++i) {
@@ -5710,13 +5710,9 @@ QGraphicsSceneTouchEvent::TouchPoint *QGraphicsScenePrivate::findClosestTouchPoi
return closestTouchPoint;
}
-QEvent::Type QGraphicsScenePrivate::appendTouchPoint(QGraphicsSceneTouchEvent::TouchPoint *touchPoint,
- QList<QGraphicsSceneTouchEvent::TouchPoint *> *currentTouchPoints)
+void QGraphicsScenePrivate::appendTouchPoint(QGraphicsSceneTouchEvent::TouchPoint *touchPoint,
+ QList<QGraphicsSceneTouchEvent::TouchPoint *> *currentTouchPoints)
{
- QEvent::Type eventType = currentTouchPoints->isEmpty()
- ? QEvent::GraphicsSceneTouchBegin
- : QEvent::GraphicsSceneTouchUpdate;
-
// insort touch point (for the app)
int at = 0;
for (; at < sceneCurrentTouchPoints.count(); ++at) {
@@ -5730,12 +5726,10 @@ QEvent::Type QGraphicsScenePrivate::appendTouchPoint(QGraphicsSceneTouchEvent::T
break;
}
currentTouchPoints->insert(at, touchPoint);
-
- return eventType;
}
-QEvent::Type QGraphicsScenePrivate::removeTouchPoint(QGraphicsSceneTouchEvent::TouchPoint *touchPoint,
- QList<QGraphicsSceneTouchEvent::TouchPoint *> *currentTouchPoints)
+void QGraphicsScenePrivate::removeTouchPoint(QGraphicsSceneTouchEvent::TouchPoint *touchPoint,
+ QList<QGraphicsSceneTouchEvent::TouchPoint *> *currentTouchPoints)
{
// remove touch point from all known touch points
for (int i = qMin(sceneCurrentTouchPoints.count() - 1, touchPoint->id()); i >= 0; --i) {
@@ -5751,21 +5745,19 @@ QEvent::Type QGraphicsScenePrivate::removeTouchPoint(QGraphicsSceneTouchEvent::T
break;
}
}
-
- return currentTouchPoints->isEmpty() ? QEvent::GraphicsSceneTouchEnd : QEvent::GraphicsSceneTouchUpdate;
}
void QGraphicsScenePrivate::touchEventHandler(QGraphicsSceneTouchEvent *sceneTouchEvent)
{
QList<QGraphicsSceneTouchEvent::TouchPoint *> sceneActiveTouchPoints = sceneCurrentTouchPoints;
- QHash<QGraphicsItem *, QGraphicsSceneTouchEvent *> itemsNeedingEvents;
+ typedef QPair<Qt::TouchPointStates, QList<QGraphicsSceneTouchEvent::TouchPoint *> > StatesAndTouchPoints;
+ QHash<QGraphicsItem *, StatesAndTouchPoints> itemsNeedingEvents;
for (int i = 0; i < sceneTouchEvent->touchPoints().count(); ++i) {
QGraphicsSceneTouchEvent::TouchPoint *touchPoint = sceneTouchEvent->touchPoints().at(i);
// update state
QGraphicsItem *item = 0;
- QEvent::Type eventType = QEvent::None;
QList<QGraphicsSceneTouchEvent::TouchPoint *> activeTouchPoints;
if (touchPoint->state() == Qt::TouchPointPressed) {
// determine which item this event will go to
@@ -5789,7 +5781,7 @@ void QGraphicsScenePrivate::touchEventHandler(QGraphicsSceneTouchEvent *sceneTou
itemForTouchPointId.insert(touchPoint->id(), item);
QList<QGraphicsSceneTouchEvent::TouchPoint *> &currentTouchPoints = itemCurrentTouchPoints[item];
- eventType = appendTouchPoint(touchPoint, &currentTouchPoints);
+ appendTouchPoint(touchPoint, &currentTouchPoints);
// make sure new points are added to activeTouchPoints as well
sceneActiveTouchPoints = sceneCurrentTouchPoints;
activeTouchPoints = currentTouchPoints;
@@ -5801,7 +5793,7 @@ void QGraphicsScenePrivate::touchEventHandler(QGraphicsSceneTouchEvent *sceneTou
QList<QGraphicsSceneTouchEvent::TouchPoint *> &currentTouchPoints = itemCurrentTouchPoints[item];
sceneActiveTouchPoints = sceneCurrentTouchPoints;
activeTouchPoints = currentTouchPoints;
- eventType = removeTouchPoint(touchPoint, &currentTouchPoints);
+ removeTouchPoint(touchPoint, &currentTouchPoints);
} else {
item = itemForTouchPointId.value(touchPoint->id());
if (!item)
@@ -5809,20 +5801,11 @@ void QGraphicsScenePrivate::touchEventHandler(QGraphicsSceneTouchEvent *sceneTou
sceneActiveTouchPoints = sceneCurrentTouchPoints;
activeTouchPoints = itemCurrentTouchPoints.value(item);
- eventType = QEvent::GraphicsSceneTouchUpdate;
- }
- Q_ASSERT(eventType != QEvent::None);
-
- if (touchPoint->state() != Qt::TouchPointStationary) {
- QGraphicsSceneTouchEvent *&touchEvent = itemsNeedingEvents[item];
- if (!touchEvent) {
- touchEvent = new QGraphicsSceneTouchEvent(eventType);
- touchEvent->setWidget(sceneTouchEvent->widget());
- touchEvent->setModifiers(sceneTouchEvent->modifiers());
- }
- Q_ASSERT(touchEvent->type() == eventType);
- touchEvent->setTouchPoints(activeTouchPoints);
}
+
+ StatesAndTouchPoints &statesAndTouchPoints = itemsNeedingEvents[item];
+ statesAndTouchPoints.first |= touchPoint->state();
+ statesAndTouchPoints.second = activeTouchPoints;
}
if (itemsNeedingEvents.isEmpty()) {
@@ -5831,21 +5814,45 @@ void QGraphicsScenePrivate::touchEventHandler(QGraphicsSceneTouchEvent *sceneTou
}
bool acceptSceneTouchEvent = false;
- QHash<QGraphicsItem *, QGraphicsSceneTouchEvent *>::ConstIterator it = itemsNeedingEvents.constBegin();
- const QHash<QGraphicsItem *, QGraphicsSceneTouchEvent *>::ConstIterator end = itemsNeedingEvents.constEnd();
+ QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator it = itemsNeedingEvents.constBegin();
+ const QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator end = itemsNeedingEvents.constEnd();
for (; it != end; ++it) {
QGraphicsItem *item = it.key();
- QGraphicsSceneTouchEvent *touchEvent = it.value();
+ // determine event type from the state mask
+ QEvent::Type eventType;
+ switch (it.value().first) {
+ case Qt::TouchPointPressed:
+ // all touch points have pressed state
+ eventType = QEvent::GraphicsSceneTouchBegin;
+ break;
+ case Qt::TouchPointReleased:
+ // all touch points have released state
+ eventType = QEvent::GraphicsSceneTouchEnd;
+ break;
+ case Qt::TouchPointStationary:
+ // don't send the event if nothing changed
+ continue;
+ default:
+ // all other combinations
+ eventType = QEvent::GraphicsSceneTouchUpdate;
+ break;
+ }
+
+ QGraphicsSceneTouchEvent touchEvent(eventType);
+ touchEvent.setWidget(sceneTouchEvent->widget());
+ touchEvent.setModifiers(sceneTouchEvent->modifiers());
+ touchEvent.setTouchPointStates(it.value().first);
+ touchEvent.setTouchPoints(it.value().second);
- switch (touchEvent->type()) {
+ switch (touchEvent.type()) {
case QEvent::GraphicsSceneTouchBegin:
{
// if the TouchBegin handler recurses, we assume that means the event
// has been implicitly accepted and continue to send touch events
item->d_ptr->acceptedTouchBeginEvent = true;
- bool res = sendTouchBeginEvent(item, touchEvent)
- && touchEvent->isAccepted();
+ bool res = sendTouchBeginEvent(item, &touchEvent)
+ && touchEvent.isAccepted();
acceptSceneTouchEvent = acceptSceneTouchEvent || res;
break;
}
@@ -5859,14 +5866,12 @@ void QGraphicsScenePrivate::touchEventHandler(QGraphicsSceneTouchEvent *sceneTou
}
default:
if (item->d_ptr->acceptedTouchBeginEvent) {
- updateTouchPointsForItem(item, touchEvent);
- (void) sendEvent(item, touchEvent);
+ updateTouchPointsForItem(item, &touchEvent);
+ (void) sendEvent(item, &touchEvent);
acceptSceneTouchEvent = true;
}
break;
}
-
- delete touchEvent;
}
sceneTouchEvent->setAccepted(acceptSceneTouchEvent);
}
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index 160ba49..22feb4c 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -164,7 +164,7 @@ public:
void grabKeyboard(QGraphicsItem *item);
void ungrabKeyboard(QGraphicsItem *item, bool itemIsDying = false);
void clearKeyboardGrabber();
-
+
QGraphicsItem *dragDropItem;
QGraphicsWidget *enterWidget;
Qt::DropAction lastDropAction;
@@ -244,7 +244,7 @@ public:
static bool closestItemLast_withoutCache(const QGraphicsItem *item1, const QGraphicsItem *item2);
static inline bool closestItemFirst_withCache(const QGraphicsItem *item1, const QGraphicsItem *item2)
- {
+ {
return item1->d_ptr->globalStackingOrder < item2->d_ptr->globalStackingOrder;
}
static inline bool closestItemLast_withCache(const QGraphicsItem *item1, const QGraphicsItem *item2)
@@ -257,7 +257,7 @@ public:
void drawItemHelper(QGraphicsItem *item, QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget,
bool painterStateProtection);
-
+
QStyle *style;
QFont font;
void setFont_helper(const QFont &font);
@@ -285,10 +285,10 @@ public:
static void updateTouchPointsForItem(QGraphicsItem *item, QGraphicsSceneTouchEvent *touchEvent);
static QGraphicsSceneTouchEvent::TouchPoint *findClosestTouchPoint(const QList<QGraphicsSceneTouchEvent::TouchPoint *> &activeTouchPoints,
const QPointF &scenePos);
- QEvent::Type appendTouchPoint(QGraphicsSceneTouchEvent::TouchPoint *touchPoint,
- QList<QGraphicsSceneTouchEvent::TouchPoint *> *currentTouchPoints);
- QEvent::Type removeTouchPoint(QGraphicsSceneTouchEvent::TouchPoint *touchPoint,
- QList<QGraphicsSceneTouchEvent::TouchPoint *> *currentTouchPoints);
+ void appendTouchPoint(QGraphicsSceneTouchEvent::TouchPoint *touchPoint,
+ QList<QGraphicsSceneTouchEvent::TouchPoint *> *currentTouchPoints);
+ void removeTouchPoint(QGraphicsSceneTouchEvent::TouchPoint *touchPoint,
+ QList<QGraphicsSceneTouchEvent::TouchPoint *> *currentTouchPoints);
void touchEventHandler(QGraphicsSceneTouchEvent *touchEvent);
bool sendTouchBeginEvent(QGraphicsItem *item, QGraphicsSceneTouchEvent *touchEvent);
};
diff --git a/src/gui/graphicsview/qgraphicssceneevent.cpp b/src/gui/graphicsview/qgraphicssceneevent.cpp
index bb13bd8..0104e9c 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.cpp
+++ b/src/gui/graphicsview/qgraphicssceneevent.cpp
@@ -1957,11 +1957,12 @@ class QGraphicsSceneTouchEventPrivate : public QGraphicsSceneEventPrivate
Q_DECLARE_PUBLIC(QGraphicsSceneTouchEvent)
public:
inline QGraphicsSceneTouchEventPrivate()
- : modifiers(Qt::NoModifier)
+ : modifiers(Qt::NoModifier), touchPointStates()
{ }
- QList<QGraphicsSceneTouchEvent::TouchPoint *> touchPoints;
Qt::KeyboardModifiers modifiers;
+ Qt::TouchPointStates touchPointStates;
+ QList<QGraphicsSceneTouchEvent::TouchPoint *> touchPoints;
};
/*!
@@ -1980,38 +1981,55 @@ QGraphicsSceneTouchEvent::~QGraphicsSceneTouchEvent()
{ }
/*!
- Returns the list of touch points for this event.
+ Returns the keyboard modifiers in use at the time the event was
+ sent.
+*/
+Qt::KeyboardModifiers QGraphicsSceneTouchEvent::modifiers() const
+{
+ Q_D(const QGraphicsSceneTouchEvent);
+ return d->modifiers;
+}
- \sa QGraphicsSceneTouchEvent::TouchPoint
+/*! \internal */
+void QGraphicsSceneTouchEvent::setModifiers(Qt::KeyboardModifiers modifiers)
+{
+ Q_D(QGraphicsSceneTouchEvent);
+ d->modifiers = modifiers;
+}
+
+/*!
+ Returns a bitwise OR of all of the touch point states at the time
+ the event was sent.
*/
-const QList<QGraphicsSceneTouchEvent::TouchPoint *> &QGraphicsSceneTouchEvent::touchPoints() const
+Qt::TouchPointStates QGraphicsSceneTouchEvent::touchPointStates() const
{
Q_D(const QGraphicsSceneTouchEvent);
- return d->touchPoints;
+ return d->touchPointStates;
}
/*! \internal */
-void QGraphicsSceneTouchEvent::setTouchPoints(const QList<QGraphicsSceneTouchEvent::TouchPoint *> &touchPoints)
+void QGraphicsSceneTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPointStates)
{
Q_D(QGraphicsSceneTouchEvent);
- d->touchPoints = touchPoints;
+ d->touchPointStates = touchPointStates;
}
/*!
- Returns the keyboard modifiers in use at the time the event was
- sent.
+ Returns the list of touch points for this event.
+
+ \sa QGraphicsSceneTouchEvent::TouchPoint
*/
-Qt::KeyboardModifiers QGraphicsSceneTouchEvent::modifiers() const
+const QList<QGraphicsSceneTouchEvent::TouchPoint *> &QGraphicsSceneTouchEvent::touchPoints() const
{
Q_D(const QGraphicsSceneTouchEvent);
- return d->modifiers;
+ return d->touchPoints;
}
/*! \internal */
-void QGraphicsSceneTouchEvent::setModifiers(Qt::KeyboardModifiers modifiers)
+void QGraphicsSceneTouchEvent::setTouchPoints(const QList<QGraphicsSceneTouchEvent::TouchPoint *> &touchPoints)
{
Q_D(QGraphicsSceneTouchEvent);
- d->modifiers = modifiers;
+ d->touchPoints = touchPoints;
}
/*!
diff --git a/src/gui/graphicsview/qgraphicssceneevent.h b/src/gui/graphicsview/qgraphicssceneevent.h
index 8b24d33..9fcda2f 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.h
+++ b/src/gui/graphicsview/qgraphicssceneevent.h
@@ -372,12 +372,15 @@ public:
QGraphicsSceneTouchEvent(Type type = None);
~QGraphicsSceneTouchEvent();
- const QList<QGraphicsSceneTouchEvent::TouchPoint *> &touchPoints() const;
- void setTouchPoints(const QList<QGraphicsSceneTouchEvent::TouchPoint *> &touchPoints);
-
Qt::KeyboardModifiers modifiers() const;
void setModifiers(Qt::KeyboardModifiers modifiers);
+ Qt::TouchPointStates touchPointStates() const;
+ void setTouchPointStates(Qt::TouchPointStates touchPointStates);
+
+ const QList<QGraphicsSceneTouchEvent::TouchPoint *> &touchPoints() const;
+ void setTouchPoints(const QList<QGraphicsSceneTouchEvent::TouchPoint *> &touchPoints);
+
private:
Q_DECLARE_PRIVATE(QGraphicsSceneTouchEvent);
};
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 08020fb..34395c9 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -450,10 +450,10 @@ public:
void initializeMultitouch();
static QTouchEvent::TouchPoint *findClosestTouchPoint(const QList<QTouchEvent::TouchPoint *> &activeTouchPoints,
const QPointF &screenPos);
- QEvent::Type appendTouchPoint(QTouchEvent::TouchPoint *touchPoint,
- QList<QTouchEvent::TouchPoint *> *currentTouchPoints);
- QEvent::Type removeTouchPoint(QTouchEvent::TouchPoint *touchPoint,
- QList<QTouchEvent::TouchPoint *> *currentTouchPoints);
+ void appendTouchPoint(QTouchEvent::TouchPoint *touchPoint,
+ QList<QTouchEvent::TouchPoint *> *currentTouchPoints);
+ void 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 148988f..0fc76ae 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -4011,13 +4011,9 @@ QTouchEvent::TouchPoint *QApplicationPrivate::findClosestTouchPoint(const QList<
return closestTouchPoint;
}
-QEvent::Type QApplicationPrivate::appendTouchPoint(QTouchEvent::TouchPoint *touchPoint,
- QList<QTouchEvent::TouchPoint *> *currentTouchPoints)
+void QApplicationPrivate::appendTouchPoint(QTouchEvent::TouchPoint *touchPoint,
+ QList<QTouchEvent::TouchPoint *> *currentTouchPoints)
{
- QEvent::Type eventType = currentTouchPoints->isEmpty()
- ? QEvent::TouchBegin
- : QEvent::TouchUpdate;
-
// insort touch point (for the app)
int at = 0;
for (; at < appCurrentTouchPoints.count(); ++at) {
@@ -4037,12 +4033,10 @@ QEvent::Type QApplicationPrivate::appendTouchPoint(QTouchEvent::TouchPoint *touc
appCurrentTouchPoints.count(),
appAllTouchPoints.count());
}
-
- return eventType;
}
-QEvent::Type QApplicationPrivate::removeTouchPoint(QTouchEvent::TouchPoint *touchPoint,
- QList<QTouchEvent::TouchPoint *> *currentTouchPoints)
+void QApplicationPrivate::removeTouchPoint(QTouchEvent::TouchPoint *touchPoint,
+ QList<QTouchEvent::TouchPoint *> *currentTouchPoints)
{
// remove touch point from all known touch points
for (int i = qMin(appCurrentTouchPoints.count() - 1, touchPoint->id()); i >= 0; --i) {
@@ -4058,8 +4052,6 @@ QEvent::Type QApplicationPrivate::removeTouchPoint(QTouchEvent::TouchPoint *touc
break;
}
}
-
- return currentTouchPoints->isEmpty() ? QEvent::TouchEnd : QEvent::TouchUpdate;
}
bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
@@ -4072,7 +4064,8 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
QList<QTouchEvent::TouchPoint *> appActiveTouchPoints = appCurrentTouchPoints;
- QHash<QWidget *, QTouchEvent> widgetsNeedingEvents;
+ typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint *> > StatesAndTouchPoints;
+ QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents;
QVector<TOUCHINPUT> winTouchInputs(msg.wParam);
memset(winTouchInputs.data(), 0, sizeof(TOUCHINPUT) * winTouchInputs.count());
QApplicationPrivate::GetTouchInputInfo((HANDLE) msg.lParam, msg.wParam, winTouchInputs.data(), sizeof(TOUCHINPUT));
@@ -4096,7 +4089,6 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
QWidget *widget = 0;
bool down = touchPoint->state() != Qt::TouchPointReleased;
QPointF screenPos(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)) {
@@ -4116,7 +4108,7 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
widgetForTouchPointId[touchPoint->id()] = widget;
QList<QTouchEvent::TouchPoint *> &currentTouchPoints = widgetCurrentTouchPoints[widget];
- eventType = appendTouchPoint(touchPoint, &currentTouchPoints);
+ appendTouchPoint(touchPoint, &currentTouchPoints);
// make sure new points are added to activeTouchPoints as well
appActiveTouchPoints = appCurrentTouchPoints;
activeTouchPoints = currentTouchPoints;
@@ -4131,7 +4123,7 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
QList<QTouchEvent::TouchPoint *> &currentTouchPoints = widgetCurrentTouchPoints[widget];
appActiveTouchPoints = appCurrentTouchPoints;
activeTouchPoints = currentTouchPoints;
- eventType = removeTouchPoint(touchPoint, &currentTouchPoints);
+ removeTouchPoint(touchPoint, &currentTouchPoints);
touchPoint->setState(Qt::TouchPointReleased);
touchPoint->setLastScreenPos(touchPoint->screenPos());
@@ -4141,7 +4133,6 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
widget = widgetForTouchPointId.value(touchPoint->id());
appActiveTouchPoints = appCurrentTouchPoints;
activeTouchPoints = widgetCurrentTouchPoints.value(widget);
- eventType = QEvent::TouchUpdate;
touchPoint->setState(screenPos == touchPoint->screenPos()
? Qt::TouchPointStationary
: Qt::TouchPointMoved);
@@ -4149,12 +4140,11 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
touchPoint->setScreenPos(screenPos);
// pressure should still be 1.
}
- Q_ASSERT(widget != 0 && eventType != QEvent::None);
+ Q_ASSERT(widget != 0);
- if (touchPoint->state() != Qt::TouchPointStationary) {
- widgetsNeedingEvents.insert(widget,
- QTouchEvent(eventType, q->keyboardModifiers(), activeTouchPoints));
- }
+ StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[widget];
+ maskAndPoints.first |= touchPoint->state();
+ maskAndPoints.second = activeTouchPoints;
}
QApplicationPrivate::CloseTouchInputHandle((HANDLE) msg.lParam);
@@ -4164,14 +4154,33 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
bool returnValue = false;
qt_tabletChokeMouse = false;
- QHash<QWidget *, QTouchEvent>::ConstIterator it = widgetsNeedingEvents.constBegin();
- const QHash<QWidget *, QTouchEvent>::ConstIterator end = widgetsNeedingEvents.constEnd();
+ QHash<QWidget *, StatesAndTouchPoints>::ConstIterator it = widgetsNeedingEvents.constBegin();
+ const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd();
for (; it != end; ++it) {
QWidget *widget = it.key();
if (!QApplicationPrivate::tryModalHelper(widget, 0))
continue;
- QTouchEvent touchEvent = it.value();
+ QEvent::Type eventType;
+ switch(it.value().first) {
+ case Qt::TouchPointPressed:
+ eventType = QEvent::TouchBegin;
+ break;
+ case Qt::TouchPointReleased:
+ eventType = QEvent::TouchEnd;
+ break;
+ case Qt::TouchPointStationary:
+ // don't send the event if nothing changed
+ continue;
+ default:
+ eventType = QEvent::TouchUpdate;
+ break;
+ }
+
+ QTouchEvent touchEvent(eventType,
+ q->keyboardModifiers(),
+ it.value().first,
+ it.value().second);
updateTouchPointsForWidget(widget, &touchEvent);
switch (touchEvent.type()) {
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 419107c..7a4c424 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -3727,8 +3727,11 @@ void QGestureEvent::accept(const QString &type)
*/
QTouchEvent::QTouchEvent(QEvent::Type type,
Qt::KeyboardModifiers modifiers,
+ Qt::TouchPointStates touchPointStates,
const QList<QTouchEvent::TouchPoint *> &touchPoints)
- : QInputEvent(type, modifiers), _touchPoints(touchPoints)
+ : QInputEvent(type, modifiers),
+ _touchPointStates(touchPointStates),
+ _touchPoints(touchPoints)
{ }
/*!
@@ -3737,6 +3740,18 @@ QTouchEvent::QTouchEvent(QEvent::Type type,
QTouchEvent::~QTouchEvent()
{ }
+/*! \fn Qt::TouchPointStates QTouchEvent::touchPointStates() const
+
+ Returns a bitwise OR of all the touch point states for this event.
+*/
+
+/*! \fn void QTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPointStates)
+
+ \internal
+
+ Sets a bitwise OR of all the touch point states for this event.
+*/
+
/*! \fn const QList<QTouchEvent::TouchPoint *> &QTouchEvent::TouchPoints() const
Returns the list of touch points contained in the touch event.
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 75cfb9d..0c7d101 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -800,16 +800,30 @@ public:
QTouchEvent(QEvent::Type type,
Qt::KeyboardModifiers modifiers,
+ Qt::TouchPointStates touchPointStates,
const QList<QTouchEvent::TouchPoint *> &touchPoints);
~QTouchEvent();
- inline const QList<QTouchEvent::TouchPoint *> &touchPoints() const { return _touchPoints; }
+ inline Qt::TouchPointStates touchPointStates() const
+ {
+ return _touchPointStates;
+ }
+ inline void setTouchPointStates(Qt::TouchPointStates touchPointStates)
+ {
+ _touchPointStates = touchPointStates;
+ }
+
+ inline const QList<QTouchEvent::TouchPoint *> &touchPoints() const
+ {
+ return _touchPoints;
+ }
inline void setTouchPoints(const QList<QTouchEvent::TouchPoint *> &touchPoints)
{
_touchPoints = touchPoints;
}
protected:
+ Qt::TouchPointStates _touchPointStates;
QList<QTouchEvent::TouchPoint *> _touchPoints;
};