From b0da063d8c386d33399cbb8da8cb51c662befab2 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Thu, 31 Aug 2017 11:24:59 +0200 Subject: 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 --- .../input/libinput/qlibinputpointer.cpp | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/platformsupport') 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) -- cgit v1.2.3