Merge branch 'fix-x11-scroll-crossing-storm' of https://github.com/liguangsheng/kitty

This commit is contained in:
Kovid Goyal 2026-08-16 06:11:35 +05:30
commit e2252170cc
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 13 additions and 4 deletions

2
glfw/x11_platform.h vendored
View file

@ -246,7 +246,7 @@ typedef struct AtomArray {
typedef struct XIScrollValuator {
double increment, value, min, max;
int number, resolution, mode;
bool is_vertical, initialized;
bool is_vertical, initialized, has_value;
} XIScrollValuator;
typedef struct XIScrollDevice {

15
glfw/x11_window.c vendored
View file

@ -1308,11 +1308,20 @@ handle_xi_motion_event(_GLFWwindow *window, XIDeviceEvent *de) {
scroll_valuator_found = true;
if (!v->initialized) {
v->initialized = true;
v->value = value;
continue;
if (!v->has_value) {
v->has_value = true;
v->value = value;
continue;
}
const double max_plausible_delta = 10. * (v->increment != 0. ? fabs(v->increment) : 1.);
if (fabs(value - v->value) > max_plausible_delta) {
v->value = value;
continue;
}
}
double delta = value - v->value;
v->value = value;
v->has_value = true;
delta *= -1;
double *off = v->is_vertical ? &yOffset : &xOffset;
*off = delta;
@ -2018,7 +2027,7 @@ processEvent(XEvent *event) {
}
case LeaveNotify: {
resetScrollValuators();
if (event->xcrossing.mode == NotifyNormal && event->xcrossing.detail != NotifyInferior) resetScrollValuators();
_glfwInputCursorEnter(window, false);
return;
}