From e886bd7c78b036a04ef6acba8cf641eed4a52e78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 20 Mar 2015 12:42:57 +0100 Subject: [PATCH] Adjust to newer libinput and require at least 0.10 There was API changes regarding axis event handling. CCBUG: 342893 --- CMakeLists.txt | 4 ++-- libinput/connection.cpp | 5 ++++- libinput/events.cpp | 22 +++++++++++++--------- libinput/events.h | 4 ++-- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5e2cf0045..ac0f92e988 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,7 +137,7 @@ set_package_properties(XKB PROPERTIES PURPOSE "Required for building KWin with Wayland support" ) -find_package(Libinput 0.5) +find_package(Libinput 0.10) set_package_properties(Libinput PROPERTIES TYPE OPTIONAL PURPOSE "Required for input handling on Wayland.") find_package(UDev) @@ -147,7 +147,7 @@ set_package_properties(UDev PROPERTIES URL "http://www.freedesktop.org/software PURPOSE "Required for input handling on Wayland." ) set(HAVE_INPUT FALSE) -if (Libinput_FOUND AND UDEV_FOUND AND Libinput_VERSION VERSION_LESS 0.8) +if (Libinput_FOUND AND UDEV_FOUND) set(HAVE_INPUT TRUE) endif() diff --git a/libinput/connection.cpp b/libinput/connection.cpp index d948c1c5a3..ee897a3bb8 100644 --- a/libinput/connection.cpp +++ b/libinput/connection.cpp @@ -115,7 +115,10 @@ void Connection::handleEvent() } case LIBINPUT_EVENT_POINTER_AXIS: { PointerEvent *pe = static_cast(event.data()); - emit pointerAxisChanged(pe->axis(), pe->axisValue(), pe->time()); + const auto axis = pe->axis(); + for (auto it = axis.begin(); it != axis.end(); ++it) { + emit pointerAxisChanged(*it, pe->axisValue(*it), pe->time()); + } break; } case LIBINPUT_EVENT_POINTER_BUTTON: { diff --git a/libinput/events.cpp b/libinput/events.cpp index 02db1937a6..7fd8d8fcd9 100644 --- a/libinput/events.cpp +++ b/libinput/events.cpp @@ -143,22 +143,26 @@ InputRedirection::PointerButtonState PointerEvent::buttonState() const abort(); } -InputRedirection::PointerAxis PointerEvent::axis() const +QVector PointerEvent::axis() const { Q_ASSERT(type() == LIBINPUT_EVENT_POINTER_AXIS); - switch (libinput_event_pointer_get_axis(m_pointerEvent)) { - case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL: - return InputRedirection::PointerAxisHorizontal; - case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL: - return InputRedirection::PointerAxisVertical; + QVector a; + if (libinput_event_pointer_has_axis(m_pointerEvent, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) { + a << InputRedirection::PointerAxisHorizontal; } - abort(); + if (libinput_event_pointer_has_axis(m_pointerEvent, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) { + a << InputRedirection::PointerAxisVertical; + } + return a; } -qreal PointerEvent::axisValue() const +qreal PointerEvent::axisValue(InputRedirection::PointerAxis axis) const { Q_ASSERT(type() == LIBINPUT_EVENT_POINTER_AXIS); - return libinput_event_pointer_get_axis_value(m_pointerEvent); + const libinput_pointer_axis a = axis == InputRedirection::PointerAxisHorizontal + ? LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL + : LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL; + return libinput_event_pointer_get_axis_value(m_pointerEvent, a); } } diff --git a/libinput/events.h b/libinput/events.h index 60335069f9..63adef4223 100644 --- a/libinput/events.h +++ b/libinput/events.h @@ -87,8 +87,8 @@ public: uint32_t button() const; InputRedirection::PointerButtonState buttonState() const; uint32_t time() const; - InputRedirection::PointerAxis axis() const; - qreal axisValue() const; + QVector axis() const; + qreal axisValue(InputRedirection::PointerAxis a) const; operator libinput_event_pointer*() { return m_pointerEvent;