summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2013-04-02 16:21:35 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-12 09:31:51 +0200
commit8c81b282f8e18897257b93cb3fc149d74441c40e (patch)
tree9e735ae924f987dd1a2c9db67de95d0f3d86a8f8 /src
parentf8a047d8435581d076e6bd4c9727209104a7fc84 (diff)
Widgets: Propagate 'accepted'-state of touch begin events.
Task-number: QTBUG-29946 Change-Id: Ia9ac54251f52b6ae4b3d667e49b96441def72a57 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qapplication.cpp15
-rw-r--r--src/widgets/kernel/qapplication_p.h2
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp8
3 files changed, 16 insertions, 9 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 02fcfde59e..d036f6bada 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -3837,7 +3837,7 @@ bool QApplicationPrivate::translateTouchToMouse(QWidget *widget, QTouchEvent *ev
return false;
}
-void QApplicationPrivate::translateRawTouchEvent(QWidget *window,
+bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
QTouchDevice *device,
const QList<QTouchEvent::TouchPoint> &touchPoints,
ulong timestamp)
@@ -3899,8 +3899,9 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window,
}
if (widgetsNeedingEvents.isEmpty())
- return;
+ return false;
+ bool accepted = false;
QHash<QWidget *, StatesAndTouchPoints>::ConstIterator it = widgetsNeedingEvents.constBegin();
const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd();
for (; it != end; ++it) {
@@ -3939,19 +3940,23 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window,
{
// 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);
- (void ) QApplication::sendSpontaneousEvent(widget, &touchEvent);
+ if (QApplication::sendSpontaneousEvent(widget, &touchEvent) && touchEvent.isAccepted()) {
+ accepted = true;
+ widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent);
+ }
break;
}
default:
if (widget->testAttribute(Qt::WA_WState_AcceptedTouchBeginEvent)) {
if (touchEvent.type() == QEvent::TouchEnd)
widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, false);
- (void) QApplication::sendSpontaneousEvent(widget, &touchEvent);
+ if (QApplication::sendSpontaneousEvent(widget, &touchEvent) && touchEvent.isAccepted())
+ accepted = true;
}
break;
}
}
+ return accepted;
}
void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong timestamp)
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index ca1bccb727..87cf259ba5 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -284,7 +284,7 @@ public:
void appendTouchPoint(const QTouchEvent::TouchPoint &touchPoint);
void removeTouchPoint(int touchPointId);
bool translateTouchToMouse(QWidget *widget, QTouchEvent *event);
- static void translateRawTouchEvent(QWidget *widget,
+ static bool translateRawTouchEvent(QWidget *widget,
QTouchDevice *device,
const QList<QTouchEvent::TouchPoint> &touchPoints,
ulong timestamp);
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index ddb570d6c7..bedcfe78bf 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -473,10 +473,12 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
void QWidgetWindow::handleTouchEvent(QTouchEvent *event)
{
- if (event->type() == QEvent::TouchCancel)
+ if (event->type() == QEvent::TouchCancel) {
QApplicationPrivate::translateTouchCancel(event->device(), event->timestamp());
- else
- QApplicationPrivate::translateRawTouchEvent(m_widget, event->device(), event->touchPoints(), event->timestamp());
+ event->accept();
+ } else {
+ event->setAccepted(QApplicationPrivate::translateRawTouchEvent(m_widget, event->device(), event->touchPoints(), event->timestamp()));
+ }
}
void QWidgetWindow::handleKeyEvent(QKeyEvent *event)