Skip to content

fix(native): scroll the terminal by wheel notch, eased over frames - #943

Merged
omartelo merged 1 commit into
mainfrom
fix/terminal-wheel-scroll
Oct 26, 2026
Merged

omartelo merged 1 commit into
mainfrom
fix/terminal-wheel-scroll

Conversation

@omartelo

Copy link
Copy Markdown
Collaborator

Summary

  • A mouse wheel notch on Wayland reaches Gio as one 150-pixel delta (the compositor's 15 times Gio's discrete scale of 10). The terminal turned it into about eight rows in a single frame, a visible jump, and sent about eight wheel steps to a program tracking the mouse: nvim scrolls three lines a step, so a notch ran through half a screen.
  • A delta of whole notches is now read as a wheel: three rows a notch through scrollback or as arrow keys (as Ghostty and xterm scroll), one wheel step a notch to a program tracking the mouse, which scrolls its own distance.
  • Any other delta is a touchpad's and keeps the old rule, a row per cell height. Gio reports both the same way, so the size is what tells them apart.
  • Whatever a scroll owes is paid out over the coming frames, a third of the rest per frame, instead of in the one that received it. A turn the other way drops what was still owed.
  • wheelNotch per platform, from Gio's own scaling: 150 on Wayland and 10 on X11 (picked by WAYLAND_DISPLAY, the check Gio itself opens Wayland on), 120 on Windows (WHEEL_DELTA), 10 on macOS.
  • CHANGELOG [Unreleased] › Fixed entry.

Test plan

  • TestWheelNotchesScrollTheScrollbackOverSeveralFrames: two notches up leave the viewport where it was until a frame, move part of the way on the first and six rows once drained.
  • TestWheelNotchesReachAFullScreenProgramOverSeveralFrames: three notches send nine arrow keys, or three wheel steps under mouse tracking, spread over frames.
  • TestTouchpadDeltasUnderACellStillScroll: four quarter-row deltas still make one row, as arrow keys and as a wheel step.
  • TestMouseGoesToTheProgramThatTracksIt and TestWheelMovesTheCursorOnTheAlternateScreen now scroll by notches and collect what the frames send: the contract changed, a wheel now counts notches and pays out over frames.
  • Wheel deltas measured in a rig window on Hyprland: every notch arrived as exactly ±150, touchpad deltas as 1 to 5 pixels.
  • The wheel tests pass under both the Wayland and the X11 notch size; local gate in native/: gofmt, go vet ./..., go test ./....

A Wayland wheel notch reaches Gio as one 150-pixel delta, which the terminal turned into some eight rows in a single frame, and into eight wheel steps for a program tracking the mouse. A notch now moves three rows of scrollback or arrow keys, or one wheel step to a tracking program, and the rows ease out over a few frames. Touchpad deltas, which are not whole notches, keep scrolling a row per cell height.
@omartelo
omartelo merged commit 71be028 into main Oct 26, 2026
7 checks passed
@omartelo
omartelo deleted the fix/terminal-wheel-scroll branch October 26, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant