From 40dc5121aa4cc76ed9a6ededd6ff56570c1a2e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Date: Sun, 27 Mar 2022 19:04:45 +0200 Subject: [PATCH] seat: support high-resolution clients Upgrade the seat protocol to version 8 and handle clients that support high-resolution scroll wheel events. Since the backend already sends discrete values in the 120 range, forwarding them is enough. --- types/seat/wlr_seat.c | 2 +- types/seat/wlr_seat_pointer.c | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/types/seat/wlr_seat.c b/types/seat/wlr_seat.c index 5280bc465..d7652c124 100644 --- a/types/seat/wlr_seat.c +++ b/types/seat/wlr_seat.c @@ -13,7 +13,7 @@ #include "util/global.h" #include "util/signal.h" -#define SEAT_VERSION 7 +#define SEAT_VERSION 8 static void seat_handle_get_pointer(struct wl_client *client, struct wl_resource *seat_resource, uint32_t id) { diff --git a/types/seat/wlr_seat_pointer.c b/types/seat/wlr_seat_pointer.c index d4ec38441..1ddc1467c 100644 --- a/types/seat/wlr_seat_pointer.c +++ b/types/seat/wlr_seat_pointer.c @@ -269,6 +269,14 @@ uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time, return serial; } +static void send_axis_value120(struct wl_resource *resource, uint32_t time, + enum wlr_axis_orientation orientation, double value, + int32_t value_discrete) { + wl_pointer_send_axis_value120(resource, orientation, value_discrete); + wl_pointer_send_axis(resource, time, orientation, + wl_fixed_from_double(value)); +} + void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time, enum wlr_axis_orientation orientation, double value, int32_t value_discrete, enum wlr_axis_source source) { @@ -298,14 +306,18 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time, wl_pointer_send_axis_source(resource, source); } if (value) { - if (value_discrete && - version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION) { - wl_pointer_send_axis_discrete(resource, orientation, + if (value_discrete) { + if (version >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION) { + send_axis_value120(resource, time, orientation, value, + value_discrete); + } else if (version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION) { + wl_pointer_send_axis_discrete(resource, orientation, value_discrete / WLR_POINTER_AXIS_DISCRETE_STEP); + } + } else { + wl_pointer_send_axis(resource, time, orientation, + wl_fixed_from_double(value)); } - - wl_pointer_send_axis(resource, time, orientation, - wl_fixed_from_double(value)); } else if (version >= WL_POINTER_AXIS_STOP_SINCE_VERSION) { wl_pointer_send_axis_stop(resource, time, orientation); }