Skip to content

Commit

Permalink
fix: use new wayland enums
Browse files Browse the repository at this point in the history
Introduce new WLR_HAVE_WL_POINTER_AXIS_SOURCE switch to keep
compatibility with wlroots < 0.18.0
  • Loading branch information
gfgit committed Mar 5, 2024
1 parent bb14e07 commit 2824a55
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions como/base/config-como.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
16 changes: 16 additions & 0 deletions como/input/backend/wlroots/pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand All @@ -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;
}
Expand Down

0 comments on commit 2824a55

Please sign in to comment.