Skip to content

Mouse highlighter: support a spotlight mode - inner transparent, out a backdrop #40043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

vanzue
Copy link
Contributor

@vanzue vanzue commented Jun 14, 2025

Summary of the Pull Request

PR Checklist

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

spotlight_mode.mp4

@vanzue vanzue marked this pull request as ready for review June 17, 2025 09:55
@yeelam-gordon yeelam-gordon requested a review from Copilot June 18, 2025 08:50
Copy link
Contributor

@yeelam-gordon yeelam-gordon left a comment

Choose a reason for hiding this comment

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

Looks good at the logic.

@yeelam-gordon yeelam-gordon added the Product-Mouse Utilities Refers to the Mouse Utilities PowerToy label Jun 18, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new “spotlight” mode for the Mouse Highlighter feature, allowing the screen to dim around the cursor with an inner transparent circle.

  • Introduces a SpotlightMode setting through JSON properties, ViewModel, and settings UI
  • Extends the renderer in MouseHighlighter.cpp to draw a stroked circle for spotlight mode and disable other pointers
  • Updates resources and XAML to expose a ComboBox for switching between circle highlight and spotlight modes

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/settings-ui/Settings.UI/ViewModels/MouseUtilsViewModel.cs Added IsSpotlightModeEnabled property and backing field
src/settings-ui/Settings.UI/Strings/en-us/Resources.resw Added localization strings for “Highlight mode” and options
src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml Added ComboBox for mode selection and disabled color pickers
src/settings-ui/Settings.UI.Library/MouseHighlighterProperties.cs Added SpotlightMode JSON setting property
src/modules/MouseUtils/MouseHighlighter/dllmain.cpp Parsed spotlight_mode from JSON into settings
src/modules/MouseUtils/MouseHighlighter/MouseHighlighter.h Added spotlightMode to MouseHighlighterSettings struct
src/modules/MouseUtils/MouseHighlighter/MouseHighlighter.cpp Implemented drawing logic, clears, and mode handling
Comments suppressed due to low confidence (1)

src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml:226

  • [nitpick] Binding a boolean to a ComboBox index via a reverse converter can be confusing. Consider introducing an enum HighlightMode { Circle, Spotlight } in the ViewModel for clearer two-way binding.
                            <tkcontrols:SettingsCard x:Uid="HighlightMode">

Comment on lines 455 to 456
// HACK: Draw with 1 pixel off. Otherwise Windows glitches the task bar transparency when a transparent window fill the whole screen.
SetWindowPos(m_hwnd, HWND_TOPMOST, GetSystemMetrics(SM_XVIRTUALSCREEN) + 1, GetSystemMetrics(SM_YVIRTUALSCREEN) + 1, GetSystemMetrics(SM_CXVIRTUALSCREEN) - 2, GetSystemMetrics(SM_CYVIRTUALSCREEN) - 2, 0);
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

There are now two definitions of BringToFront() in this file. Remove the duplicate definition or merge their logic to prevent redefinition/link errors.

Suggested change
// HACK: Draw with 1 pixel off. Otherwise Windows glitches the task bar transparency when a transparent window fill the whole screen.
SetWindowPos(m_hwnd, HWND_TOPMOST, GetSystemMetrics(SM_XVIRTUALSCREEN) + 1, GetSystemMetrics(SM_YVIRTUALSCREEN) + 1, GetSystemMetrics(SM_CXVIRTUALSCREEN) - 2, GetSystemMetrics(SM_CYVIRTUALSCREEN) - 2, 0);
// HACK: Draw with 1 pixel off. Otherwise Windows glitches the task bar transparency when a transparent window fills the whole screen.
SetWindowPos(m_hwnd, HWND_TOPMOST, GetSystemMetrics(SM_XVIRTUALSCREEN) + 1, GetSystemMetrics(SM_YVIRTUALSCREEN) + 1, GetSystemMetrics(SM_CXVIRTUALSCREEN) - 2, GetSystemMetrics(SM_CYVIRTUALSCREEN) - 2, 0);
// Additional logic from the duplicate definition (if any) can be merged here.

Copilot uses AI. Check for mistakes.

m_alwaysPointer = circleShape;
if (m_spotlightMode)
{
float borderThickness = static_cast<float>(std::hypot(GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN)));
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

Computing the screen diagonal with GetSystemMetrics and std::hypot on every mouse event can be expensive. Cache this value once (e.g., at startup) to reduce per-click overhead.

Suggested change
float borderThickness = static_cast<float>(std::hypot(GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN)));
float borderThickness = m_screenDiagonal;

Copilot uses AI. Check for mistakes.

@vanzue vanzue requested a review from yaqingmi June 19, 2025 02:11
SelectedIndex="{x:Bind ViewModel.IsSpotlightModeEnabled, Converter={StaticResource ReverseBoolToComboBoxIndexConverter}, Mode=TwoWay}">
<ComboBoxItem x:Uid="HighlightMode_Spotlight_Mode" />
<ComboBoxItem x:Uid="HighlightMode_Circle_Highlight_Mode" />
</ComboBox>
Copy link
Contributor

Choose a reason for hiding this comment

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

For the UI tests of Mouse Highlighter, since elements can only be clicked when they are visible, it's important to check the number of mouse wheel scrolls during the test if the UI layout has been modified. This ensures that the target elements are brought into view and can be interacted with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks fore careful review, So I will know maybe UI testing will fail because of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Product-Mouse Utilities Refers to the Mouse Utilities PowerToy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants