mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 18:43:54 -06:00
Replace tab.ActivePaneChanged handler with a method (#17331)
I noticed this while working on #17330. We're constructing a whole lambda just to do this wacky weak_ref logic, and that feels... gross. We should just make this a bound method and a typed event, so we can just use the one event handler regardless
This commit is contained in:
parent
ecb5631476
commit
01e4df152e
@ -136,26 +136,7 @@ namespace winrt::TerminalApp::implementation
|
||||
// When the tab's active pane changes, we'll want to lookup a new icon
|
||||
// for it. The Title change will be propagated upwards through the tab's
|
||||
// PropertyChanged event handler.
|
||||
newTabImpl->ActivePaneChanged([weakTab, weakThis{ get_weak() }]() {
|
||||
auto page{ weakThis.get() };
|
||||
auto tab{ weakTab.get() };
|
||||
|
||||
if (page && tab)
|
||||
{
|
||||
// Possibly update the icon of the tab.
|
||||
page->_UpdateTabIcon(*tab);
|
||||
|
||||
page->_updateThemeColors();
|
||||
|
||||
// Update the taskbar progress as well. We'll raise our own
|
||||
// SetTaskbarProgress event here, to get tell the hosting
|
||||
// application to re-query this value from us.
|
||||
page->SetTaskbarProgress.raise(*page, nullptr);
|
||||
|
||||
auto profile = tab->GetFocusedProfile();
|
||||
page->_UpdateBackground(profile);
|
||||
}
|
||||
});
|
||||
newTabImpl->ActivePaneChanged({ get_weak(), &TerminalPage::_activePaneChanged });
|
||||
|
||||
// The RaiseVisualBell event has been bubbled up to here from the pane,
|
||||
// the next part of the chain is bubbling up to app logic, which will
|
||||
|
||||
@ -2237,6 +2237,29 @@ namespace winrt::TerminalApp::implementation
|
||||
return true;
|
||||
}
|
||||
|
||||
// When the tab's active pane changes, we'll want to lookup a new icon
|
||||
// for it. The Title change will be propagated upwards through the tab's
|
||||
// PropertyChanged event handler.
|
||||
void TerminalPage::_activePaneChanged(winrt::TerminalApp::TerminalTab sender,
|
||||
Windows::Foundation::IInspectable args)
|
||||
{
|
||||
if (const auto tab{ _GetTerminalTabImpl(sender) })
|
||||
{
|
||||
// Possibly update the icon of the tab.
|
||||
_UpdateTabIcon(*tab);
|
||||
|
||||
_updateThemeColors();
|
||||
|
||||
// Update the taskbar progress as well. We'll raise our own
|
||||
// SetTaskbarProgress event here, to get tell the hosting
|
||||
// application to re-query this value from us.
|
||||
SetTaskbarProgress.raise(*this, nullptr);
|
||||
|
||||
auto profile = tab->GetFocusedProfile();
|
||||
_UpdateBackground(profile);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t TerminalPage::NumberOfTabs() const
|
||||
{
|
||||
return _tabs.Size();
|
||||
|
||||
@ -542,6 +542,8 @@ namespace winrt::TerminalApp::implementation
|
||||
winrt::Microsoft::Terminal::Control::TermControl _senderOrActiveControl(const winrt::Windows::Foundation::IInspectable& sender);
|
||||
winrt::com_ptr<TerminalTab> _senderOrFocusedTab(const IInspectable& sender);
|
||||
|
||||
void _activePaneChanged(winrt::TerminalApp::TerminalTab tab, Windows::Foundation::IInspectable args);
|
||||
|
||||
#pragma region ActionHandlers
|
||||
// These are all defined in AppActionHandlers.cpp
|
||||
#define ON_ALL_ACTIONS(action) DECLARE_ACTION_HANDLER(action);
|
||||
|
||||
@ -1242,7 +1242,7 @@ namespace winrt::TerminalApp::implementation
|
||||
_RecalculateAndApplyReadOnly();
|
||||
|
||||
// Raise our own ActivePaneChanged event.
|
||||
ActivePaneChanged.raise();
|
||||
ActivePaneChanged.raise(*this, nullptr);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
||||
@ -99,7 +99,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
til::typed_event<TerminalApp::TerminalPaneContent> RestartTerminalRequested;
|
||||
|
||||
til::event<winrt::delegate<>> ActivePaneChanged;
|
||||
til::typed_event<TerminalApp::TerminalTab, IInspectable> ActivePaneChanged;
|
||||
til::event<winrt::delegate<>> TabRaiseVisualBell;
|
||||
til::typed_event<IInspectable, IInspectable> TaskbarProgressChanged;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user