Repository navigation
[Mouse Highlighter] Keep ripple work off the low-level hook - #49699
Merged
Muyuan Li (MuyuanMS) merged 5 commits intoAug 11, 2026
Merged
Muyuan Li (MuyuanMS) merged 5 commits into
Muyuan Li (MuyuanMS) merged 5 commits into
Conversation
Move mouse hook processing onto the module window thread, preserve ordered coordinates and click timing, coalesce moves, and reset queued input during lifecycle changes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6caaf738-168e-4b11-8efb-b155139dac31
Clint Rutkas (crutkas)
marked this pull request as ready for review
August 6, 2026 21:52
Co-authored-by: Muyuan Li <116717757+MuyuanMS@users.noreply.github.com>
Co-authored-by: Muyuan Li <116717757+MuyuanMS@users.noreply.github.com>
Co-authored-by: Muyuan Li <116717757+MuyuanMS@users.noreply.github.com>
Keep queued mouse events when PostMessage fails and allow coalesced moves to retry delivery through the synchronized window handle. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 259addc8-304d-4595-83c8-bba3d76e0637
Member
Author
|
Muyuan Li (@MuyuanMS) updated, kicking of a build to do an e2e on it on monday but would love your eyes on it as well / do a manual on it for a few hours too |
This was referenced Aug 10, 2026
Muyuan Li (MuyuanMS)
approved these changes
Aug 10, 2026
Boliang Zhang (LegendaryBlair)
pushed a commit
that referenced
this pull request
Aug 12, 2026
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Mouse Highlighter performed synchronous WinRT Composition work in its `WH_MOUSE_LL` callback. Slow low-level hook callbacks stall the shared mouse-hook chain and can be silently removed by Windows, causing a button-up event to be lost and leaving the ripple or pressed state stuck. FancyZones was inspected to confirm ownership but is not changed by this PR. This moves Mouse Highlighter's visual, animation, timer, and Z-order work onto its module window thread. The hook now records events in a bounded, allocation-free FIFO and posts a window message. Adjacent high-rate mouse moves are coalesced, while button ordering, hook timestamps, and signed screen coordinates (including negative multi-monitor coordinates) are preserved. Stop, settings changes, and teardown clear pending events, pressed state, hold state, and timers. Settings application is also marshaled to the window thread so WinRT Composition remains thread-affine. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [ ] Closes: #xxx <!-- - [ ] Closes: #yyy (add separate lines for additional resolved issues) --> - [x] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [x] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments The low-level hook now does only constant-time event capture and queue signaling. A fixed-capacity FIFO preserves the sequence of button transitions and mouse positions without allocating in the hook. Only adjacent move events are coalesced, avoiding message flooding without moving a cursor update across a button boundary. Input timestamps keep quick-click versus hold classification based on the original 180 ms threshold even if window-thread processing is delayed. All Composition access runs through the Mouse Highlighter window/message queue. Lifecycle paths unhook before clearing the queue and reset button, ripple-hold, spotlight, and timer state. If the bounded queue ever fills, recovery resets transient visual state before retaining the triggering button event rather than risking a dropped button-up. <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed - Built `src/modules/MouseUtils/MouseHighlighter/MouseHighlighter.vcxproj` in Debug x64. - Built `src/modules/FancyZones/FancyZonesLib/FancyZonesLib.vcxproj` in Debug x64 to verify the unchanged hook-chain neighbor. - Ran `git diff --check`. - Performed a focused concurrency and event-ordering code review. No focused native unit-test seam exists for this hook/Composition path without disproportionate refactoring, so no automated test was added. No end-to-end rapid-click/drag stress run across mixed-DPI multi-monitor layouts was performed. --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Muyuan Li <116717757+MuyuanMS@users.noreply.github.com> Copilot-Session: 6caaf738-168e-4b11-8efb-b155139dac31 Copilot-Session: 259addc8-304d-4595-83c8-bba3d76e0637 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7b3fb20d-6e9d-4fef-a5cd-f8921d28c220
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.
Summary of the Pull Request
Mouse Highlighter performed synchronous WinRT Composition work in its
WH_MOUSE_LLcallback. Slow low-level hook callbacks stall the shared mouse-hook chain and can be silently removed by Windows, causing a button-up event to be lost and leaving the ripple or pressed state stuck. FancyZones was inspected to confirm ownership but is not changed by this PR.This moves Mouse Highlighter's visual, animation, timer, and Z-order work onto its module window thread. The hook now records events in a bounded, allocation-free FIFO and posts a window message. Adjacent high-rate mouse moves are coalesced, while button ordering, hook timestamps, and signed screen coordinates (including negative multi-monitor coordinates) are preserved. Stop, settings changes, and teardown clear pending events, pressed state, hold state, and timers. Settings application is also marshaled to the window thread so WinRT Composition remains thread-affine.
PR Checklist
Detailed Description of the Pull Request / Additional comments
The low-level hook now does only constant-time event capture and queue signaling. A fixed-capacity FIFO preserves the sequence of button transitions and mouse positions without allocating in the hook. Only adjacent move events are coalesced, avoiding message flooding without moving a cursor update across a button boundary. Input timestamps keep quick-click versus hold classification based on the original 180 ms threshold even if window-thread processing is delayed.
All Composition access runs through the Mouse Highlighter window/message queue. Lifecycle paths unhook before clearing the queue and reset button, ripple-hold, spotlight, and timer state. If the bounded queue ever fills, recovery resets transient visual state before retaining the triggering button event rather than risking a dropped button-up.
Validation Steps Performed
src/modules/MouseUtils/MouseHighlighter/MouseHighlighter.vcxprojin Debug x64.src/modules/FancyZones/FancyZonesLib/FancyZonesLib.vcxprojin Debug x64 to verify the unchanged hook-chain neighbor.git diff --check.No focused native unit-test seam exists for this hook/Composition path without disproportionate refactoring, so no automated test was added. No end-to-end rapid-click/drag stress run across mixed-DPI multi-monitor layouts was performed.