mirror of
https://github.com/microsoft/terminal.git
synced 2026-04-08 23:31:03 +00:00
RegisterBigTimeEncapsulationViolatingTerminalPaneContentEvents
This commit is contained in:
@@ -1731,11 +1731,8 @@ namespace winrt::TerminalApp::implementation
|
||||
// Add an event handler for when the terminal or tab wants to set a
|
||||
// progress indicator on the taskbar
|
||||
hostingTab.TaskbarProgressChanged({ get_weak(), &TerminalPage::_SetTaskbarProgressHandler });
|
||||
}
|
||||
|
||||
void TerminalPage::_RegisterPaneEvents(const TerminalApp::TerminalPaneContent& paneContent)
|
||||
{
|
||||
paneContent.RestartTerminalRequested({ get_weak(), &TerminalPage::_restartPaneConnection });
|
||||
hostingTab.RestartTerminalRequested({ get_weak(), &TerminalPage::_restartPaneConnection });
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -2384,16 +2381,6 @@ namespace winrt::TerminalApp::implementation
|
||||
_UnZoomIfNeeded();
|
||||
auto [original, _] = activeTab->SplitPane(*realSplitType, splitSize, newPane);
|
||||
|
||||
// When we split the pane, the Pane itself will create a _new_ Pane
|
||||
// instance for the original content. We need to make sure we also
|
||||
// re-add our event handler to that newly created pane.
|
||||
//
|
||||
// _MakePane will already call this for the newly created pane.
|
||||
if (const auto& paneContent{ original->GetContent().try_as<TerminalPaneContent>() })
|
||||
{
|
||||
_RegisterPaneEvents(*paneContent);
|
||||
}
|
||||
|
||||
// After GH#6586, the control will no longer focus itself
|
||||
// automatically when it's finished being laid out. Manually focus
|
||||
// the control here instead.
|
||||
@@ -3204,8 +3191,6 @@ namespace winrt::TerminalApp::implementation
|
||||
original->SetActive();
|
||||
}
|
||||
|
||||
_RegisterPaneEvents(paneContent);
|
||||
|
||||
return resultPane;
|
||||
}
|
||||
|
||||
|
||||
@@ -345,7 +345,6 @@ namespace winrt::TerminalApp::implementation
|
||||
void _InitializeTab(winrt::com_ptr<TerminalTab> newTabImpl, uint32_t insertPosition = -1);
|
||||
void _RegisterTerminalEvents(Microsoft::Terminal::Control::TermControl term);
|
||||
void _RegisterTabEvents(TerminalTab& hostingTab);
|
||||
void _RegisterPaneEvents(const TerminalApp::TerminalPaneContent& paneContent);
|
||||
|
||||
void _DismissTabContextMenus();
|
||||
void _FocusCurrentTab(const bool focusAlways);
|
||||
|
||||
@@ -904,7 +904,6 @@ namespace winrt::TerminalApp::implementation
|
||||
if (it != _contentEvents.end())
|
||||
{
|
||||
// revoke the event handlers by resetting the event struct
|
||||
it->second = {};
|
||||
// and remove it from the map
|
||||
_contentEvents.erase(paneId);
|
||||
}
|
||||
@@ -1060,6 +1059,11 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
});
|
||||
|
||||
if (const auto& terminal{ content.try_as<TerminalApp::TerminalPaneContent>() })
|
||||
{
|
||||
events.RestartTerminalRequested = terminal.RestartTerminalRequested(winrt::auto_revoke, { get_weak(), &TerminalTab::_bubbleRestartTerminalRequested });
|
||||
}
|
||||
|
||||
if (_tabStatus.IsInputBroadcastActive())
|
||||
{
|
||||
if (const auto& termContent{ content.try_as<TerminalApp::TerminalPaneContent>() })
|
||||
@@ -1998,4 +2002,9 @@ namespace winrt::TerminalApp::implementation
|
||||
ActionAndArgs actionAndArgs{ ShortcutAction::Find, nullptr };
|
||||
_dispatch.DoAction(*this, actionAndArgs);
|
||||
}
|
||||
void TerminalTab::_bubbleRestartTerminalRequested(TerminalApp::TerminalPaneContent sender,
|
||||
const winrt::Windows::Foundation::IInspectable& args)
|
||||
{
|
||||
RestartTerminalRequested.raise(sender, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,8 @@ namespace winrt::TerminalApp::implementation
|
||||
return _tabStatus;
|
||||
}
|
||||
|
||||
til::typed_event<TerminalApp::TerminalPaneContent> RestartTerminalRequested;
|
||||
|
||||
WINRT_CALLBACK(ActivePaneChanged, winrt::delegate<>);
|
||||
WINRT_CALLBACK(TabRaiseVisualBell, winrt::delegate<>);
|
||||
TYPED_EVENT(TaskbarProgressChanged, IInspectable, IInspectable);
|
||||
@@ -138,6 +140,8 @@ namespace winrt::TerminalApp::implementation
|
||||
winrt::Microsoft::Terminal::Control::TermControl::KeySent_revoker KeySent;
|
||||
winrt::Microsoft::Terminal::Control::TermControl::CharSent_revoker CharSent;
|
||||
winrt::Microsoft::Terminal::Control::TermControl::StringSent_revoker StringSent;
|
||||
|
||||
winrt::TerminalApp::TerminalPaneContent::RestartTerminalRequested_revoker RestartTerminalRequested;
|
||||
};
|
||||
std::unordered_map<uint32_t, ContentEventTokens> _contentEvents;
|
||||
|
||||
@@ -196,6 +200,8 @@ namespace winrt::TerminalApp::implementation
|
||||
void _moveTabToNewWindowClicked(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
|
||||
void _findClicked(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
|
||||
|
||||
void _bubbleRestartTerminalRequested(TerminalApp::TerminalPaneContent sender, const winrt::Windows::Foundation::IInspectable& args);
|
||||
|
||||
friend class ::TerminalAppLocalTests::TabTests;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user