From ca9042c7f08f8f0dc214b9cc19f3243728ec8c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Date: Wed, 4 Aug 2021 17:51:26 +0200 Subject: Get scroll source in the event handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Where libinput supports high-resolution scroll events, the scroll source is encoded in the event type. Get the scroll source in xf86libinput_handle_event to facilitate the migration. Refactor, no functional changes. Signed-off-by: José Expósito --- src/xf86libinput.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/xf86libinput.c b/src/xf86libinput.c index adbc724..a8b7013 100644 --- a/src/xf86libinput.c +++ b/src/xf86libinput.c @@ -1631,15 +1631,14 @@ static inline bool calculate_axis_value(struct xf86libinput *driver_data, enum libinput_pointer_axis axis, struct libinput_event_pointer *event, + enum libinput_pointer_axis_source source, double *value_out) { - enum libinput_pointer_axis_source source; double value; if (!libinput_event_pointer_has_axis(event, axis)) return false; - source = libinput_event_pointer_get_axis_source(event); if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL) { value = get_wheel_scroll_value(driver_data, event, axis); } else { @@ -1665,7 +1664,9 @@ calculate_axis_value(struct xf86libinput *driver_data, } static void -xf86libinput_handle_axis(InputInfoPtr pInfo, struct libinput_event_pointer *event) +xf86libinput_handle_axis(InputInfoPtr pInfo, + struct libinput_event_pointer *event, + enum libinput_pointer_axis_source source) { DeviceIntPtr dev = pInfo->dev; struct xf86libinput *driver_data = pInfo->private; @@ -1678,7 +1679,6 @@ xf86libinput_handle_axis(InputInfoPtr pInfo, struct libinput_event_pointer *even valuator_mask_zero(mask); - source = libinput_event_pointer_get_axis_source(event); switch(source) { case LIBINPUT_POINTER_AXIS_SOURCE_FINGER: case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL: @@ -1691,6 +1691,7 @@ xf86libinput_handle_axis(InputInfoPtr pInfo, struct libinput_event_pointer *even if (calculate_axis_value(driver_data, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, event, + source, &value)) valuator_mask_set_double(mask, 3, value); @@ -1700,6 +1701,7 @@ xf86libinput_handle_axis(InputInfoPtr pInfo, struct libinput_event_pointer *even if (calculate_axis_value(driver_data, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, event, + source, &value)) valuator_mask_set_double(mask, 2, value); @@ -2381,7 +2383,8 @@ xf86libinput_handle_event(struct libinput_event *event) break; case LIBINPUT_EVENT_POINTER_AXIS: xf86libinput_handle_axis(pInfo, - libinput_event_get_pointer_event(event)); + libinput_event_get_pointer_event(event), + libinput_event_pointer_get_axis_source(event)); break; case LIBINPUT_EVENT_TOUCH_FRAME: break; -- cgit v1.2.1