Surface: correct scroll-event semantics (scrolling was far too fast)#9
Merged
Merged
Conversation
ghostty_surface_mouse_scroll's last argument is a scroll-mods bitmask (bit 0 = precision, bits 1-3 = momentum phase; ghostty src/input/mouse.zig), but scrollWheel passed the keyboard-modifier bitmask and never set precision. Ghostty therefore treated trackpad pixel deltas as discrete wheel ticks and multiplied each by the cell height -- one line per pixel of finger travel, ~30x too fast -- and holding shift while scrolling happened to flip the precision bit. Mirror ghostty's own AppKit surface view: hasPreciseScrollingDeltas sets the precision flag (deltas are pixels, with ghostty's 2x feel multiplier), discrete wheel ticks pass through unscaled, and momentumPhase is forwarded so inertial scrolling decays properly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RHWv6ccUfu4nK3yiGB4ocZ
arach
approved these changes
Jul 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Another one from running Termini in Belfry (see #3, #8): scrolling in the macOS surface is drastically too fast, because
scrollWheelpasses the wrong thing inghostty_surface_mouse_scroll's flags argument.The bug. That argument is a scroll-mods bitmask — bit 0 is the precision flag, bits 1–3 the momentum phase (
src/input/mouse.zigin ghostty) — butscrollWheelpasses the keyboard modifier bitmask and never sets precision. Two consequences:scrollingDeltaX/YwithhasPreciseScrollingDeltas) are pixel values, but without the precision bit ghostty interprets them as discrete wheel ticks and multiplies each by the cell height — so one pixel of finger travel scrolls a whole line, roughly cell-height× too fast (~30× at typical font sizes).The fix mirrors ghostty's own
SurfaceView_AppKit.swiftscrollWheel:hasPreciseScrollingDeltassets the precision flag and deltas pass as pixels (with the same 2× feel multiplier ghostty uses), discrete wheel ticks pass through unscaled, andNSEvent.momentumPhaseis mapped ontoghostty_input_mouse_momentum_eso inertial flick-scrolling decays properly instead of replaying raw deltas.The iOS surface's pan-gesture path already sets the precision bit correctly and is untouched.
Verified by feel in Belfry (trackpad, mouse wheel, and momentum flicks) against Ghostty.app as the reference;
swift buildclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01RHWv6ccUfu4nK3yiGB4ocZ