From 8eda96bc8ae68387807e079cd557c98c4a452c4f Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Mon, 29 Oct 2018 12:42:11 +0100
Subject: [PATCH] Fix smooth-scrolling of mouse wheels

Turns out has_precise_scrolling_deltas, doesn't mean what its name says,
but instead is a macOS'ism indicating a system scroll gesture.

Fixes: QTBUG-71378
Change-Id: I124ba8f64495671e8a8ad7a9c397fb506d7fedf9
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
---
 src/core/web_event_factory.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index 04d4930ec..5e784a4e2 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -1449,7 +1449,11 @@ blink::WebMouseWheelEvent WebEventFactory::toWebWheelEvent(QWheelEvent *ev, doub
     webEvent.wheel_ticks_x = static_cast<float>(ev->angleDelta().x()) / QWheelEvent::DefaultDeltasPerStep;
     webEvent.wheel_ticks_y = static_cast<float>(ev->angleDelta().y()) / QWheelEvent::DefaultDeltasPerStep;
     webEvent.phase = toBlinkPhase(ev);
-    webEvent.has_precise_scrolling_deltas = true;
+#if defined(Q_OS_DARWIN)
+    // has_precise_scrolling_deltas is a macOS term meaning it is a system scroll gesture, see qnsview_mouse.mm
+    webEvent.has_precise_scrolling_deltas = (ev->source() == Qt::MouseEventSynthesizedBySystem);
+#endif
+
     setBlinkWheelEventDelta(webEvent);
 
     return webEvent;
@@ -1463,6 +1467,10 @@ bool WebEventFactory::coalesceWebWheelEvent(blink::WebMouseWheelEvent &webEvent,
         return false;
     if (toBlinkPhase(ev) != webEvent.phase)
         return false;
+#if defined(Q_OS_DARWIN)
+    if (webEvent.has_precise_scrolling_deltas != (ev->source() == Qt::MouseEventSynthesizedBySystem))
+        return false;
+#endif
 
     webEvent.SetTimeStamp(currentTimeForEvent(ev));
     webEvent.SetPositionInWidget(ev->x() / dpiScale, ev->y() / dpiScale);
-- 
GitLab