Repository: microsoft/terminal
File: src/cascadia/WindowsTerminal/AppHost.cpp (C++)

Code before:
                // We purposely don't log here, because this is exceptionally noisy,
                // especially on startup, when we're moving the window into place
                // but might not have a real xamlRoot yet.
            }
        }
    }
}

void AppHost::_CloseRequested(const winrt::Windows::Foundation::IInspectable& /*sender*/,
                              const winrt::Windows::Foundation::IInspectable& /*args*/)
{
    const auto pos = _GetWindowLaunchPosition();
    _logic.CloseWindow(pos);
}

void AppHost::_AppInitializedHandler(const winrt::Windows::Foundation::IInspectable& /*sender*/,
                                     const winrt::Windows::Foundation::IInspectable& /*arg*/)
{
    // GH#11561: We're totally done being initialized. Resize the window to
    // match the initial settings, and then call ShowWindow to finally make us
    // visible.

    LaunchMode launchMode{};
    _initialResizeAndRepositionWindow(_window->GetHandle(), _proposedRect, launchMode);

    int nCmdShow = SW_SHOW;
    if (WI_IsFlagSet(launchMode, LaunchMode::MaximizedMode))
    {
        nCmdShow = SW_MAXIMIZE;
    }

    ShowWindow(_window->GetHandle(), nCmdShow);
}


Review comment (suggestion):
You can use `SW_SHOWDEFAULT` here to respect the wishes of the OS.
> Sets the show state based on the SW_ value specified in the [STARTUPINFO](https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/ns-processthreadsapi-startupinfoa) structure passed to the [CreateProcess](https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-createprocessa) function by the program that started the application.

If not, then this should still probably rather be `SW_SHOWNORMAL` I think.

Code after:
                // it's only 5 LOC so whatever.
                const auto popups{ Media::VisualTreeHelper::GetOpenPopupsForXamlRoot(root.XamlRoot()) };
                for (const auto& p : popups)
                {
                    p.IsOpen(false);
                }
            }
            catch (...)
            {
                // We purposely don't log here, because this is exceptionally noisy,
                // especially on startup, when we're moving the window into place
                // but might not have a real xamlRoot yet.
            }
        }
    }
}

void AppHost::_CloseRequested(const winrt::Windows::Foundation::IInspectable& /*sender*/,
                              const winrt::Windows::Foundation::IInspectable& /*args*/)
{
    const auto pos = _GetWindowLaunchPosition();
    _logic.CloseWindow(pos);
}

void AppHost::_AppInitializedHandler(const winrt::Windows::Foundation::IInspectable& /*sender*/,
                                     const winrt::Windows::Foundation::IInspectable& /*arg*/)
{
    // GH#11561: We're totally done being initialized. Resize the window to
    // match the initial settings, and then call ShowWindow to finally make us
    // visible.

    LaunchMode launchMode{};
    _initialResizeAndRepositionWindow(_window->GetHandle(), _proposedRect, launchMode);

    auto nCmdShow = SW_SHOWDEFAULT;
    if (WI_IsFlagSet(launchMode, LaunchMode::MaximizedMode))
    {
        nCmdShow = SW_MAXIMIZE;
    }

    ShowWindow(_window->GetHandle(), nCmdShow);
}