A tab should be able to be created without a pane, and this works for that

This commit is contained in:
Mike Griese
2022-06-23 15:27:01 -05:00
parent eb4b2a7534
commit 19605bf75b
4 changed files with 48 additions and 24 deletions

View File

@@ -128,7 +128,7 @@ namespace winrt::TerminalApp::implementation
// - newTabImpl: the uninitialized tab.
void TerminalPage::_InitializeTab(winrt::com_ptr<TerminalTab> newTabImpl)
{
newTabImpl->Initialize();
// newTabImpl->Initialize();
// Add the new tab to the list of our tabs.
_tabs.Append(*newTabImpl);
@@ -228,13 +228,17 @@ namespace winrt::TerminalApp::implementation
_tabView.TabItems().Append(tabViewItem);
// Set this tab's icon to the icon from the user's profile
if (const auto profile{ newTabImpl->GetFocusedProfile() })
{
if (!profile.Icon().empty())
{
newTabImpl->UpdateIcon(profile.Icon());
}
}
//
// TODO! This doesn't need ot live in TerminalPage like, at all. This
// should get moved inside TerminalTab::AttachRootPane, or
// TerminalTab::Initialize or something.
// if (const auto profile{ newTabImpl->GetFocusedProfile() })
// {
// if (!profile.Icon().empty())
// {
// newTabImpl->UpdateIcon(profile.Icon());
// }
// }
tabViewItem.PointerReleased({ this, &TerminalPage::_OnTabClick });
@@ -288,11 +292,15 @@ namespace winrt::TerminalApp::implementation
TerminalSettingsCreateResult controlSettings,
Profile profile)
{
const auto initial = _startupState <= StartupState::InStartup;
if (!initial)
{
co_await winrt::resume_background();
}
auto newTabImpl = winrt::make_self<TerminalTab>(nullptr);
_InitializeTab(newTabImpl); // Adds tab to list, tabview
// const auto initial = _startupState <= StartupState::InStartup;
// if (!initial)
// {
// TODO! Do we need both this and the resume_background in _CreateNewContentProcess
co_await winrt::resume_background();
// }
auto content = co_await initContentProc;
// if (!initial)
// {
@@ -300,8 +308,7 @@ namespace winrt::TerminalApp::implementation
// }
auto pane = _makePaneFromContent(content, controlSettings, profile);
auto newTabImpl = winrt::make_self<TerminalTab>(pane);
_InitializeTab(newTabImpl);
newTabImpl->AttachRootPane(pane);
}
// Method Description:

View File

@@ -718,6 +718,7 @@ namespace winrt::TerminalApp::implementation
// we're readying to accept a defterm connection. In that case, we don't
// have a tab yet, but will once we're initialized.
const bool startedElevated = false;
// TODO!
if ((_tabs.Size() == 0 && startedElevated) && !(_shouldStartInboundListener || _isEmbeddingInboundListener))
{
_LastTabClosedHandlers(*this, nullptr);

View File

@@ -27,6 +27,17 @@ namespace winrt::TerminalApp::implementation
{
TerminalTab::TerminalTab(std::shared_ptr<Pane> rootPane)
{
if (rootPane != nullptr)
{
AttachRootPane(rootPane);
}
_Setup();
}
void TerminalTab::AttachRootPane(std::shared_ptr<Pane> rootPane)
{
assert(_rootPane == nullptr);
_rootPane = rootPane;
_activePane = nullptr;
@@ -60,7 +71,13 @@ namespace winrt::TerminalApp::implementation
_mruPanes.insert(_mruPanes.begin(), id.value());
}
_Setup();
_rootClosedToken = _rootPane->Closed([=](auto&& /*s*/, auto&& /*e*/) {
_ClosedHandlers(nullptr, nullptr);
});
Content(_rootPane->GetRootElement());
Initialize();
}
// Method Description:
@@ -71,12 +88,6 @@ namespace winrt::TerminalApp::implementation
// - <none>
void TerminalTab::_Setup()
{
_rootClosedToken = _rootPane->Closed([=](auto&& /*s*/, auto&& /*e*/) {
_ClosedHandlers(nullptr, nullptr);
});
Content(_rootPane->GetRootElement());
_MakeTabViewItem();
_CreateContextMenu();
@@ -379,6 +390,10 @@ namespace winrt::TerminalApp::implementation
{
return _runtimeTabText;
}
if (!_activePane)
{
return L"";
}
if (!_activePane->_IsLeaf())
{
return RS_(L"MultiplePanes");
@@ -864,7 +879,7 @@ namespace winrt::TerminalApp::implementation
}
});
events.taskbarToken = control.SetTaskbarProgress([dispatcher, weakThis](auto&&, auto&&) -> winrt::fire_and_forget {
events.taskbarToken = control.SetTaskbarProgress([dispatcher, weakThis](auto&&, auto &&) -> winrt::fire_and_forget {
co_await wil::resume_foreground(dispatcher);
// Check if Tab's lifetime has expired
if (auto tab{ weakThis.get() })
@@ -1069,7 +1084,7 @@ namespace winrt::TerminalApp::implementation
// Add a Closed event handler to the Pane. If the pane closes out from
// underneath us, and it's zoomed, we want to be able to make sure to
// update our state accordingly to un-zoom that pane. See GH#7252.
auto closedToken = pane->Closed([weakThis, weakPane](auto&& /*s*/, auto&& /*e*/) -> winrt::fire_and_forget {
auto closedToken = pane->Closed([weakThis, weakPane](auto&& /*s*/, auto && /*e*/) -> winrt::fire_and_forget {
if (auto tab{ weakThis.get() })
{
if (tab->_zoomedPane)

View File

@@ -36,6 +36,7 @@ namespace winrt::TerminalApp::implementation
std::shared_ptr<Pane> DetachRoot();
std::shared_ptr<Pane> DetachPane();
void AttachPane(std::shared_ptr<Pane> pane);
void AttachRootPane(std::shared_ptr<Pane> rootPane);
void SplitPane(winrt::Microsoft::Terminal::Settings::Model::SplitDirection splitType,
const float splitSize,