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 authored and romangg committed Mar 5, 2024
1 parent e989441 commit 17eb47b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 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
30 changes: 24 additions & 6 deletions como/input/backend/wlroots/pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,20 @@ void handle_button(struct wl_listener* listener, void* data)
auto pointer = event_receiver_struct->receiver;
auto wlr_event = reinterpret_cast<wlr_pointer_button_event*>(data);

auto event = button_event{
auto event = button_event
{
wlr_event->button,
wlr_event->state == WLR_BUTTON_RELEASED ? button_state::released : button_state::pressed,
{
pointer,
wlr_event->time_msec,
},
#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,
},
};

Q_EMIT pointer->button_changed(event);
Expand All @@ -104,6 +111,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 +129,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 17eb47b

Please sign in to comment.