summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-06-23 10:03:51 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-06-23 12:15:11 +0000
commit99d3c34167e2ba8c0c505554cdcd4fca20d5223e (patch)
treee9c6a329abcffff74b9fed95ff66a3f252896b9c
parentf77a9e1bcf87642a443a15688ba65856b0b38c56 (diff)
downloadqtwebengine-99d3c34167e2ba8c0c505554cdcd4fca20d5223e.tar.gz
Use angleDelta instead of deprecated Qt4 delta
Switch to using the Qt5 angleDelta instead of the Qt4 style delta that can only handle single orientation wheel events. Change-Id: I181dda03c7fc9c676100cb31ab7717f9641b625e Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--src/core/web_event_factory.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index da230479a..80f81e954 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -656,14 +656,11 @@ blink::WebMouseWheelEvent WebEventFactory::toWebWheelEvent(QWheelEvent *ev, doub
webEvent.modifiers = modifiersForEvent(ev);
webEvent.timeStampSeconds = currentTimeForEvent(ev);
- if (ev->orientation() == Qt::Horizontal)
- webEvent.wheelTicksX = ev->delta() / 120.0f;
- else
- webEvent.wheelTicksY = ev->delta() / 120.0f;
+ webEvent.wheelTicksX = ev->angleDelta().x() / QWheelEvent::DefaultDeltasPerStep;
+ webEvent.wheelTicksY = ev->angleDelta().y() / QWheelEvent::DefaultDeltasPerStep;
-
- // Since we report the scroll by the pixel, convert the delta to pixel distance using standard scroll step.
- // Use the same single scroll step as QTextEdit (in QTextEditPrivate::init [h,v]bar->setSingleStep)
+ // We can't use the device specific QWheelEvent::pixelDelta(), so we calculate
+ // a pixel delta based on ticks and scroll per line.
static const float cDefaultQtScrollStep = 20.f;
webEvent.deltaX = webEvent.wheelTicksX * wheelScrollLines * cDefaultQtScrollStep;