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
This commit is contained in:
Kovid Goyal 2026-10-05 20:41:07 +05:30
parent 007e61a59e
commit 51aa327be1
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 2 deletions

View file

@ -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]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -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) {