Prefer visible process target windows#4
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates process-based target discovery so overlays attach to a more “main window”-like top-level HWND (favoring visible/unowned/non-tool windows) rather than the first enumerated window for a process, preventing attachment to hidden helper/tool windows in multi-window apps.
Changes:
- Update
Win32WindowQueryprocess-name/process-id discovery to choose the “best” top-level window via scoring instead of first match. - Add a Windows integration test ensuring process-id discovery prefers a visible main window over a hidden helper window.
- Adjust an existing discovery test to use process-name targeting (but the test name currently doesn’t reflect that).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tests/ModernOverlay.Tests/TargetTrackingTests.cs | Adds/adjusts integration tests to validate improved process target discovery behavior. |
| src/ModernOverlay.Win32/Win32WindowQuery.cs | Implements “best window” selection for process-based window discovery via scoring. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Fixes process target discovery so ByProcessName and ByProcessId prefer visible, unowned, non-tool top-level windows instead of returning the first HWND owned by the process. This prevents overlays from attaching to hidden helper/tool windows in multi-window processes. Validation: dotnet test tests\ModernOverlay.Tests\ModernOverlay.Tests.csproj --configuration Debug --filter ProcessTargetDiscoveryPrefersVisibleMainWindow.