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.
This commit is contained in:
Kovid Goyal
2026-03-12 20:20:41 +05:30
parent 5ba3d10471
commit 99639f1373

13
glfw/x11_window.c vendored
View File

@@ -1447,9 +1447,16 @@ handle_xi_motion_event(_GLFWwindow *window, XIDeviceEvent *de) {
*off = delta; *off = delta;
if (!d->is_highres) { if (!d->is_highres) {
if (v->increment == 120.) type = GLFW_SCROLL_OFFEST_V120; if (v->increment == 120.) type = GLFW_SCROLL_OFFEST_V120;
else if (fabs(delta) >= fabs(v->increment)) { else {
type = GLFW_SCROLL_OFFSET_LINES; // XInput2 has no reliable way to distinguish high res scroll devices so we
if (v->increment != 0) *off /= v->increment; // 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;
}
} }
} }
} }