summaryrefslogtreecommitdiffstats
path: root/src/core/render_widget_host_view_qt.cpp
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-05-16 19:17:36 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-19 12:28:30 +0200
commitf3c68034e1da662651e0075643c50f9432cb37b6 (patch)
treecc79260fdbef823bceb2347362206fc5886747c1 /src/core/render_widget_host_view_qt.cpp
parent1e0c8bbe39eab2b1c4646304c5090c593ffba867 (diff)
Fix fling gestures
InputHandlerProxy::HandleGestureFling assumes that the timestamp on the fling gesture is in the same system as base::TimeTicks. By giving it our smaller relative event timestamps (most often taken from a QElapsedTimer) this ends up here being calculated as a negative time on the fling animation curve. Fix the issue by applying a delta at the ui::TouchEvent conversion so that the resulting GestureFlingStart has a timestamp that can be reliably interpreted. Change-Id: I5e149bf64887305119643359495f89be6e0c3ffb 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.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 44dce6308..18eabd5c0 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -954,12 +954,21 @@ void RenderWidgetHostViewQt::handleWheelEvent(QWheelEvent *ev)
void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev)
{
+ // Chromium expects the touch event timestamps to be comparable to base::TimeTicks::Now().
+ // Most importantly we also have to preserve the relative time distance between events.
+ // Calculate a delta between event timestamps and Now() on the first received event, and
+ // apply this delta to all successive events. This delta is most likely smaller than it
+ // should by calculating it here but this will hopefully cause less than one frame of delay.
+ base::TimeDelta eventTimestamp = base::TimeDelta::FromMilliseconds(ev->timestamp());
+ if (m_eventsToNowDelta == base::TimeDelta())
+ m_eventsToNowDelta = base::TimeTicks::Now() - base::TimeTicks() - eventTimestamp;
+ eventTimestamp += m_eventsToNowDelta;
+
// Convert each of our QTouchEvent::TouchPoint to the simpler ui::TouchEvent to
// be able to use the same code path for both gesture recognition and WebTouchEvents.
// It's a waste to do a double QTouchEvent -> ui::TouchEvent -> blink::WebTouchEvent
// conversion but this should hopefully avoid a few bugs in the future.
// FIXME: Carry Qt::TouchCancel from the event to each TouchPoint.
- base::TimeDelta timestamp = base::TimeDelta::FromMilliseconds(ev->timestamp());
Q_FOREACH (const QTouchEvent::TouchPoint& touchPoint, ev->touchPoints()) {
// Stationary touch points are already in our accumulator.
if (touchPoint.state() == Qt::TouchPointStationary)
@@ -970,7 +979,7 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev)
toGfxPoint((touchPoint.pos() / dpiScale()).toPoint()),
0, // flags
GetMappedTouch(touchPoint.id()),
- timestamp,
+ eventTimestamp,
0, 0, // radius
0, // angle
touchPoint.pressure());