mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 08:26:56 +00:00
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:
parent
f976bea4cc
commit
9721346387
3 changed files with 15 additions and 4 deletions
|
|
@ -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
1
glfw/x11_platform.h
vendored
|
|
@ -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
16
glfw/x11_window.c
vendored
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue