Skip to content

Commit

Permalink
This nearly works, I just need to correctly identify the activated pane
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Oct 13, 2020
1 parent 6f05114 commit 4a67a5a
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cascadia/TerminalApp/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,15 @@ void Pane::_ControlConnectionStateChangedHandler(const TermControl& /*sender*/,
if ((mode == winrt::TerminalApp::CloseOnExitMode::Always) ||
(mode == winrt::TerminalApp::CloseOnExitMode::Graceful && newConnectionState == ConnectionState::Closed))
{
// We need to call Restore on the root of the tree, or at least our
// parent, to get us re-added ot their content. However, we also
// want to close our content here too, and remove it from the UI
// tree.

// if (_zoomed)
// {
// Restore(shared_from_this());
// };
_ClosedHandlers(nullptr, nullptr);
}
}
Expand Down
35 changes: 35 additions & 0 deletions src/cascadia/TerminalApp/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,41 @@ namespace winrt::TerminalApp::implementation
tab->_RecalculateAndApplyTabColor();
}
});

pane->Closed([weakThis](auto&& /*s*/, auto && /*e*/) -> winrt::fire_and_forget {
if (auto tab{ weakThis.get() })
{
if (tab->_zoomedPane)
{
co_await winrt::resume_foreground(tab->GetRootElement().Dispatcher());
tab->ExitZoom();
tab->Content(tab->GetRootElement());
// if (tab->_focused)
// {
// tab->_Focus();
// }
// tab->_UpdateActivePane(tab->_rootPane->GetActivePane());
}

// OKAY I see what's happening here the ActivePaneChanged
// Handler in TerminalPage doesn't re-attach the tab content to
// the tree, it just updates hte title of the window.
//
// So when the pane is `exit`ed, the pane's control is removed
// and re-attached to the parent grid, which _isn't in the XAML
// tree_. And no one can go tell the TerminalPage that it needs
// to re set up the tab content again.
//
// The Page _manually_ does this in a few places, when various
// pane actions are about to take place, it'll unzoom. It would
// be way easier if the Tab could just manage the content of the
// page.
//
// Or if the Tab just had a Content that was observable, that
// when that changed, the page would auto readjust. That does
// sound like a LOT of work though.
}
});
}

// Method Description:
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalApp/Tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ namespace winrt::TerminalApp::implementation
// This is needed since Tab is going to be managing its own SwitchToTab command.
OBSERVABLE_GETSET_PROPERTY(uint32_t, TabViewIndex, _PropertyChangedHandlers, 0);

OBSERVABLE_GETSET_PROPERTY(winrt::Windows::UI::Xaml::UIElement, Content, _PropertyChangedHandlers, nullptr);

private:
std::shared_ptr<Pane> _rootPane{ nullptr };
std::shared_ptr<Pane> _activePane{ nullptr };
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalApp/Tab.idl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ namespace TerminalApp
Windows.UI.Xaml.Controls.IconSource IconSource { get; };
Command SwitchToTabCommand { get; };
UInt32 TabViewIndex { get; };

Windows.UI.Xaml.UIElement Content { get; };
}
}
10 changes: 10 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,16 @@ namespace winrt::TerminalApp::implementation
{
page->_UpdateTitle(*tab);
}
else if (args.PropertyName() == L"Content")
{
if (tab == page->_GetFocusedTab())
{
page->_tabContent.Children().Clear();
page->_tabContent.Children().Append(tab->Content());

tab->SetFocused(true);
}
}
}
});

Expand Down

1 comment on commit 4a67a5a

@github-actions

This comment was marked as outdated.

Please sign in to comment.