From 99639f1373ad4d687869896b139ef17b9b3a8bc5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 12 Mar 2026 20:20:41 +0530 Subject: [PATCH] XInput2: Assume any fractional scroll value means the device is high res Because as far as I can tell there is no reliable way to detect high res scroll devices under XWayland. Sigh. --- glfw/x11_window.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/glfw/x11_window.c b/glfw/x11_window.c index 539ced065..f46365a75 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -1447,9 +1447,16 @@ handle_xi_motion_event(_GLFWwindow *window, XIDeviceEvent *de) { *off = delta; if (!d->is_highres) { if (v->increment == 120.) type = GLFW_SCROLL_OFFEST_V120; - else if (fabs(delta) >= fabs(v->increment)) { - type = GLFW_SCROLL_OFFSET_LINES; - if (v->increment != 0) *off /= v->increment; + else { + // XInput2 has no reliable way to distinguish high res scroll devices so we + // assume that if fractional values are seen it must be high res. Sigh, Linux, the + // land of truly wondrous wonders. See https://github.com/kovidgoyal/kitty/issues/9649 + double int_part; bool delta_is_fractional = modf(delta, &int_part) != 0.; + if (delta_is_fractional) d->is_highres = true; + else { + type = GLFW_SCROLL_OFFSET_LINES; + if (v->increment != 0) *off /= v->increment; + } } } }