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

Code before:
            CATCH_LOG();
            return result;
        }();

        return isUwp;
    }

    // Method Description:
    // - Build the UI for the terminal app. Before this method is called, it
    //   should not be assumed that the TerminalApp is usable. The Settings
    //   should be loaded before this is called, either with LoadSettings or
    //   GetLaunchDimensions (which will call LoadSettings)
    // Arguments:
    // - <none>
    // Return Value:
    // - <none>
    void TerminalWindow::Create()
    {
        _root->DialogPresenter(*this);

        // Pay attention, that even if some command line arguments were parsed (like launch mode),
        // we will not use the startup actions from settings.
        // While this simplifies the logic, we might want to reconsider this behavior in the future.
        if (!_hasCommandLineArguments && _gotSettingsStartupActions)
        {
            _root->SetStartupActions(_settingsStartupArgs);
        }

        _root->SetSettings(_settings, false); // We're on our UI thread right now, so this is safe
        _root->Loaded({ get_weak(), &TerminalWindow::_OnLoaded });

        _root->Initialized([this](auto&&, auto&&) {
            // GH#288 - When we finish initialization, if the user wanted us
            // launched _fullscreen_, toggle fullscreen mode. This will make sure
            // that the window size is _first_ set up as something sensible, so
            // leaving fullscreen returns to a reasonable size.
            const auto launchMode = this->GetLaunchMode();
            if (_WindowProperties->IsQuakeWindow() || WI_IsFlagSet(launchMode, LaunchMode::FocusMode))
            {
                _root->SetFocusMode(true);
            }

            // The IslandWindow handles (creating) the maximized state
            // we just want to record it here on the page as well.
            if (WI_IsFlagSet(launchMode, LaunchMode::MaximizedMode))
            {
                _root->Maximized(true);
            }

            if (WI_IsFlagSet(launchMode, LaunchMode::FullscreenMode) && !_WindowProperties->IsQuakeWindow())
            {

Review comment (suggestion):
@zadjii-msft Is this the right way to get a handle to `AppLogic`? BTW given that `App::Logic()` returns a singleton, should we maybe remove `static AppLogic logic;` from there and move it into `AppLogic::Current()`? If there's a singleton, I feel like it's more idiomatic to create it inside the class of the singleton.

Code after:
        _root->Loaded({ get_weak(), &TerminalWindow::_OnLoaded });

        _root->Initialized([this](auto&&, auto&&) {
            // GH#288 - When we finish initialization, if the user wanted us
            // launched _fullscreen_, toggle fullscreen mode. This will make sure
            // that the window size is _first_ set up as something sensible, so
            // leaving fullscreen returns to a reasonable size.
            const auto launchMode = this->GetLaunchMode();
            if (_WindowProperties->IsQuakeWindow() || WI_IsFlagSet(launchMode, LaunchMode::FocusMode))
            {
                _root->SetFocusMode(true);
            }

            // The IslandWindow handles (creating) the maximized state
            // we just want to record it here on the page as well.
            if (WI_IsFlagSet(launchMode, LaunchMode::MaximizedMode))
            {
                _root->Maximized(true);
            }

            if (WI_IsFlagSet(launchMode, LaunchMode::FullscreenMode) && !_WindowProperties->IsQuakeWindow())
            {
                _root->SetFullscreen(true);
            }

            AppLogic::Current()->NotifyRootInitialized();
        });
        _root->Create();

        _RefreshThemeRoutine();

        auto args = winrt::make_self<SystemMenuChangeArgs>(RS_(L"SettingsMenuItem"),
                                                           SystemMenuChangeAction::Add,
                                                           SystemMenuItemHandler(this, &TerminalWindow::_OpenSettingsUI));
        _SystemMenuChangeRequestedHandlers(*this, *args);

        TraceLoggingWrite(
            g_hTerminalAppProvider,
            "WindowCreated",
            TraceLoggingDescription("Event emitted when the window is started"),
            TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
            TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
    }
    void TerminalWindow::Quit()
    {
        if (_root)
        {
            _root->CloseWindow(true);
        }
    }