Skip to content

Let a trackpad scroll the transcript - #8

Merged
bharathm03 merged 1 commit into
masterfrom
fix/trackpad-scroll
Aug 27, 2026
Merged

Let a trackpad scroll the transcript#8
bharathm03 merged 1 commit into
masterfrom
fix/trackpad-scroll

Conversation

@bharathm03

Copy link
Copy Markdown
Collaborator

Two-finger scroll does nothing in the transcript on a laptop. Two independent paths drop precision scrolling, and a trackpad hits both — which is why nothing about the gesture worked, in either direction, at any speed.

The wheel path rounded the remainder away.

final deltaLines = (event.scrollDelta.dy / metrics.linePixels).round();
if (deltaLines == 0) return;   // the pixels are gone

A mouse notch is worth several lines, so it survives rounding. A precision touchpad reports a few pixels per event — every one of them rounds to zero and is discarded, so the transcript never moves however long you scroll. The pan-zoom path already carried a sub-line remainder; the wheel now does the same.

The pan-zoom path was dropped outright whenever the program had the mouse.

if (_terminalMouseReportingEnabled) return;

PointerPanZoom* is what a two-finger scroll actually delivers (macOS always; Windows precision touchpads via DirectManipulation), and mouse reporting is not an edge case — a full-screen agent turns it on for its entire run. So the only scroll input a laptop has was dead for the whole session, and the comment justifying it ("matches iTerm2 / Terminal.app") describes behaviour neither of them has.

SGR has no pan-zoom encoding, but it has wheel buttons, and one button-4/5 press per line crossed is what terminals that support both send. That is what the pan now forwards, reusing _sendWheelStep so the encoding cannot drift from the real wheel's.

Tests

Two new cases in terminal_view_test.dart, both failing before this change:

  • a trackpad pan under normalMouse + sgrMouse reaches the program as BUTTON_FOUR
  • wheel deltas of a quarter-line each still move the transcript

flutter test in pkgs/vte/ghostty_vte_flutter: 214 pass, 28 fail — the same 28 that fail on master on this machine (shell-launch and glyph-painting cases that need a POSIX shell / different font metrics).

Not verified on hardware yet

The repros are synthetic pointer sequences, so they prove the code path, not the platform. Neither fix has been driven by a real trackpad — the machine reporting the bug is a laptop that isn't to hand.

Two independent paths dropped precision scrolling, and a laptop hits both.

The wheel path rounded each event to whole lines and threw the remainder away. A mouse notch is several lines, so it survived rounding; a precision touchpad reports a few pixels per event, every one of which rounds to zero, so the transcript never moved no matter how long you scrolled. Accumulate the pixels and carry the sub-line remainder, the way the pan-zoom path already did.

The pan-zoom path — what a trackpad two-finger scroll actually delivers on macOS and on Windows precision touchpads — returned early whenever the program had mouse reporting on. That is not what other terminals do, and mouse reporting is not an edge case: a full-screen agent holds the mouse for its entire run, so the one input a laptop has was dead for the whole session. Forward it as one wheel step per line crossed, which is the encoding SGR mouse actually has.
@bharathm03
bharathm03 merged commit c262d5f into master Aug 27, 2026
17 checks passed
@bharathm03
bharathm03 deleted the fix/trackpad-scroll branch August 27, 2026 16:41
bharathm03 added a commit to antgrid-ai/antgrid that referenced this pull request Aug 27, 2026
Picks up antgrid-ai/dart_terminal#8. Two independent paths in the terminal view dropped precision scrolling, and a two-finger scroll hits both: the wheel path rounded each event to whole lines and discarded the remainder (a mouse notch survives that, a touchpad's few-pixel events all round to zero), and the pan-zoom path — what a trackpad actually delivers — returned early whenever the program had mouse reporting on, which a full-screen agent holds for its entire run.
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