From 2824a55f94f20e131f2d64ac0cbf6de9cd6583d0 Mon Sep 17 00:00:00 2001 From: Filippo Gentile Date: Tue, 5 Mar 2024 13:13:12 +0100 Subject: [PATCH] fix: use new wayland enums Introduce new WLR_HAVE_WL_POINTER_AXIS_SOURCE switch to keep compatibility with wlroots < 0.18.0 --- CMakeLists.txt | 1 + como/base/config-como.h.cmake | 1 + como/input/backend/wlroots/pointer.h | 16 ++++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 681cc18d4..630c341b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -219,6 +219,7 @@ if (${wlroots_VERSION} VERSION_GREATER_EQUAL 0.18) set(WLR_HAVE_UTIL_TRANSFORM_HEADER 1) set(WLR_HAVE_NEW_PIXEL_COPY_API 1) set(WLR_HAVE_BACKEND_CREATE_WITH_LOOP 1) + set(WLR_HAVE_WL_POINTER_AXIS_SOURCE 1) endif() find_package(X11) diff --git a/como/base/config-como.h.cmake b/como/base/config-como.h.cmake index 0366fc4c8..d7f1a3877 100644 --- a/como/base/config-como.h.cmake +++ b/como/base/config-como.h.cmake @@ -20,6 +20,7 @@ #cmakedefine01 WLR_HAVE_UTIL_TRANSFORM_HEADER #cmakedefine01 WLR_HAVE_NEW_PIXEL_COPY_API #cmakedefine01 WLR_HAVE_BACKEND_CREATE_WITH_LOOP +#cmakedefine01 WLR_HAVE_WL_POINTER_AXIS_SOURCE #if HAVE_BREEZE_DECO #define BREEZE_KDECORATION_PLUGIN_ID "${BREEZE_KDECORATION_PLUGIN_ID}" diff --git a/como/input/backend/wlroots/pointer.h b/como/input/backend/wlroots/pointer.h index 36641a64a..dfc6ae35d 100644 --- a/como/input/backend/wlroots/pointer.h +++ b/como/input/backend/wlroots/pointer.h @@ -84,7 +84,12 @@ void handle_button(struct wl_listener* listener, void* data) auto event = button_event{ wlr_event->button, +#if WLR_HAVE_WL_POINTER_AXIS_SOURCE + wlr_event->state == WL_POINTER_BUTTON_STATE_RELEASED ? button_state::released + : button_state::pressed, +#else wlr_event->state == WLR_BUTTON_RELEASED ? button_state::released : button_state::pressed, +#endif { pointer, wlr_event->time_msec, @@ -104,6 +109,16 @@ void handle_axis(struct wl_listener* listener, void* data) auto get_source = [](auto wlr_source) { switch (wlr_source) { +#if WLR_HAVE_WL_POINTER_AXIS_SOURCE + case WL_POINTER_AXIS_SOURCE_WHEEL: + return axis_source::wheel; + case WL_POINTER_AXIS_SOURCE_FINGER: + return axis_source::finger; + case WL_POINTER_AXIS_SOURCE_CONTINUOUS: + return axis_source::continuous; + case WL_POINTER_AXIS_SOURCE_WHEEL_TILT: + return axis_source::wheel_tilt; +#else case WLR_AXIS_SOURCE_WHEEL: return axis_source::wheel; case WLR_AXIS_SOURCE_FINGER: @@ -112,6 +127,7 @@ void handle_axis(struct wl_listener* listener, void* data) return axis_source::continuous; case WLR_AXIS_SOURCE_WHEEL_TILT: return axis_source::wheel_tilt; +#endif default: return axis_source::unknown; }