From 51aa327be16a43f60eacc2df548dd519b05f6505 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 5 Oct 2026 20:41:07 +0530 Subject: [PATCH] Fix momentum scroll scale not being set for negative deltas The scale between scaled and unscaled offsets was only calculated for positive deltas, so when scrolling up or left it stayed at zero (or stale from a previous scroll), causing momentum events to have zero offsets. Closes #10610 --- docs/changelog.rst | 4 ++++ glfw/momentum-scroll.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index fce395184..fa08cbc4e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -269,6 +269,10 @@ Detailed list of changes - Wayland: Fix the window class (app_id) and title being lost when an OS window is hidden and then shown again (:iss:`10602`) +- Linux: Fix momentum scrolling not coasting when scrolling up or left, until + the first scroll down or right (:pull:`10610`) + + 0.49.2 [2026-10-01] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/glfw/momentum-scroll.c b/glfw/momentum-scroll.c index bcbabf09a..5b6a5d25c 100644 --- a/glfw/momentum-scroll.c +++ b/glfw/momentum-scroll.c @@ -221,8 +221,8 @@ handle_scroll_event(_GLFWwindow *w, const GLFWScrollEvent *ev, bool stopped, boo memset(&s.physical_event, 0, sizeof(s.physical_event)); s.physical_event.start = now; } - if (ev->unscaled.y > 0) s.scale = ev->y_offset / ev->unscaled.y; - else if (ev->unscaled.x > 0) s.scale = ev->x_offset / ev->unscaled.x; + if (ev->unscaled.y != 0) s.scale = ev->y_offset / ev->unscaled.y; + else if (ev->unscaled.x != 0) s.scale = ev->x_offset / ev->unscaled.x; if (s.window_id && s.window_id != w->id) cancel_existing_scroll(true); if (s.state != PHYSICAL_EVENT_IN_PROGRESS) cancel_existing_scroll(false); if (!is_synthetic_momentum_start_event) {