[PR #17779] Restore off-the-top behavior for VT mouse mode #31368

Open
opened 2026-01-31 09:46:49 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/17779

State: closed
Merged: Yes


PR #10642 and #11290 introduced an adjustment for the cursor position used to generate VT mouse mode events.

One of the decisions made in those PRs was to only send coordinates where Y was >= 0, so if you were off the top of the screen you wouldn't get any events. However, terminal emulators are expected to send clamped events when the mouse is off the screen. This decision broke clamping Y to 0 when the mouse was above the screen.

The other decision was to only adjust the Y coordinate if the core's ScrollOffset was greater than 0. It turns out that ScrollOffset is 0 when you are scrolled all the way back in teh buffer. With this check, we would clamp coordinates properly until the top line of the scrollback was visible, at which point we would send those coordinates over directly. This resulted in the same weird behavior as observed in #10190.

I've fixed both of those things. Core is expected to receive negative coordinates and clamp them to the viewport. ScrollOffset should never be below 0, as it refers to the top visible buffer line.

In addition to that, #17744 uncovered that we were allowing autoscrolling to happen even when VT mouse events were being generated. I added a way for ControlInteractivity to halt further event processing. It's crude.

Refs #10190
Closes #17744

**Original Pull Request:** https://github.com/microsoft/terminal/pull/17779 **State:** closed **Merged:** Yes --- PR #10642 and #11290 introduced an adjustment for the cursor position used to generate VT mouse mode events. One of the decisions made in those PRs was to only send coordinates where Y was >= 0, so if you were off the top of the screen you wouldn't get any events. However, terminal emulators are expected to send _clamped_ events when the mouse is off the screen. This decision broke clamping Y to 0 when the mouse was above the screen. The other decision was to only adjust the Y coordinate if the core's `ScrollOffset` was greater than 0. It turns out that `ScrollOffset` _is 0_ when you are scrolled all the way back in teh buffer. With this check, we would clamp coordinates properly _until the top line of the scrollback was visible_, at which point we would send those coordinates over directly. This resulted in the same weird behavior as observed in #10190. I've fixed both of those things. Core is expected to receive negative coordinates and clamp them to the viewport. ScrollOffset should never be below 0, as it refers to the top visible buffer line. In addition to that, #17744 uncovered that we were allowing autoscrolling to happen even when VT mouse events were being generated. I added a way for `ControlInteractivity` to halt further event processing. It's crude. Refs #10190 Closes #17744
claunia added the pull-request label 2026-01-31 09:46:49 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#31368