mirror of
https://github.com/microsoft/terminal.git
synced 2026-07-09 02:26:45 +00:00
The first tab now opens out-of-proc too
We're gonna definitely run into a lot of pain here. Like, the initialization finishes now bbefore the tabs are created, so the "no tabs got opened" check needs to be changed. I don't think I need both resume_bg's in CreateContent and also in AsyncCreateTab
This commit is contained in:
@@ -72,10 +72,10 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
return S_FALSE;
|
||||
}
|
||||
const auto settings{ TerminalSettings::CreateWithNewTerminalArgs(_settings, newTerminalArgs, *_bindings) };
|
||||
const auto controlSettings{ TerminalSettings::CreateWithNewTerminalArgs(_settings, newTerminalArgs, *_bindings) };
|
||||
|
||||
// Try to handle auto-elevation
|
||||
if (_maybeElevate(newTerminalArgs, settings, profile))
|
||||
if (_maybeElevate(newTerminalArgs, controlSettings, profile))
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
@@ -83,10 +83,15 @@ namespace winrt::TerminalApp::implementation
|
||||
// unfortunately. This seems to be due to Centennial quirks. It works
|
||||
// unpackaged, but not packaged.
|
||||
//
|
||||
// This call to _MakePane won't return nullptr, we already checked that
|
||||
// case above with the _maybeElevate call.
|
||||
_CreateNewTabFromPane(_MakePane(newTerminalArgs, false, nullptr));
|
||||
// // This call to _MakePane won't return nullptr, we already checked that
|
||||
// // case above with the _maybeElevate call.
|
||||
// _CreateNewTabFromPane(_MakePane(newTerminalArgs, false, nullptr));
|
||||
|
||||
// TerminalSettingsCreateResult controlSettings{ nullptr };
|
||||
// Profile profile{ nullptr };
|
||||
// _evaluateSettings(newTerminalArgs, false /*duplicate*/, controlSettings, profile);
|
||||
auto initContentProc = _CreateNewContentProcess(profile, controlSettings);
|
||||
_createNewTabFromContent(initContentProc, controlSettings, profile);
|
||||
// const auto tabCount = _tabs.Size();
|
||||
// const auto usedManualProfile = (newTerminalArgs != nullptr) &&
|
||||
// (newTerminalArgs.ProfileIndex() != nullptr ||
|
||||
@@ -279,6 +284,26 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
}
|
||||
|
||||
winrt::fire_and_forget TerminalPage::_createNewTabFromContent(Windows::Foundation::IAsyncOperation<ContentProcess> initContentProc,
|
||||
TerminalSettingsCreateResult controlSettings,
|
||||
Profile profile)
|
||||
{
|
||||
const auto initial = _startupState <= StartupState::InStartup;
|
||||
if (!initial)
|
||||
{
|
||||
co_await winrt::resume_background();
|
||||
}
|
||||
auto content = co_await initContentProc;
|
||||
// if (!initial)
|
||||
// {
|
||||
co_await wil::resume_foreground(Dispatcher(), CoreDispatcherPriority::High);
|
||||
// }
|
||||
|
||||
auto pane = _makePaneFromContent(content, controlSettings, profile);
|
||||
auto newTabImpl = winrt::make_self<TerminalTab>(pane);
|
||||
_InitializeTab(newTabImpl);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Get the icon of the currently focused terminal control, and set its
|
||||
// tab's icon to that icon.
|
||||
|
||||
@@ -717,7 +717,8 @@ namespace winrt::TerminalApp::implementation
|
||||
// GH#12267: Make sure that we don't instantly close ourselves when
|
||||
// we're readying to accept a defterm connection. In that case, we don't
|
||||
// have a tab yet, but will once we're initialized.
|
||||
if (_tabs.Size() == 0 && !(_shouldStartInboundListener || _isEmbeddingInboundListener))
|
||||
const bool startedElevated = false;
|
||||
if ((_tabs.Size() == 0 && startedElevated) && !(_shouldStartInboundListener || _isEmbeddingInboundListener))
|
||||
{
|
||||
_LastTabClosedHandlers(*this, nullptr);
|
||||
}
|
||||
@@ -2689,6 +2690,19 @@ namespace winrt::TerminalApp::implementation
|
||||
return content;
|
||||
}
|
||||
|
||||
// INVARIANT: Must be called on UI thread!
|
||||
std::shared_ptr<Pane> TerminalPage::_makePaneFromContent(ContentProcess content,
|
||||
TerminalSettingsCreateResult controlSettings,
|
||||
Profile profile)
|
||||
{
|
||||
// Create the XAML control that will be attached to the content process.
|
||||
// We're not passing in a connection, because the contentGuid will be used instead
|
||||
const auto control = _InitControl(controlSettings, content.Guid());
|
||||
_RegisterTerminalEvents(control);
|
||||
|
||||
return std::make_shared<Pane>(profile, control);
|
||||
}
|
||||
|
||||
TermControl TerminalPage::_InitControl(const TerminalSettingsCreateResult& settings, const ITerminalConnection& connection)
|
||||
{
|
||||
// Do any initialization that needs to apply to _every_ TermControl we
|
||||
|
||||
@@ -449,6 +449,15 @@ namespace winrt::TerminalApp::implementation
|
||||
Windows::Foundation::IAsyncOperation<winrt::Microsoft::Terminal::Control::ContentProcess> _CreateNewContentProcess(winrt::Microsoft::Terminal::Settings::Model::Profile profile,
|
||||
winrt::Microsoft::Terminal::Settings::Model::TerminalSettingsCreateResult settings);
|
||||
winrt::Microsoft::Terminal::Control::ContentProcess _AttachToContentProcess(const winrt::guid contentGuid);
|
||||
|
||||
winrt::fire_and_forget _createNewTabFromContent(Windows::Foundation::IAsyncOperation<winrt::Microsoft::Terminal::Control::ContentProcess> initContentProc,
|
||||
winrt::Microsoft::Terminal::Settings::Model::TerminalSettingsCreateResult controlSettings,
|
||||
winrt::Microsoft::Terminal::Settings::Model::Profile profile);
|
||||
|
||||
std::shared_ptr<Pane> _makePaneFromContent(winrt::Microsoft::Terminal::Control::ContentProcess initContentProc,
|
||||
winrt::Microsoft::Terminal::Settings::Model::TerminalSettingsCreateResult controlSettings,
|
||||
winrt::Microsoft::Terminal::Settings::Model::Profile profile);
|
||||
|
||||
winrt::Microsoft::Terminal::Control::TermControl _InitControl(const winrt::Microsoft::Terminal::Settings::Model::TerminalSettingsCreateResult& settings,
|
||||
const winrt::guid& contentGuid);
|
||||
winrt::Microsoft::Terminal::Control::ContentProcess _InBackgroundMakeContent(const winrt::Microsoft::Terminal::Settings::Model::NewTerminalArgs& newTerminalArgs,
|
||||
|
||||
Reference in New Issue
Block a user