make sure event handlers get replaced, too
This commit is contained in:
parent
fdc574929b
commit
5253c114ae
|
@ -847,14 +847,17 @@ bool Pane::SwapPanes(std::shared_ptr<Pane> first, std::shared_ptr<Pane> second)
|
|||
return false;
|
||||
}
|
||||
|
||||
winrt::Windows::UI::Xaml::Controls::UserControl Pane::ReplaceControl(const winrt::Windows::UI::Xaml::Controls::UserControl& control)
|
||||
Controls::UserControl Pane::ReplaceControl(const Controls::UserControl& control)
|
||||
{
|
||||
if (!_IsLeaf())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Remove old control's event handlers
|
||||
const auto& oldControl = _control;
|
||||
_gotFocusRevoker.revoke();
|
||||
_lostFocusRevoker.revoke();
|
||||
if (const auto& oldTermControl{ _control.try_as<TermControl>() })
|
||||
{
|
||||
oldTermControl.ConnectionStateChanged(_connectionStateChangedToken);
|
||||
|
@ -862,7 +865,13 @@ winrt::Windows::UI::Xaml::Controls::UserControl Pane::ReplaceControl(const winrt
|
|||
}
|
||||
|
||||
_control = control;
|
||||
|
||||
_borderFirst.Child(_control);
|
||||
|
||||
// Register an event with the control to have it inform us when it gains focus.
|
||||
_gotFocusRevoker = _control.GotFocus(winrt::auto_revoke, { this, &Pane::_ControlGotFocusHandler });
|
||||
_lostFocusRevoker = _control.LostFocus(winrt::auto_revoke, { this, &Pane::_ControlLostFocusHandler });
|
||||
|
||||
if (const auto& termControl{ _control.try_as<TermControl>() })
|
||||
{
|
||||
_connectionStateChangedToken = termControl.ConnectionStateChanged({ this, &Pane::_ControlConnectionStateChangedHandler });
|
||||
|
|
|
@ -1612,7 +1612,7 @@ namespace winrt::TerminalApp::implementation
|
|||
{
|
||||
// NOTE: For debugging purposes, changing this to `true || IsElevated()`
|
||||
// is a handy way of forcing the elevation logic, even when unelevated.
|
||||
if (IsElevated())
|
||||
if (true || IsElevated())
|
||||
{
|
||||
// If the cmdline is EXACTLY an executable in
|
||||
// `C:\WINDOWS\System32`, then ignore this check.
|
||||
|
@ -1662,11 +1662,7 @@ namespace winrt::TerminalApp::implementation
|
|||
{
|
||||
// Go ahead and allow them. Swap the control into
|
||||
// the pane, which will initialize and start it.
|
||||
pane->ReplaceControl(otherWarning->Control());
|
||||
// Update the title, because replacing the control like
|
||||
// this is a little weird, and doesn't actually trigger
|
||||
// a TitleChanged by itself.
|
||||
tabImpl->UpdateTitle();
|
||||
tabImpl->ReplaceControl(pane, otherWarning->Control());
|
||||
}
|
||||
// Don't return true here. We want to make sure to check
|
||||
// all the panes for the same commandline we just
|
||||
|
|
|
@ -516,10 +516,9 @@ namespace winrt::TerminalApp::implementation
|
|||
p->Id(_nextPaneId);
|
||||
if (auto termControl{ p->_control.try_as<TermControl>() })
|
||||
{
|
||||
// TODO! make sure that the event handlers are still wired up for splitting a pane that creates an unapproved commandline, I don't think they are.
|
||||
_AttachEventHandlersToControl(p->Id().value(), termControl);
|
||||
}
|
||||
|
||||
|
||||
_nextPaneId++;
|
||||
}
|
||||
return false;
|
||||
|
@ -1756,6 +1755,19 @@ namespace winrt::TerminalApp::implementation
|
|||
return Title();
|
||||
}
|
||||
|
||||
void TerminalTab::ReplaceControl(std::shared_ptr<Pane> pane, const Controls::UserControl& control)
|
||||
{
|
||||
pane->ReplaceControl(control);
|
||||
|
||||
if (auto termControl{ pane->_control.try_as<TermControl>() })
|
||||
{
|
||||
_AttachEventHandlersToControl(pane->Id().value(), termControl);
|
||||
}
|
||||
|
||||
// Update the title manually.
|
||||
UpdateTitle();
|
||||
}
|
||||
|
||||
DEFINE_EVENT(TerminalTab, ActivePaneChanged, _ActivePaneChangedHandlers, winrt::delegate<>);
|
||||
DEFINE_EVENT(TerminalTab, ColorSelected, _colorSelected, winrt::delegate<winrt::Windows::UI::Color>);
|
||||
DEFINE_EVENT(TerminalTab, ColorCleared, _colorCleared, winrt::delegate<>);
|
||||
|
|
|
@ -93,6 +93,9 @@ namespace winrt::TerminalApp::implementation
|
|||
|
||||
std::shared_ptr<Pane> GetRootPane() const { return _rootPane; }
|
||||
|
||||
void ReplaceControl(std::shared_ptr<Pane> pane,
|
||||
const winrt::Windows::UI::Xaml::Controls::UserControl& control);
|
||||
|
||||
winrt::TerminalApp::TerminalTabStatus TabStatus()
|
||||
{
|
||||
return _tabStatus;
|
||||
|
|
Loading…
Reference in a new issue