Skip to content

Prefer visible process target windows#4

Merged
SteffenCarlsen merged 2 commits into
mainfrom
feature/prefer-main-process-window
Jun 1, 2026
Merged

Prefer visible process target windows#4
SteffenCarlsen merged 2 commits into
mainfrom
feature/prefer-main-process-window

Conversation

@SteffenCarlsen

Copy link
Copy Markdown
Owner

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.

Copilot AI review requested due to automatic review settings June 1, 2026 12:58

Copilot AI left a comment

Copy link
Copy Markdown

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 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 Win32WindowQuery process-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.

Comment thread tests/ModernOverlay.Tests/TargetTrackingTests.cs Outdated
Comment thread src/ModernOverlay.Win32/Win32WindowQuery.cs Outdated
Comment thread tests/ModernOverlay.Tests/TargetTrackingTests.cs Outdated
Comment thread src/ModernOverlay.Win32/Win32WindowQuery.cs Outdated
@SteffenCarlsen SteffenCarlsen merged commit 0c5d54b into main Jun 1, 2026
1 check passed
@SteffenCarlsen SteffenCarlsen deleted the feature/prefer-main-process-window branch June 1, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants