From d0b8c111fd8686522d074e858897f216318952e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Date: Mon, 20 Sep 2021 19:45:48 +0200 Subject: [PATCH] pointer: add high-resolution axis event Starting with Linux Kernel v5.0 two new axes are available for mice that support high-resolution wheel scrolling: REL_WHEEL_HI_RES and REL_HWHEEL_HI_RES. Both axes send data in fractions of 120 where each multiple of 120 amounts to one logical scroll event. Fractions of 120 indicate a wheel movement less than one detent. Three new events are now available on libinput: LIBINPUT_EVENT_POINTER_SCROLL_WHEEL, LIBINPUT_EVENT_POINTER_SCROLL_FINGER, and LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS. These events replace the LIBINPUT_EVENT_POINTER_AXIS event, so new clients should simply ignore that event. Also, two new APIs are available to access the high-resolution data: libinput_event_pointer_get_scroll_value() and libinput_event_pointer_get_scroll_value_v120(). Create a new event, wlr_event_pointer_axis_v120, to represent high-resolution axis events and a signal to emit them: wlr_pointer->pointer.axis_value120. --- include/wlr/types/wlr_pointer.h | 10 ++++++++++ types/wlr_pointer.c | 1 + 2 files changed, 11 insertions(+) diff --git a/include/wlr/types/wlr_pointer.h b/include/wlr/types/wlr_pointer.h index 1380fa76c..afb8191c0 100644 --- a/include/wlr/types/wlr_pointer.h +++ b/include/wlr/types/wlr_pointer.h @@ -24,6 +24,7 @@ struct wlr_pointer { struct wl_signal motion_absolute; // struct wlr_event_pointer_motion_absolute struct wl_signal button; // struct wlr_event_pointer_button struct wl_signal axis; // struct wlr_event_pointer_axis + struct wl_signal axis_value120; // struct wlr_event_pointer_axis_value120 struct wl_signal frame; struct wl_signal swipe_begin; // struct wlr_event_pointer_swipe_begin @@ -80,6 +81,15 @@ struct wlr_event_pointer_axis { int32_t delta_discrete; }; +struct wlr_event_pointer_axis_value120 { + struct wlr_input_device *device; + uint32_t time_msec; + enum wlr_axis_source source; + enum wlr_axis_orientation orientation; + double delta; + int32_t delta_value120; +}; + struct wlr_event_pointer_swipe_begin { struct wlr_input_device *device; uint32_t time_msec; diff --git a/types/wlr_pointer.c b/types/wlr_pointer.c index d18fe754d..afcd32841 100644 --- a/types/wlr_pointer.c +++ b/types/wlr_pointer.c @@ -11,6 +11,7 @@ void wlr_pointer_init(struct wlr_pointer *pointer, wl_signal_init(&pointer->events.motion_absolute); wl_signal_init(&pointer->events.button); wl_signal_init(&pointer->events.axis); + wl_signal_init(&pointer->events.axis_value120); wl_signal_init(&pointer->events.frame); wl_signal_init(&pointer->events.swipe_begin); wl_signal_init(&pointer->events.swipe_update);