High resolution wheel-event support from libinput

Is necessary because the support was added using a new event
and a new getter.

[ChangeLog][QtGui][libinput] Can now use the hires scrolling API
from libinput 1.19, adding this feature to QPAs using libinput directly

Task-number: QTBUG-96227
Change-Id: Ie30281de2f6391389e9e6049bc4117d3a8f63ad1
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2020-02-14 11:36:32 +01:00 committed by Shawn Rutledge
parent e7db28fa9d
commit 53d1e26ff5
3 changed files with 40 additions and 2 deletions

View File

@ -512,6 +512,23 @@ xcb_xkb_get_kbd_by_name_replies_key_names_value_list_sizeof(nullptr, 0, 0, 0, 0,
}
")
# libinput_hires_wheel_support
qt_config_compile_test(libinput_hires_wheel_support
LABEL "libinput hires wheel support"
LIBRARIES
Libinput::Libinput
CODE
"#include <libinput.h>
int main(void)
{
/* BEGIN TEST: */
libinput_event_type type = LIBINPUT_EVENT_POINTER_SCROLL_WHEEL;
libinput_event_pointer_get_scroll_value_v120(nullptr, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
/* END TEST: */
return 0;
}
")
# special case begin
# directwrite (assumes DirectWrite2)
qt_config_compile_test(directwrite
@ -678,6 +695,10 @@ qt_feature("libinput-axis-api" PRIVATE
LABEL "axis API in libinput"
CONDITION QT_FEATURE_libinput AND ON
)
qt_feature("libinput-hires-wheel-support" PRIVATE
LABEL "HiRes wheel support in libinput"
CONDITION QT_FEATURE_libinput AND TEST_libinput_hires_wheel_support
)
qt_feature("lgmon"
LABEL "lgmon"
CONDITION libs.lgmon OR FIXME
@ -1223,6 +1244,7 @@ qt_configure_end_summary_section() # end of "Qt Gui" section
qt_configure_add_summary_section(NAME "Features used by QPA backends")
qt_configure_add_summary_entry(ARGS "evdev")
qt_configure_add_summary_entry(ARGS "libinput")
qt_configure_add_summary_entry(ARGS "libinput_hires_wheel_support")
qt_configure_add_summary_entry(ARGS "integrityhid")
qt_configure_add_summary_entry(ARGS "mtdev")
qt_configure_add_summary_entry(ARGS "tslib")

View File

@ -208,7 +208,11 @@ void QLibInputHandler::processEvent(libinput_event *ev)
case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
m_pointer->processAbsMotion(libinput_event_get_pointer_event(ev));
break;
#if QT_CONFIG(libinput_hires_wheel_support)
case LIBINPUT_EVENT_POINTER_SCROLL_WHEEL:
#else
case LIBINPUT_EVENT_POINTER_AXIS:
#endif
m_pointer->processAxis(libinput_event_get_pointer_event(ev));
break;
case LIBINPUT_EVENT_KEYBOARD_KEY:

View File

@ -133,16 +133,28 @@ void QLibInputPointer::processAxis(libinput_event_pointer *e)
angleDelta.setX(qRound(value));
#else
if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) {
#if QT_CONFIG(libinput_hires_wheel_support)
value = libinput_event_pointer_get_scroll_value_v120(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
#else
value = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
#endif
angleDelta.setY(qRound(value));
}
if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) {
#if QT_CONFIG(libinput_hires_wheel_support)
value = libinput_event_pointer_get_scroll_value_v120(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
#else
value = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
#endif
angleDelta.setX(qRound(value));
}
#endif
const int factor = 8;
angleDelta *= -factor;
#if QT_CONFIG(libinput_hires_wheel_support)
const int factor = -1;
#else
const int factor = -8;
#endif
angleDelta *= factor;
Qt::KeyboardModifiers mods = QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers();
QWindowSystemInterface::handleWheelEvent(nullptr, m_pos, m_pos, QPoint(), angleDelta, mods);
}