summaryrefslogtreecommitdiff
path: root/src/widgets/kernel/qgesturemanager.cpp
diff options
context:
space:
mode:
authorRafael Roquetto <rafael.roquetto.qnx@kdab.com>2012-11-05 21:18:02 -0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-08 15:05:26 +0100
commit602ea84f44ab507e5603ed0808bf4a5dd145d773 (patch)
treef64b7f35261b3ee7b13d70460e081be6e4506756 /src/widgets/kernel/qgesturemanager.cpp
parentd2e5c7787e82fe3157ca3100a0e465a0ed7c5685 (diff)
downloadqtbase-602ea84f44ab507e5603ed0808bf4a5dd145d773.tar.gz
Fix TapAndHoldGesture (others) for QWidgets
After the migration to QPA, touch events usually have a QWindow as a receiver, unlike Qt4 where receivers were QWidgets. This broke QGestureManager and gestures such as the TapAndHoldGesture, because QGestureManager::filterEvent(QWidget *, QEvent *) was never called. Since the receivers are now of QWindow type, QGestureManager::filterEvent(QObject *, QEvent *) gets called instead, always returning false. This has several side effects, one of them was causing the TapAndHold gesture to time out, because it never got a TouchEnd event (and thus it thought that the touch was still going on, even though it was not). This patch ensures that if a gesture event is meant to be delivered to a QWidget, the right event filter method is called. Change-Id: I1df5f763fe6c4d8db0058adbd17d23d70b4988fe Reviewed-by: Zeno Albisser <zeno.albisser@digia.com> Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Denis Dzyubenko <denis@ddenis.info>
Diffstat (limited to 'src/widgets/kernel/qgesturemanager.cpp')
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index 806bfcefb7..72a2469f23 100644
--- a/src/widgets/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
@@ -46,6 +46,7 @@
#include "private/qgraphicsitem_p.h"
#include "private/qevent_p.h"
#include "private/qapplication_p.h"
+#include "private/qwidgetwindow_qpa_p.h"
#include "qgesture.h"
#include "qevent.h"
#include "qgraphicsitem.h"
@@ -531,6 +532,13 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event)
bool QGestureManager::filterEvent(QObject *receiver, QEvent *event)
{
+ // if the receiver is actually a widget, we need to call the correct event
+ // filter method.
+ QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(receiver);
+
+ if (widgetWindow)
+ return filterEvent(widgetWindow->widget(), event);
+
if (!m_gestureToRecognizer.contains(static_cast<QGesture *>(receiver)))
return false;
QGesture *state = static_cast<QGesture *>(receiver);