Skip to content

Commit

Permalink
Make subsequent windows open in the foreground (#17368)
Browse files Browse the repository at this point in the history
Sometimes subsequent WT windows open in the background behind other
applications. This PR tries to fix it.

Refs #15895
Refs #15479

Mysterious bug (and annoying). There are even some discussions about
happening to the first startup, not just subsequent ones. Sometimes the
window may show up without animation too. So I don't think this is the
final solution, but it did get solved on my computer, for now.

## Validation Steps Performed
0. Quit all WT windows if some.
1. Open File Explorer, click "Open in Terminal" in context menu.
2. Move the newly opened window and minimize it.
3. Back to step 1 and repeat several times.
4. All the windows should open in the foreground correctly (yet possibly
without animation).

---------

Co-authored-by: Mike Griese <[email protected]>
(cherry picked from commit c52ba7d)
Service-Card-Id: 92715121
Service-Version: 1.20
  • Loading branch information
2 people authored and DHowett committed Jun 26, 2024
1 parent c318eb9 commit 3088224
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cascadia/Remoting/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
// We connected to a monarch instance, not us though. This won't hit
// in isolated mode.

LOG_IF_FAILED(CoAllowSetForegroundWindow(winrt::get_unknown(_monarch), nullptr));

// Send the commandline over to the monarch process
if (_proposeToMonarch(args))
{
Expand Down

0 comments on commit 3088224

Please sign in to comment.