summaryrefslogtreecommitdiffstats
path: root/src/core/render_widget_host_view_qt.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-10-24 16:30:31 +0200
committerLiang Qi <liang.qi@qt.io>2017-10-27 06:52:08 +0000
commit4267567f5366b237c763d1b93cd09501a483a070 (patch)
tree06ac8607b5bcfabf94d7270209596b7120563110 /src/core/render_widget_host_view_qt.cpp
parent684cfe05641ba9f3abc7e128d9dab5b331ef0689 (diff)
Coalesce wheel events when possible
Combine wheel events if we are getting more than Chromium can handle. This improves latency and perceived performance when scrolling with touchpads or fine-grained mouse, on a slow machine or with a debug build. Change-Id: Id847c8e7782e155c28067b6051ce92896b68ca7a Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'src/core/render_widget_host_view_qt.cpp')
-rw-r--r--src/core/render_widget_host_view_qt.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index d1fc7d171..a45383946 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -282,6 +282,7 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget
, m_cursorPositionWithinSelection(-1)
, m_cursorPosition(0)
, m_emptyPreviousSelection(true)
+ , m_wheelAckPending(false)
{
m_host->SetView(this);
#ifndef QT_NO_ACCESSIBILITY
@@ -1350,7 +1351,28 @@ void RenderWidgetHostViewQt::accessibilityActiveChanged(bool active)
void RenderWidgetHostViewQt::handleWheelEvent(QWheelEvent *ev)
{
- m_host->ForwardWheelEvent(WebEventFactory::toWebWheelEvent(ev, dpiScale()));
+ if (!m_wheelAckPending) {
+ Q_ASSERT(m_pendingWheelEvents.isEmpty());
+ m_wheelAckPending = true;
+ m_host->ForwardWheelEvent(WebEventFactory::toWebWheelEvent(ev, dpiScale()));
+ return;
+ }
+ if (!m_pendingWheelEvents.isEmpty()) {
+ // Try to combine with this wheel event with the last pending one.
+ if (WebEventFactory::coalesceWebWheelEvent(m_pendingWheelEvents.last(), ev, dpiScale()))
+ return;
+ }
+ m_pendingWheelEvents.append(WebEventFactory::toWebWheelEvent(ev, dpiScale()));
+}
+
+void RenderWidgetHostViewQt::WheelEventAck(const blink::WebMouseWheelEvent &/*event*/, content::InputEventAckState /*ack_result*/)
+{
+ m_wheelAckPending = false;
+ if (!m_pendingWheelEvents.isEmpty()) {
+ m_wheelAckPending = true;
+ m_host->ForwardWheelEvent(m_pendingWheelEvents.takeFirst());
+ }
+ // TODO: We could forward unhandled wheelevents to our parent.
}
void RenderWidgetHostViewQt::clearPreviousTouchMotionState()