summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-02-09 14:39:40 +0200
committerQt by Nokia <qt-info@nokia.com>2012-02-10 11:41:04 +0100
commit09e2e77be25e02ff1c3ba432d739fbc5fe860ec7 (patch)
tree369e230e9b7ad53e699b151d00f1a8b629cded30 /src/widgets/kernel
parente5830479d62240ed0af580780c0586baca2b66a2 (diff)
Handle TouchCancel in gui and widgets
Change-Id: I31739840348d88ae408ac1aae2399f6328ccdd43 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/qapplication.cpp22
-rw-r--r--src/widgets/kernel/qapplication_p.h1
-rw-r--r--src/widgets/kernel/qwidget.cpp2
-rw-r--r--src/widgets/kernel/qwidgetwindow_qpa.cpp6
4 files changed, 30 insertions, 1 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index d2b4e01c0b..8d776e2f29 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -5200,6 +5200,28 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window,
}
}
+void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong timestamp)
+{
+ QTouchEvent touchEvent(QEvent::TouchCancel, device, QApplication::keyboardModifiers());
+ touchEvent.setTimestamp(timestamp);
+ QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it
+ = self->activeTouchPoints.constBegin(), ite = self->activeTouchPoints.constEnd();
+ QSet<QWidget *> widgetsNeedingCancel;
+ while (it != ite) {
+ QWidget *widget = static_cast<QWidget *>(it->target.data());
+ if (widget)
+ widgetsNeedingCancel.insert(widget);
+ ++it;
+ }
+ for (QSet<QWidget *>::const_iterator widIt = widgetsNeedingCancel.constBegin(),
+ widItEnd = widgetsNeedingCancel.constEnd(); widIt != widItEnd; ++widIt) {
+ QWidget *widget = *widIt;
+ touchEvent.setWindow(widget->windowHandle());
+ touchEvent.setTarget(widget);
+ QApplication::sendSpontaneousEvent(widget, &touchEvent);
+ }
+}
+
#ifndef QT_NO_GESTURES
QGestureManager* QGestureManager::instance()
{
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index d9d184d51a..b4cd22df13 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -386,6 +386,7 @@ public:
QTouchDevice *device,
const QList<QTouchEvent::TouchPoint> &touchPoints,
ulong timestamp);
+ static void translateTouchCancel(QTouchDevice *device, ulong timestamp);
private:
#ifdef Q_WS_QWS
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 008f0391bc..cd3669717d 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -7776,6 +7776,7 @@ bool QWidget::event(QEvent *event)
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
+ case QEvent::TouchCancel:
case QEvent::ContextMenu:
#ifndef QT_NO_WHEELEVENT
case QEvent::Wheel:
@@ -8178,6 +8179,7 @@ bool QWidget::event(QEvent *event)
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
+ case QEvent::TouchCancel:
{
event->ignore();
break;
diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp
index e7ba4853a0..c2524567f1 100644
--- a/src/widgets/kernel/qwidgetwindow_qpa.cpp
+++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp
@@ -110,6 +110,7 @@ bool QWidgetWindow::event(QEvent *event)
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
+ case QEvent::TouchCancel:
handleTouchEvent(static_cast<QTouchEvent *>(event));
return true;
@@ -289,7 +290,10 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
void QWidgetWindow::handleTouchEvent(QTouchEvent *event)
{
- QApplicationPrivate::translateRawTouchEvent(m_widget, event->device(), event->touchPoints(), event->timestamp());
+ if (event->type() == QEvent::TouchCancel)
+ QApplicationPrivate::translateTouchCancel(event->device(), event->timestamp());
+ else
+ QApplicationPrivate::translateRawTouchEvent(m_widget, event->device(), event->touchPoints(), event->timestamp());
}
void QWidgetWindow::handleKeyEvent(QKeyEvent *event)