From aea16ba5d2896ef22bf0bea45e5e8142c0ff1c2a Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 15 Jun 2024 10:17:01 +0200 Subject: input: implement wl_pointer::axis_value120() This implements high resolution mouse wheel scroll events. A "normal" scroll step corresponds to the value 120. Anything less than that is a partial scroll step. This event replaces axis_discrete(), when we bind wl_seat v8 (which we now do, when available). We calculate the number of degrees that is required to scroll a single line, based off of the scrollback.multiplier value. Each high-res event accumulates, until we have at least the number of degress required to scroll one, or more lines. The remaining degrees are kept, and added to in the next scroll event. Closes #1738 --- wayland.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'wayland.c') diff --git a/wayland.c b/wayland.c index d65a404e..c357f382 100644 --- a/wayland.c +++ b/wayland.c @@ -1161,6 +1161,12 @@ handle_global(void *data, struct wl_registry *registry, if (!verify_iface_version(interface, version, required)) return; +#if defined(WL_POINTER_AXIS_VALUE120_SINCE_VERSION) + const uint32_t preferred = WL_POINTER_AXIS_VALUE120_SINCE_VERSION; +#else + const uint32_t preferred = required; +#endif + int repeat_fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK); if (repeat_fd == -1) { LOG_ERRNO("failed to create keyboard repeat timer FD"); @@ -1168,7 +1174,7 @@ handle_global(void *data, struct wl_registry *registry, } struct wl_seat *wl_seat = wl_registry_bind( - wayl->registry, name, &wl_seat_interface, required); + wayl->registry, name, &wl_seat_interface, min(version, preferred)); tll_push_back(wayl->seats, ((struct seat){ .wayl = wayl, -- cgit v1.3