Fix the foreground style for find my mouse#42865
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR modifies the FindMyMouse window configuration to improve mouse input transparency and adjust window behavior. The changes include adding window extended styles for mouse transparency and layered rendering, removing a cursor message handler, and modifying window positioning flags.
Key Changes
- Added
WS_EX_TRANSPARENTandWS_EX_LAYEREDextended window styles at window creation - Removed
WM_SETCURSORmessage handler that set the cursor to arrow - Removed
SWP_NOACTIVATEflag fromSetWindowPoscall inStartSonar()
| // Cover the entire virtual screen. | ||
| // 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, SWP_NOACTIVATE); | ||
| 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.
Removing the SWP_NOACTIVATE flag will cause the window to activate when positioned, potentially stealing focus from the foreground application. The Find My Mouse overlay should remain non-intrusive and not activate. The flag should be restored, or replaced with SWP_NOACTIVATE to maintain the previous behavior of not activating the window.
| SetWindowPos(m_hwnd, HWND_TOPMOST, GetSystemMetrics(SM_XVIRTUALSCREEN) + 1, GetSystemMetrics(SM_YVIRTUALSCREEN) + 1, GetSystemMetrics(SM_CXVIRTUALSCREEN) - 2, GetSystemMetrics(SM_CYVIRTUALSCREEN) - 2, 0); | |
| SetWindowPos(m_hwnd, HWND_TOPMOST, GetSystemMetrics(SM_XVIRTUALSCREEN) + 1, GetSystemMetrics(SM_YVIRTUALSCREEN) + 1, GetSystemMetrics(SM_CXVIRTUALSCREEN) - 2, GetSystemMetrics(SM_CYVIRTUALSCREEN) - 2, SWP_NOACTIVATE); |
| } | ||
|
|
||
| DWORD exStyle = WS_EX_TOOLWINDOW | Shim()->GetExtendedStyle(); | ||
| DWORD exStyle = WS_EX_TRANSPARENT | WS_EX_LAYERED | WS_EX_TOOLWINDOW | Shim()->GetExtendedStyle(); |
There was a problem hiding this comment.
The WS_EX_LAYERED flag is not needed for CompositionSpotlight, which uses the Windows Composition API rather than layered window functions like SetLayeredWindowAttributes. This flag is only required by the legacy GdiSonar implementations that are not currently used. While this doesn't cause a functional issue, removing it would improve code clarity and avoid potential confusion about the window's rendering approach.
| DWORD exStyle = WS_EX_TRANSPARENT | WS_EX_LAYERED | WS_EX_TOOLWINDOW | Shim()->GetExtendedStyle(); | |
| DWORD exStyle = WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW | Shim()->GetExtendedStyle(); |
Summary of the Pull Request
Find my mouse should use full transparent window
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
Find.my.mouse.cursor.style.fix.mp4