Skip to content

Commit 99639f1

Browse files
committed
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.
1 parent 5ba3d10 commit 99639f1

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

glfw/x11_window.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,9 +1447,16 @@ handle_xi_motion_event(_GLFWwindow *window, XIDeviceEvent *de) {
14471447
*off = delta;
14481448
if (!d->is_highres) {
14491449
if (v->increment == 120.) type = GLFW_SCROLL_OFFEST_V120;
1450-
else if (fabs(delta) >= fabs(v->increment)) {
1451-
type = GLFW_SCROLL_OFFSET_LINES;
1452-
if (v->increment != 0) *off /= v->increment;
1450+
else {
1451+
// XInput2 has no reliable way to distinguish high res scroll devices so we
1452+
// assume that if fractional values are seen it must be high res. Sigh, Linux, the
1453+
// land of truly wondrous wonders. See https://github.com/kovidgoyal/kitty/issues/9649
1454+
double int_part; bool delta_is_fractional = modf(delta, &int_part) != 0.;
1455+
if (delta_is_fractional) d->is_highres = true;
1456+
else {
1457+
type = GLFW_SCROLL_OFFSET_LINES;
1458+
if (v->increment != 0) *off /= v->increment;
1459+
}
14531460
}
14541461
}
14551462
}

0 commit comments

Comments
 (0)