-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
There was a problem hiding this 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">
// 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); |
There was a problem hiding this comment.
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.
// 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))); |
There was a problem hiding this comment.
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.
float borderThickness = static_cast<float>(std::hypot(GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN))); | |
float borderThickness = m_screenDiagonal; |
Copilot uses AI. Check for mistakes.
SelectedIndex="{x:Bind ViewModel.IsSpotlightModeEnabled, Converter={StaticResource ReverseBoolToComboBoxIndexConverter}, Mode=TwoWay}"> | ||
<ComboBoxItem x:Uid="HighlightMode_Spotlight_Mode" /> | ||
<ComboBoxItem x:Uid="HighlightMode_Circle_Highlight_Mode" /> | ||
</ComboBox> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Summary of the Pull Request
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
spotlight_mode.mp4