summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2017-08-31 11:24:59 +0200
committerGatis Paeglis <gatis.paeglis@qt.io>2017-09-05 14:16:48 +0000
commitb0da063d8c386d33399cbb8da8cb51c662befab2 (patch)
treee564b9062ee5d64b49ad1d3eeeb0916b73eee8d4 /src/platformsupport
parent90d5959dc49daea54cfe2e2b220a1225943e9642 (diff)
libinput: make scrolling consistent with other platforms
Default scroll increment on other platforms (e.g. XCB, Windows) is 120. With libinput it was 15 * 120 = 1800, which results in non-smooth scolling experience. This patch also replaces deprecated versions of QWindowSystemInterface::handleWheelEvent(). Change-Id: I363f13a2922fd871a93dbd1bd611778fa18f6122 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/input/libinput/qlibinputpointer.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/platformsupport/input/libinput/qlibinputpointer.cpp b/src/platformsupport/input/libinput/qlibinputpointer.cpp
index bdeac8db7e..6879d0cd83 100644
--- a/src/platformsupport/input/libinput/qlibinputpointer.cpp
+++ b/src/platformsupport/input/libinput/qlibinputpointer.cpp
@@ -96,21 +96,28 @@ void QLibInputPointer::processMotion(libinput_event_pointer *e)
void QLibInputPointer::processAxis(libinput_event_pointer *e)
{
+ double value; // default axis value is 15 degrees per wheel click
+ QPoint angleDelta;
#if !QT_CONFIG(libinput_axis_api)
- const double v = libinput_event_pointer_get_axis_value(e) * 120;
- const Qt::Orientation ori = libinput_event_pointer_get_axis(e) == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL
- ? Qt::Vertical : Qt::Horizontal;
- QWindowSystemInterface::handleWheelEvent(Q_NULLPTR, m_pos, m_pos, qRound(-v), ori, QGuiApplication::keyboardModifiers());
+ value = libinput_event_pointer_get_axis_value(e);
+ if (libinput_event_pointer_get_axis(e) == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)
+ angleDelta.setY(qRound(value));
+ else
+ angleDelta.setX(qRound(value));
#else
if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) {
- const double v = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL) * 120;
- QWindowSystemInterface::handleWheelEvent(Q_NULLPTR, m_pos, m_pos, qRound(-v), Qt::Vertical, QGuiApplication::keyboardModifiers());
+ value = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
+ angleDelta.setY(qRound(value));
}
if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) {
- const double v = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL) * 120;
- QWindowSystemInterface::handleWheelEvent(Q_NULLPTR, m_pos, m_pos, qRound(-v), Qt::Horizontal, QGuiApplication::keyboardModifiers());
+ value = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
+ angleDelta.setX(qRound(value));
}
#endif
+ const int factor = 8;
+ angleDelta *= -factor;
+ Qt::KeyboardModifiers mods = QGuiApplication::keyboardModifiers();
+ QWindowSystemInterface::handleWheelEvent(nullptr, m_pos, m_pos, QPoint(), angleDelta, mods);
}
void QLibInputPointer::setPos(const QPoint &pos)