From 4be54381db0dab676f7a546c1afcf67f9af053a0 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 6 Mar 2024 16:42:10 +0100 Subject: [PATCH 1/2] style: rename CMake define The define is not only about the axis source, but also some other enums having been renamed in [1] on wlroots master. [1] https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4575 --- CMakeLists.txt | 2 +- como/base/config-como.h.cmake | 2 +- como/input/backend/wlroots/pointer.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 630c341b6..5bc574ad4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -219,7 +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) + set(WLR_HAVE_WL_POINTER_ENUMS 1) endif() find_package(X11) diff --git a/como/base/config-como.h.cmake b/como/base/config-como.h.cmake index d7f1a3877..908b7fc8a 100644 --- a/como/base/config-como.h.cmake +++ b/como/base/config-como.h.cmake @@ -20,7 +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 +#cmakedefine01 WLR_HAVE_WL_POINTER_ENUMS #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 62c2cb0c2..8e774f370 100644 --- a/como/input/backend/wlroots/pointer.h +++ b/como/input/backend/wlroots/pointer.h @@ -85,7 +85,7 @@ void handle_button(struct wl_listener* listener, void* data) auto event = button_event { wlr_event->button, -#if WLR_HAVE_WL_POINTER_AXIS_SOURCE +#if WLR_HAVE_WL_POINTER_ENUMS wlr_event->state == WL_POINTER_BUTTON_STATE_RELEASED ? button_state::released : button_state::pressed, #else @@ -111,7 +111,7 @@ 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 +#if WLR_HAVE_WL_POINTER_ENUMS case WL_POINTER_AXIS_SOURCE_WHEEL: return axis_source::wheel; case WL_POINTER_AXIS_SOURCE_FINGER: From d3bfc6694b1438e62f442898053fbad76b08f826 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 6 Mar 2024 16:39:39 +0100 Subject: [PATCH 2/2] fix: adapt to wlroots pointer enum name change In tests we also have some of these names that are changed on wlroots master. --- tests/integration/lib/helpers.cpp | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/integration/lib/helpers.cpp b/tests/integration/lib/helpers.cpp index ef9ee7f16..2e11533f9 100644 --- a/tests/integration/lib/helpers.cpp +++ b/tests/integration/lib/helpers.cpp @@ -479,7 +479,11 @@ void pointer_motion_absolute(QPointF const& position, uint32_t time) wlr_signal_emit_safe(&test_app->pointer->events.frame, test_app->pointer); } +#if WLR_HAVE_WL_POINTER_ENUMS +void pointer_button_impl(uint32_t button, uint32_t time, wl_pointer_button_state state) +#else void pointer_button_impl(uint32_t button, uint32_t time, wlr_button_state state) +#endif { auto test_app = app(); @@ -498,19 +502,35 @@ void pointer_button_impl(uint32_t button, uint32_t time, wlr_button_state state) void pointer_button_pressed(uint32_t button, uint32_t time) { +#if WLR_HAVE_WL_POINTER_ENUMS + pointer_button_impl(button, time, WL_POINTER_BUTTON_STATE_PRESSED); +#else pointer_button_impl(button, time, WLR_BUTTON_PRESSED); +#endif } void pointer_button_released(uint32_t button, uint32_t time) { +#if WLR_HAVE_WL_POINTER_ENUMS + pointer_button_impl(button, time, WL_POINTER_BUTTON_STATE_RELEASED); +#else pointer_button_impl(button, time, WLR_BUTTON_RELEASED); +#endif } +#if WLR_HAVE_WL_POINTER_ENUMS +void pointer_axis_impl(double delta, + uint32_t time, + int32_t discrete_delta, + wl_pointer_axis orientation, + wl_pointer_axis_source source) +#else void pointer_axis_impl(double delta, uint32_t time, int32_t discrete_delta, wlr_axis_orientation orientation, wlr_axis_source source) +#endif { auto test_app = app(); @@ -531,14 +551,27 @@ void pointer_axis_impl(double delta, void pointer_axis_horizontal(double delta, uint32_t time, int32_t discrete_delta) { +#if WLR_HAVE_WL_POINTER_ENUMS + pointer_axis_impl(delta, + time, + discrete_delta, + WL_POINTER_AXIS_HORIZONTAL_SCROLL, + WL_POINTER_AXIS_SOURCE_WHEEL); +#else pointer_axis_impl( delta, time, discrete_delta, WLR_AXIS_ORIENTATION_HORIZONTAL, WLR_AXIS_SOURCE_WHEEL); +#endif } void pointer_axis_vertical(double delta, uint32_t time, int32_t discrete_delta) { +#if WLR_HAVE_WL_POINTER_ENUMS + pointer_axis_impl( + delta, time, discrete_delta, WL_POINTER_AXIS_VERTICAL_SCROLL, WL_POINTER_AXIS_SOURCE_WHEEL); +#else pointer_axis_impl( delta, time, discrete_delta, WLR_AXIS_ORIENTATION_VERTICAL, WLR_AXIS_SOURCE_WHEEL); +#endif } void keyboard_key_impl(uint32_t key,