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>bb10
parent
90d5959dc4
commit
b0da063d8c
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue