Skip to content

fix: mouse wheel responds on the first tick after a direction change - #21807

Merged
TurboGit merged 3 commits into
darktable-org:masterfrom
Arecsu:fix/mouse-wheel-direction-lag
Aug 14, 2026
Merged

fix: mouse wheel responds on the first tick after a direction change#21807
TurboGit merged 3 commits into
darktable-org:masterfrom
Arecsu:fix/mouse-wheel-direction-lag

Conversation

@Arecsu

@Arecsu Arecsu commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Scrolling a bauhaus slider or dropdown with the mouse wheel was eating ticks: scroll a few notches up, then one down, and the first down notch did nothing — you had to scroll down twice to move the value. The very first notch of a scroll could get lost too (scroll three times, only two register). It affected sliders, dropdowns, and the alt/ctrl/shift zoom-range shortcuts.

Why

A wheel notch arrives at the scroll controller as a smooth event with delta ±1. The discrete scroll proxy was attenuating that to 0.95, and its accumulator only emits a step once it crosses ±1.0. So a single notch could never register by itself, and the leftover 0.95-ish remainder meant the first notch of the opposite direction was silently spent cancelling it. Released versions passed wheel notches straight through as exact ±1 steps, which is why this only showed up with the new proxy.

What changed

  • Sliders, dropdowns and their popups: wheel notches are no longer attenuated, so each notch is exactly one step and registers immediately. Smooth/touchpad scrolling keeps its attenuation, and macOS keeps its compression (its scroll deltas are distance-based).
  • If a fractional remainder does exist (touchpad-style input), it's dropped when the scroll direction changes, so the first tick of the new direction counts.
  • dt_gui_get_scroll_unit_deltas() (thumbtable, gradientslider, darkroom scroll-zoom, scroll shortcuts) gets the same direction-change handling.

Single-direction scrolling behaves exactly as before.

Fixes #21390

The discrete scroll accumulators (both the event controller proxy used
by bauhaus sliders/dropdowns and dt_gui_get_scroll_unit_deltas) kept the
signed fractional remainder from the previous scroll direction.  After
reversing direction, the first tick was silently spent cancelling that
stale remainder, so it did nothing and a second tick was needed before
the value changed.

Drop the accumulated remainder when the incoming scroll delta changes
sign, so the new direction takes effect on its very first tick.
@Arecsu

Arecsu commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Confirmed and fixed on Linux + Wayland, we should test under Windows to be sure. macOS I think it's fine as well

Wheel notches arrive as GDK_SCROLL_SMOOTH events with |delta| == 1.0.
The discrete proxy (bauhaus sliders, dropdowns and their popups)
attenuated them by the 0.95 Linux/Windows scale, leaving a single notch
at 0.95 -- below the 1.0 emit threshold of the accumulator.  As a
result the first notch of a scroll direction silently did nothing, and
the fractional remainder it built up made the first tick after a
direction change do nothing either.  Dropping the remainder on a
direction change (the previous commit) cannot help here: after the
reset a single 0.95 notch still cannot cross the threshold.

Keep the delta unattenuated in the discrete proxy so a notch is exactly
one step; the smooth/touchpad proxy keeps the attenuation, and macOS
keeps its compression on both paths since its scroll deltas are
distance-based (several units per event).
@TurboGit TurboGit added this to the 5.8 milestone Aug 12, 2026
@TurboGit TurboGit added the bugfix pull request fixing a bug label Aug 12, 2026
Comment thread src/gui/gtk.c Outdated
Restructure the #ifdef so only the conditional differs between
platforms, making the shared attenuation code explicit.

@TurboGit TurboGit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@TurboGit
TurboGit merged commit 300465d into darktable-org:master Aug 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix pull request fixing a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parameter slider scroll misbehavior

2 participants