[PR #5131] [MERGED] Manually pass mouse wheel messages to TermControls #26129

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/5131
Author: @zadjii-msft
Created: 3/26/2020
Status: Merged
Merged: 4/1/2020
Merged by: @undefined

Base: masterHead: dev/migrie/b/979-hp-touchBAD


📝 Commits (10+)

  • dae733a try naively passing the mouse event through, but that doesn't seem to do the trick
  • 892bc58 doing this the right way still isn't right
  • b708a08 start working on manually plumbing the event through, but this feels so very wrong
  • 68ace1a This is so dumb ; I love it
  • 7252ab6 Hey if your laptop's clock batttery is broken, you're going to have IMMENSE PAIN trying to work on this project.
  • b3da428 Boy this is such a dirty hack but hey it works
  • cf9d172 So very much code cleanup
  • b5a6de3 Merge remote-tracking branch 'origin/master' into dev/migrie/b/979-hp-touchBAD
  • 47f8591 runformat
  • 10cb133 Appease the spelling god?

📊 Changes

17 files changed (+356 additions, -20 deletions)

View changed files

📝 .github/actions/spell-check/whitelist/whitelist.txt (+3 -0)
📝 src/cascadia/TerminalApp/lib/pch.h (+5 -0)
📝 src/cascadia/TerminalConnection/pch.h (+5 -2)
src/cascadia/TerminalControl/IMouseWheelListener.idl (+16 -0)
📝 src/cascadia/TerminalControl/TermControl.cpp (+65 -15)
📝 src/cascadia/TerminalControl/TermControl.h (+4 -1)
📝 src/cascadia/TerminalControl/TermControl.idl (+3 -1)
📝 src/cascadia/TerminalControl/TerminalControl.vcxproj (+1 -0)
📝 src/cascadia/TerminalControl/pch.h (+5 -0)
📝 src/cascadia/TerminalCore/ControlKeyStates.hpp (+21 -0)
📝 src/cascadia/WindowsTerminal/AppHost.cpp (+46 -1)
📝 src/cascadia/WindowsTerminal/AppHost.h (+1 -0)
📝 src/cascadia/WindowsTerminal/IslandWindow.cpp (+34 -0)
📝 src/cascadia/WindowsTerminal/IslandWindow.h (+1 -0)
📝 src/cascadia/WindowsTerminal/pch.h (+4 -0)
📝 src/inc/til/point.h (+36 -0)
📝 src/til/ut_til/PointTests.cpp (+106 -0)

📄 Description

Summary of the Pull Request

As we've learned in #979, not all touchpads are created equal. Some of them have bad drivers that makes scrolling inactive windows not work. For whatever reason, these devices think the Terminal is all one giant inactive window, so we don't get the mouse wheel events through the XAML stack. We do however get the event as a WM_MOUSEWHEEL on those devices (a message we don't get on devices with normally functioning trackpads).

This PR attempts to take that WM_MOUSEWHEEL and manually dispatch it to the TermControl, so we can at least scroll the terminal content.

Unfortunately, this solution is not very general purpose. This only works to scroll controls that manually implement our own IMouseWheelListener interface. As we add more controls, we'll need to continue manually implementing this interface, until the underlying XAML Islands bug is fixed. I don't love this. I'd rather have a better solution, but it seems that we can't synthesize a more general-purpose PointerWheeled event that could get routed through the XAML tree as normal.

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

I've also added a til::point conversion to winrt::Windows::Foundation::Point, and some scaling operators for point

Validation Steps Performed

  • It works on my HP Spectre 2017 with a synaptics trackpad
    • I also made sure to test that tmux works in panes on this laptop
  • It works on my slaptop, and DOESN'T follow this hack codepath on this machine.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/5131 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 3/26/2020 **Status:** ✅ Merged **Merged:** 4/1/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/migrie/b/979-hp-touchBAD` --- ### 📝 Commits (10+) - [`dae733a`](https://github.com/microsoft/terminal/commit/dae733a22d0612b5ea9e70cf2b680391b439b637) try naively passing the mouse event through, but that doesn't seem to do the trick - [`892bc58`](https://github.com/microsoft/terminal/commit/892bc58ecf91a5bdcae8c3fde7ea24010893164b) doing this the right way still isn't right - [`b708a08`](https://github.com/microsoft/terminal/commit/b708a08e5c012a69957b74127c1adbc6010f926b) start working on manually plumbing the event through, but this feels so very wrong - [`68ace1a`](https://github.com/microsoft/terminal/commit/68ace1abc6cc56f786f8be77bff0dbbeb4735237) This is so dumb ; I love it - [`7252ab6`](https://github.com/microsoft/terminal/commit/7252ab6dbfbb5c639f36b6694143431c5ca624d3) Hey if your laptop's clock batttery is broken, you're going to have IMMENSE PAIN trying to work on this project. - [`b3da428`](https://github.com/microsoft/terminal/commit/b3da428e61892e7b07e2f6d280a89cd57567cb57) Boy this is such a dirty hack but hey it works - [`cf9d172`](https://github.com/microsoft/terminal/commit/cf9d17282474c4bc6098566a183eff1f3b8f1115) So very much code cleanup - [`b5a6de3`](https://github.com/microsoft/terminal/commit/b5a6de329e0ef772dc5935e43e86b87d546d89e4) Merge remote-tracking branch 'origin/master' into dev/migrie/b/979-hp-touchBAD - [`47f8591`](https://github.com/microsoft/terminal/commit/47f859141244d8af4a00202cf2f3de4a5e6af580) runformat - [`10cb133`](https://github.com/microsoft/terminal/commit/10cb1337e00bfc1f8af52ac154f3428b40f3f499) Appease the spelling god? ### 📊 Changes **17 files changed** (+356 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spell-check/whitelist/whitelist.txt` (+3 -0) 📝 `src/cascadia/TerminalApp/lib/pch.h` (+5 -0) 📝 `src/cascadia/TerminalConnection/pch.h` (+5 -2) ➕ `src/cascadia/TerminalControl/IMouseWheelListener.idl` (+16 -0) 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+65 -15) 📝 `src/cascadia/TerminalControl/TermControl.h` (+4 -1) 📝 `src/cascadia/TerminalControl/TermControl.idl` (+3 -1) 📝 `src/cascadia/TerminalControl/TerminalControl.vcxproj` (+1 -0) 📝 `src/cascadia/TerminalControl/pch.h` (+5 -0) 📝 `src/cascadia/TerminalCore/ControlKeyStates.hpp` (+21 -0) 📝 `src/cascadia/WindowsTerminal/AppHost.cpp` (+46 -1) 📝 `src/cascadia/WindowsTerminal/AppHost.h` (+1 -0) 📝 `src/cascadia/WindowsTerminal/IslandWindow.cpp` (+34 -0) 📝 `src/cascadia/WindowsTerminal/IslandWindow.h` (+1 -0) 📝 `src/cascadia/WindowsTerminal/pch.h` (+4 -0) 📝 `src/inc/til/point.h` (+36 -0) 📝 `src/til/ut_til/PointTests.cpp` (+106 -0) </details> ### 📄 Description ## Summary of the Pull Request As we've learned in #979, not all touchpads are created equal. Some of them have bad drivers that makes scrolling inactive windows not work. For whatever reason, these devices think the Terminal is all one giant inactive window, so we don't get the mouse wheel events through the XAML stack. We do however get the event as a `WM_MOUSEWHEEL` on those devices (a message we don't get on devices with normally functioning trackpads). This PR attempts to take that `WM_MOUSEWHEEL` and manually dispatch it to the `TermControl`, so we can at least scroll the terminal content. Unfortunately, this solution is not very general purpose. This only works to scroll controls that manually implement our own `IMouseWheelListener` interface. As we add more controls, we'll need to continue manually implementing this interface, until the underlying XAML Islands bug is fixed. **I don't love this**. I'd rather have a better solution, but it seems that we can't synthesize a more general-purpose `PointerWheeled` event that could get routed through the XAML tree as normal. ## References * #2606 and microsoft/microsoft-ui-xaml#2101 - these bugs are also tracking a similar "inactive windows" / "scaled mouse events" issue in XAML ## PR Checklist * [x] Closes #979 * [x] I work here * [ ] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments I've also added a `til::point` conversion _to_ `winrt::Windows::Foundation::Point`, and some scaling operators for `point` ## Validation Steps Performed * It works on my HP Spectre 2017 with a synaptics trackpad - I also made sure to test that `tmux` works in panes on this laptop * It works on my slaptop, and DOESN'T follow this hack codepath on this machine. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:14:08 +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#26129