summaryrefslogtreecommitdiffstats
path: root/src/core/render_widget_host_view_qt.cpp
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2014-11-04 06:05:39 -0800
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>2014-11-12 16:46:27 +0100
commit51d7318aa4bebd38d43daad0dc19b45ab3afaa35 (patch)
tree75c6100a43f961d6bf5ad20f51c7dec299cf74ac /src/core/render_widget_host_view_qt.cpp
parent85d26a2919a016ae76c6d83af28281cffd8a3aa1 (diff)
Process touch events in sorted order.
We are mapping a single QTouchEvent to multiple MotionEventQt for Chromium. For gesture recognition it is important that these motion events are being processed in a sorted manner, as a move event might trigger a different gesture depending on how many ACTION_DOWN or ACTION_POINTER_DOWN were received before. It is particularly illegal to process an ACTION_MOVE with multiple touch points without having received a ACTION_POINTER_DOWN before. Change-Id: I75d22dd845774a14b5f590e0e0ce46263c4a49f4 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com> Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'src/core/render_widget_host_view_qt.cpp')
-rw-r--r--src/core/render_widget_host_view_qt.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 2cc5510ae..c221e94e3 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -133,6 +133,12 @@ static inline ui::GestureProvider::Config QtGestureProviderConfig() {
return config;
}
+static inline bool compareTouchPoints(const QTouchEvent::TouchPoint &lhs, const QTouchEvent::TouchPoint &rhs)
+{
+ // TouchPointPressed < TouchPointMoved < TouchPointReleased
+ return lhs.state() < rhs.state();
+}
+
class MotionEventQt : public ui::MotionEvent {
public:
MotionEventQt(const QList<QTouchEvent::TouchPoint> &touchPoints, const base::TimeTicks &eventTime, Action action, int index = -1)
@@ -983,6 +989,10 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev)
if (ev->type() == QEvent::TouchBegin)
m_sendMotionActionDown = true;
+ // Make sure that ACTION_POINTER_DOWN is delivered before ACTION_MOVE,
+ // and ACTION_MOVE before ACTION_POINTER_UP.
+ std::sort(touchPoints.begin(), touchPoints.end(), compareTouchPoints);
+
for (int i = 0; i < touchPoints.size(); ++i) {
ui::MotionEvent::Action action;
switch (touchPoints[i].state()) {