Skip to content

Add middle-button scrolling support - #20469

Open
ghnew wants to merge 2 commits into
microsoft:mainfrom
ghnew:feat/middle-button-scrolling
Open

Add middle-button scrolling support#20469
ghnew wants to merge 2 commits into
microsoft:mainfrom
ghnew:feat/middle-button-scrolling

Conversation

@ghnew

@ghnew ghnew commented Jul 26, 2026

Copy link
Copy Markdown

Summary of the Pull Request

Introduces Mouse Panning (middle-button scrolling) and a configurable middleClickAction setting to Windows Terminal (wt.exe).

Users can now middle-click to enter vertical autoscroll panning mode with dynamic cursor icon feedback (SizeAll ╬ at the origin anchor and SizeNorthSouth $\updownarrow$ while moving), or configure middle-click to paste text (common in Unix/Linux terminals).

References and Relevant Issues

Detailed Description of the Pull Request / Additional comments

  1. Settings Model (src/cascadia/TerminalSettingsModel/ & src/cascadia/inc/):

    • Added MiddleClickAction enum (Default = 0, Pan, Paste, None) and MiddleClickAction property to IControlSettings.idl.
    • Added macro definition entry to CONTROL_SETTINGS(X) in ControlProperties.h.
    • Exposed middleClickAction in profile settings (Profile.idl, MTSMSettings.h).
    • Added JSON string mapper definitions in TerminalSettingsSerializationHelpers.h and EnumMappings.cpp to support "pan", "paste", "default", and "none" values in settings.json.
  2. Input Interactivity & Viewport Control (src/cascadia/TerminalControl/):

    • ControlInteractivity.cpp: Updated PointerPressed for IsMiddleButtonDown to evaluate MiddleClickAction. When set to Paste, it raises RequestPasteTextFromClipboard().
    • TermControl.cpp:
      • Added _isPanning and _panningAnchorPos state tracking in _PointerPressedHandler, _PointerMovedHandler, and _PointerReleasedHandler.
      • Calculates vertical displacement velocity relative to the origin touchdown point and feeds it to _TryStartAutoScroll(...).
      • Dynamically sets CoreWindow::GetForCurrentThread().PointerCursor(...) to CoreCursorType::SizeAll ╬ when stationary near the anchor point and CoreCursorType::SizeNorthSouth $\updownarrow$ while scrolling vertically. Resets the cursor to IBeam when panning completes.
  3. Unit Testing (src/cascadia/UnitTests_Control/):

    • Added TestMiddleClick to ControlInteractivityTests.cpp to test settings evaluation and clipboard paste event dispatching.

Validation Steps Performed

  • Automated Tests: Executed TAEF unit tests via te.exe on Control.Unit.Tests.dll. Verified TestMiddleClick passed (1/1 Passed).
  • Manual Verification:
    1. Built and launched WindowsTerminal.exe locally.
    2. Verified middle-clicking inside the terminal viewport enters autoscroll panning mode with cursor switching (SizeAll $\rightarrow$ SizeNorthSouth).
    3. Added "middleClickAction": "paste" to settings.json and verified middle-clicking pastes clipboard text.
    4. Verified middle-clicks pass through to applications (e.g. vim / tmux) when VT mouse tracking is active.

PR Checklist

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@ghnew

ghnew commented Jul 26, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@microsoft-github-policy-service microsoft-github-policy-service Bot added Issue-Task It's a feature request, but it doesn't really need a major design. Area-Input Related to input processing (key presses, mouse, etc.) Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Terminal The new Windows Terminal. labels Jul 26, 2026
@DHowett

DHowett commented Jul 26, 2026

Copy link
Copy Markdown
Member

Mind sharing a video?

@ghnew

ghnew commented Jul 27, 2026

Copy link
Copy Markdown
Author
Screen.Recording.2026-07-27.111029.mp4

@DHowett sure, here it is

X(hstring, DragDropDelimiter, "dragDropDelimiter", L" ") \
X(Microsoft::Terminal::Control::PathTranslationStyle, PathTranslationStyle, "pathTranslationStyle", Microsoft::Terminal::Control::PathTranslationStyle::None)
X(Microsoft::Terminal::Control::PathTranslationStyle, PathTranslationStyle, "pathTranslationStyle", Microsoft::Terminal::Control::PathTranslationStyle::None) \
X(Microsoft::Terminal::Control::MiddleClickAction, MiddleClickAction, "middleClickAction", Microsoft::Terminal::Control::MiddleClickAction::Default)

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.

The PR looks good overall, but this should technically be an action / keybinding. Since we don't have proper mouse-bindings yet, could we just mark this setting as experimental like some others?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the review @lhecker! That makes total sense. I've updated the setting JSON key to "experimental.middleClickAction" in MTSMSettings.h.

JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Control::MiddleClickAction)
{
static constexpr std::array<pair_type, 4> mappings = {
pair_type{ "default", ValueType::Default },

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.

I don't think we need a default value, right? The default is unambiguously scrolling, at least on Windows.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've removed the redundant "default" string option and made Pan (0) the default enum value for experimental.middleClickAction so the JSON options are cleanly "pan", "paste", and "none".

@DHowett

DHowett commented Jul 27, 2026

Copy link
Copy Markdown
Member

Hey, so, can somebody clarify who @SanjayPJ is compared to @ghnew, and whether @ghnew has permission to submit @SanjayPJ's commit and sign the contributor license agreement for @SanjayPJ's work?

@ghnew
ghnew force-pushed the feat/middle-button-scrolling branch from eb8966a to 7ce3da4 Compare July 28, 2026 06:57
@ghnew

ghnew commented Jul 28, 2026

Copy link
Copy Markdown
Author

Hi @DHowett ! Sorry for the confusion.

Both @SanjayPJ and @ghnew are my GitHub accounts. I accidentally used different accounts for the contribution and the CLA.

To keep everything consistent, I've now rewritten the commit author so that all commits are attributed to @ghnew, which is the account associated with the CLA. Please let me know if there's anything else I need to do.

@lhecker

lhecker commented Jul 28, 2026

Copy link
Copy Markdown
Member

Do note that GitHub's TOS technically forbids having multiple non-paid accounts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Input Related to input processing (key presses, mouse, etc.) Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mouse panning (middle-button scrolling)

3 participants