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 <migrie@microsoft.com>
  • Loading branch information
flyingcat and zadjii-msft authored Jun 10, 2024
1 parent e49afb3 commit c52ba7d
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 @@ -130,6 +130,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 c52ba7d

Please sign in to comment.