XWayland: Fix a regression where some wheel mice were not scrolling properly

We assume increment == 1 and delta * 120 == integer means we have
V120 events in units of 1/120.

Fixes #9770
This commit is contained in:
Kovid Goyal 2026-03-29 14:43:48 +05:30
parent f976bea4cc
commit 9721346387
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 15 additions and 4 deletions

View file

@ -187,6 +187,8 @@ Detailed list of changes
- X11: Fix a regression in the previous release that caused an occasional crash on input device removal (:iss:`9723`)
- XWayland: Fix a regression where some wheel mice were not scrolling properly (:pull:`9770`)
- Command palette: Improve searching to use word level matching (:pull:`9727`)
- hints kitten: A new option to set the background color of matched text (:pull:`9745`)

1
glfw/x11_platform.h vendored
View file

@ -247,6 +247,7 @@ typedef struct XIScrollDevice {
char name[32];
unsigned num_events;
GLFWOffsetType offset_type;
bool v120_offset_needs_scaling;
} XIScrollDevice;
typedef struct XdndSelectionRequest {

16
glfw/x11_window.c vendored
View file

@ -1466,15 +1466,17 @@ handle_xi_motion_event(_GLFWwindow *window, XIDeviceEvent *de) {
*off = delta;
d->num_events++;
if (!d->type_detected) {
debug_input("Detecting scroll device type: delta: %.3f delta*120: %.3f v->increment: %.3f\n", delta, delta * 120, v->increment);
if (v->increment == 120.) {
d->type_detected = true;
d->offset_type = GLFW_SCROLL_OFFEST_V120;
d->v120_offset_needs_scaling = false;
} else {
bool delta_is_fractional = number_has_fractional_part(delta);
if (delta_is_fractional) {
if (number_has_fractional_part(delta)) {
if (fabs(delta * 120 - round(delta * 120)) < 0.01) {
d->type_detected = d->num_events > 2;
d->offset_type = GLFW_SCROLL_OFFEST_V120;
d->v120_offset_needs_scaling = v->increment == 1.;
} else {
d->type_detected = true;
d->offset_type = GLFW_SCROLL_OFFEST_HIGHRES;
@ -1485,8 +1487,14 @@ handle_xi_motion_event(_GLFWwindow *window, XIDeviceEvent *de) {
}
}
}
if (d->offset_type == GLFW_SCROLL_OFFSET_LINES) {
if (v->increment != 0) *off /= v->increment;
if (v->increment != 0) {
if (d->offset_type == GLFW_SCROLL_OFFSET_LINES) {
*off /= v->increment;
} else if (d->offset_type == GLFW_SCROLL_OFFEST_V120 && d->v120_offset_needs_scaling) {
// On XWayland, scroll deltas are in scroll-increment units (typically
// where increment=1.0 means one line or one v120).
*off *= 120.;
}
}
}
type = d->offset_type;