Repository: microsoft/terminal
File: src/cascadia/TerminalApp/TerminalPage.cpp (C++)

Code before:
            // first place. If we try accepting the connection, the spawning an
            // elevated version of the Terminal with that profile... that's a
            // recipe for disaster. We won't ever open up a tab in this window.
            newTerminalArgs.Elevate(false);
            const auto newPane = _MakePane(newTerminalArgs, nullptr, connection);
            newPane->WalkTree([](auto pane) {
                pane->FinalizeConfigurationGivenDefault();
            });
            _CreateNewTabFromPane(newPane);

            // Request a summon of this window to the foreground
            _SummonWindowRequestedHandlers(*this, nullptr);

            const IInspectable unused{ nullptr };
            _SetAsDefaultDismissHandler(unused, unused);

            // TEMPORARY SOLUTION
            // If the connection has requested for the window to be maximized,
            // manually maximize it here. Ideally, we should be _initializing_
            // the session maximized, instead of manually maximizing it after initialization.
            // However, because of the current way our defterm handoff works,
            // we are unable to get the connection info before the terminal session
            // has already started.

            // Make sure that there were no other tabs already existing (in
            // the case that we are in glomming mode), because we don't want
            // to be maximizing other existing sessions that did not ask for it.
            if (_tabs.Size() == 1 && connection.ShowWindow() == 3)
            {
                RequestSetMaximized(true);
            }
            return S_OK;
        }
        CATCH_RETURN()
    }

    // Method Description:
    // - Creates a settings UI tab and focuses it. If there's already a settings UI tab open,
    //   just focus the existing one.
    // Arguments:
    // - <none>
    // Return Value:
    // - <none>
    void TerminalPage::OpenSettingsUI()
    {
        // If we're holding the settings tab's switch command, don't create a new one, switch to the existing one.
        if (!_settingsTab)
        {
            winrt::Microsoft::Terminal::Settings::Editor::MainPage sui{ _settings };
            if (_hostingHwnd)
            {

Review comment (suggestion):
Crazy idea: if we're in glomming mode and a defterm connection requests to be maximized, should we not glom that connection? Open it in a new window instead and make _that_ window maximized?

I guess then we're opening up the possibility for needing to check if a window is maximized and (if that's the case) glomming to that one if maximized was requested.

Code after:
            // first place. If we try accepting the connection, the spawning an
            // elevated version of the Terminal with that profile... that's a
            // recipe for disaster. We won't ever open up a tab in this window.
            newTerminalArgs.Elevate(false);
            const auto newPane = _MakePane(newTerminalArgs, nullptr, connection);
            newPane->WalkTree([](auto pane) {
                pane->FinalizeConfigurationGivenDefault();
            });
            _CreateNewTabFromPane(newPane);

            // Request a summon of this window to the foreground
            _SummonWindowRequestedHandlers(*this, nullptr);

            const IInspectable unused{ nullptr };
            _SetAsDefaultDismissHandler(unused, unused);

            // TEMPORARY SOLUTION
            // If the connection has requested for the window to be maximized,
            // manually maximize it here. Ideally, we should be _initializing_
            // the session maximized, instead of manually maximizing it after initialization.
            // However, because of the current way our defterm handoff works,
            // we are unable to get the connection info before the terminal session
            // has already started.

            // Make sure that there were no other tabs already existing (in
            // the case that we are in glomming mode), because we don't want
            // to be maximizing other existing sessions that did not ask for it.
            if (_tabs.Size() == 1 && connection.ShowWindow() == SW_SHOWMAXIMIZED)
            {
                RequestSetMaximized(true);
            }
            return S_OK;
        }
        CATCH_RETURN()
    }

    // Method Description:
    // - Creates a settings UI tab and focuses it. If there's already a settings UI tab open,
    //   just focus the existing one.
    // Arguments:
    // - <none>
    // Return Value:
    // - <none>
    void TerminalPage::OpenSettingsUI()
    {
        // If we're holding the settings tab's switch command, don't create a new one, switch to the existing one.
        if (!_settingsTab)
        {
            winrt::Microsoft::Terminal::Settings::Editor::MainPage sui{ _settings };
            if (_hostingHwnd)
            {