summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qapplication.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/kernel/qapplication.cpp')
-rw-r--r--src/widgets/kernel/qapplication.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 401fb47dc8..f457993168 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -4272,15 +4272,16 @@ void QApplicationPrivate::cleanupMultitouch_sys()
{
}
-QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, const QPointF &screenPos)
+QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, const QTouchEvent::TouchPoint &touchPoint)
{
+ const QPointF screenPos = touchPoint.screenPos();
int closestTouchPointId = -1;
QObject *closestTarget = 0;
qreal closestDistance = qreal(0.);
QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it = activeTouchPoints.constBegin(),
ite = activeTouchPoints.constEnd();
while (it != ite) {
- if (it.key().device == device) {
+ if (it.key().device == device && it.key().touchPointId != touchPoint.id()) {
const QTouchEvent::TouchPoint &touchPoint = it->touchPoint;
qreal dx = screenPos.x() - touchPoint.screenPos().x();
qreal dy = screenPos.y() - touchPoint.screenPos().y();
@@ -4336,7 +4337,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
}
if (device->type() == QTouchDevice::TouchScreen) {
- QWidget *closestWidget = d->findClosestTouchPointTarget(device, touchPoint.screenPos());
+ QWidget *closestWidget = d->findClosestTouchPointTarget(device, touchPoint);
QWidget *widget = static_cast<QWidget *>(target.data());
if (closestWidget
&& (widget->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget))) {
@@ -4356,8 +4357,10 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
#ifdef Q_OS_OSX
// Single-touch events are normally not sent unless WA_TouchPadAcceptSingleTouchEvents is set.
- // In Qt 4 this check was in OS X-only coode. That behavior is preserved here by the #ifdef.
- if (touchPoints.count() == 1 && !targetWidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents))
+ // In Qt 4 this check was in OS X-only code. That behavior is preserved here by the #ifdef.
+ if (touchPoints.count() == 1
+ && device->type() == QTouchDevice::TouchPad
+ && !targetWidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents))
continue;
#endif
@@ -4373,7 +4376,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
QHash<QWidget *, StatesAndTouchPoints>::ConstIterator it = widgetsNeedingEvents.constBegin();
const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd();
for (; it != end; ++it) {
- QWidget *widget = it.key();
+ const QPointer<QWidget> widget = it.key();
if (!QApplicationPrivate::tryModalHelper(widget, 0))
continue;
@@ -4413,7 +4416,8 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
// has been implicitly accepted and continue to send touch events
if (QApplication::sendSpontaneousEvent(widget, &touchEvent) && touchEvent.isAccepted()) {
accepted = true;
- widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent);
+ if (!widget.isNull())
+ widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent);
}
break;
}