Commit 51d7318a authored by Zeno Albisser's avatar Zeno Albisser Committed by Jani Heikkinen
Browse files

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: default avatarJocelyn Turcotte <jocelyn.turcotte@digia.com>
Reviewed-by: default avatarAndras Becsi <andras.becsi@digia.com>
Showing with 10 additions and 0 deletions
...@@ -133,6 +133,12 @@ static inline ui::GestureProvider::Config QtGestureProviderConfig() { ...@@ -133,6 +133,12 @@ static inline ui::GestureProvider::Config QtGestureProviderConfig() {
return config; 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 { class MotionEventQt : public ui::MotionEvent {
public: public:
MotionEventQt(const QList<QTouchEvent::TouchPoint> &touchPoints, const base::TimeTicks &eventTime, Action action, int index = -1) MotionEventQt(const QList<QTouchEvent::TouchPoint> &touchPoints, const base::TimeTicks &eventTime, Action action, int index = -1)
...@@ -983,6 +989,10 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) ...@@ -983,6 +989,10 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev)
if (ev->type() == QEvent::TouchBegin) if (ev->type() == QEvent::TouchBegin)
m_sendMotionActionDown = true; 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) { for (int i = 0; i < touchPoints.size(); ++i) {
ui::MotionEvent::Action action; ui::MotionEvent::Action action;
switch (touchPoints[i].state()) { switch (touchPoints[i].state()) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment