Merge remote-tracking branch 'origin/dev/migrie/til-events-for-all' into dev/migrie/fhl/2024-spring-merge-base

This commit is contained in:
Mike Griese 2024-03-08 10:52:08 -06:00
commit 5343d560b0
106 changed files with 671 additions and 567 deletions

View File

@ -95,8 +95,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
peasant.IdentifyWindowsRequested({ this, &Monarch::_identifyWindows });
peasant.RenameRequested({ this, &Monarch::_renameRequested });
peasant.ShowNotificationIconRequested([this](auto&&, auto&&) { _ShowNotificationIconRequestedHandlers(*this, nullptr); });
peasant.HideNotificationIconRequested([this](auto&&, auto&&) { _HideNotificationIconRequestedHandlers(*this, nullptr); });
peasant.ShowNotificationIconRequested([this](auto&&, auto&&) { ShowNotificationIconRequested.raise(*this, nullptr); });
peasant.HideNotificationIconRequested([this](auto&&, auto&&) { HideNotificationIconRequested.raise(*this, nullptr); });
peasant.QuitAllRequested({ this, &Monarch::_handleQuitAll });
{
@ -111,7 +111,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
TraceLoggingKeyword(TIL_KEYWORD_TRACE));
_WindowCreatedHandlers(nullptr, nullptr);
WindowCreated.raise(nullptr, nullptr);
return newPeasantsId;
}
catch (...)
@ -141,7 +141,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
// Let the process hosting the monarch run any needed logic before
// closing all windows.
auto args = winrt::make_self<implementation::QuitAllRequestedArgs>();
_QuitAllRequestedHandlers(*this, *args);
QuitAllRequested.raise(*this, *args);
if (const auto action = args->BeforeQuitAllAction())
{
@ -207,7 +207,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
std::unique_lock lock{ _peasantsMutex };
_peasants.erase(peasantId);
}
_WindowClosedHandlers(nullptr, nullptr);
WindowClosed.raise(nullptr, nullptr);
}
// Method Description:
@ -650,7 +650,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
auto findWindowArgs{ winrt::make_self<Remoting::implementation::FindTargetWindowArgs>(args) };
// This is handled by some handler in-proc
_FindTargetWindowRequestedHandlers(*this, *findWindowArgs);
FindTargetWindowRequested.raise(*this, *findWindowArgs);
// After the event was handled, ResultTargetWindow() will be filled with
// the parsed result.
@ -741,7 +741,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
result->WindowName(targetWindowName);
result->ShouldCreateWindow(true);
_RequestNewWindowHandlers(*this, *winrt::make_self<WindowRequestedArgs>(*result, args));
RequestNewWindow.raise(*this, *winrt::make_self<WindowRequestedArgs>(*result, args));
// If this fails, it'll be logged in the following
// TraceLoggingWrite statement, with succeeded=false
@ -779,7 +779,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
result->Id(windowID);
result->WindowName(targetWindowName);
_RequestNewWindowHandlers(*this, *winrt::make_self<WindowRequestedArgs>(*result, args));
RequestNewWindow.raise(*this, *winrt::make_self<WindowRequestedArgs>(*result, args));
return *result;
}
@ -796,7 +796,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
auto result = winrt::make_self<Remoting::implementation::ProposeCommandlineResult>(true);
result->WindowName(targetWindowName);
_RequestNewWindowHandlers(*this, *winrt::make_self<WindowRequestedArgs>(*result, args));
RequestNewWindow.raise(*this, *winrt::make_self<WindowRequestedArgs>(*result, args));
return *result;
}
@ -1115,7 +1115,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
auto request = winrt::make_self<implementation::WindowRequestedArgs>(nameIsReserved ? L"" : window,
content,
windowBounds);
_RequestNewWindowHandlers(*this, *request);
RequestNewWindow.raise(*this, *request);
}
}

View File

@ -101,14 +101,14 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
void RequestMoveContent(winrt::hstring window, winrt::hstring content, uint32_t tabIndex, const Windows::Foundation::IReference<Windows::Foundation::Rect>& windowBounds);
void RequestSendContent(const Remoting::RequestReceiveContentArgs& args);
TYPED_EVENT(FindTargetWindowRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::FindTargetWindowArgs);
TYPED_EVENT(ShowNotificationIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(HideNotificationIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(WindowCreated, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(WindowClosed, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(QuitAllRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::QuitAllRequestedArgs);
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::FindTargetWindowArgs> FindTargetWindowRequested;
til::typed_event<> ShowNotificationIconRequested;
til::typed_event<> HideNotificationIconRequested;
til::typed_event<> WindowCreated;
til::typed_event<> WindowClosed;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::QuitAllRequestedArgs> QuitAllRequested;
TYPED_EVENT(RequestNewWindow, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::WindowRequestedArgs);
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::WindowRequestedArgs> RequestNewWindow;
private:
uint64_t _ourPID;
@ -223,7 +223,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
// A peasant died, let the app host know that the number of
// windows has changed.
_WindowClosedHandlers(nullptr, nullptr);
WindowClosed.raise(nullptr, nullptr);
}
}

View File

@ -67,7 +67,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
// Raise an event with these args. The AppHost will listen for this
// event to know when to take these args and dispatch them to a
// currently-running window.
_ExecuteCommandlineRequestedHandlers(*this, args);
ExecuteCommandlineRequested.raise(*this, args);
return true;
}
@ -97,7 +97,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
// by the monarch. The monarch might have died. If they have, this
// will throw an exception. Just eat it, the election thread will
// handle hooking up the new one.
_WindowActivatedHandlers(*this, args);
WindowActivated.raise(*this, args);
successfullyNotified = true;
}
catch (...)
@ -146,7 +146,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
TraceLoggingKeyword(TIL_KEYWORD_TRACE));
_SummonRequestedHandlers(*this, localCopy);
SummonRequested.raise(*this, localCopy);
}
// Method Description:
@ -161,7 +161,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
{
// Not worried about try/catching this. The handler is in AppHost, which
// is in-proc for us.
_DisplayWindowIdRequestedHandlers(*this, nullptr);
DisplayWindowIdRequested.raise(*this, nullptr);
}
// Method Description:
@ -182,7 +182,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
// by the monarch. The monarch might have died. If they have, this
// will throw an exception. Just eat it, the election thread will
// handle hooking up the new one.
_IdentifyWindowsRequestedHandlers(*this, nullptr);
IdentifyWindowsRequested.raise(*this, nullptr);
successfullyNotified = true;
}
catch (...)
@ -207,7 +207,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
// by the monarch. The monarch might have died. If they have, this
// will throw an exception. Just eat it, the election thread will
// handle hooking up the new one.
_RenameRequestedHandlers(*this, args);
RenameRequested.raise(*this, args);
if (args.Succeeded())
{
_WindowName = args.NewName();
@ -233,7 +233,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
{
try
{
_ShowNotificationIconRequestedHandlers(*this, nullptr);
ShowNotificationIconRequested.raise(*this, nullptr);
}
catch (...)
{
@ -249,7 +249,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
{
try
{
_HideNotificationIconRequestedHandlers(*this, nullptr);
HideNotificationIconRequested.raise(*this, nullptr);
}
catch (...)
{
@ -265,7 +265,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
{
try
{
_QuitAllRequestedHandlers(*this, nullptr);
QuitAllRequested.raise(*this, nullptr);
}
catch (...)
{
@ -281,7 +281,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
{
try
{
_AttachRequestedHandlers(*this, request);
AttachRequested.raise(*this, request);
}
catch (...)
{
@ -297,7 +297,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
{
try
{
_QuitRequestedHandlers(*this, nullptr);
QuitRequested.raise(*this, nullptr);
}
catch (...)
{
@ -318,7 +318,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
hstring Peasant::GetWindowLayout()
{
auto args = winrt::make_self<implementation::GetWindowLayoutArgs>();
_GetWindowLayoutRequestedHandlers(nullptr, *args);
GetWindowLayoutRequested.raise(nullptr, *args);
if (const auto op = args->WindowLayoutJsonAsync())
{
// This will fail if called on the UI thread, so the monarch should
@ -331,6 +331,6 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
void Peasant::SendContent(const Remoting::RequestReceiveContentArgs& args)
{
_SendContentRequestedHandlers(*this, args);
SendContentRequested.raise(*this, args);
}
}

View File

@ -68,25 +68,25 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
winrt::hstring GetWindowLayout();
void SendContent(const winrt::Microsoft::Terminal::Remoting::RequestReceiveContentArgs& args);
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::WindowActivatedArgs> WindowActivated;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::CommandlineArgs> ExecuteCommandlineRequested;
til::typed_event<> IdentifyWindowsRequested;
til::typed_event<> DisplayWindowIdRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::RenameRequestArgs> RenameRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::SummonWindowBehavior> SummonRequested;
til::typed_event<> ShowNotificationIconRequested;
til::typed_event<> HideNotificationIconRequested;
til::typed_event<> QuitAllRequested;
til::typed_event<> QuitRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::GetWindowLayoutArgs> GetWindowLayoutRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::AttachRequest> AttachRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::RequestReceiveContentArgs> SendContentRequested;
WINRT_PROPERTY(winrt::hstring, WindowName);
WINRT_PROPERTY(winrt::hstring, ActiveTabTitle);
TYPED_EVENT(WindowActivated, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::WindowActivatedArgs);
TYPED_EVENT(ExecuteCommandlineRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::CommandlineArgs);
TYPED_EVENT(IdentifyWindowsRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(DisplayWindowIdRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(RenameRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::RenameRequestArgs);
TYPED_EVENT(SummonRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::SummonWindowBehavior);
TYPED_EVENT(ShowNotificationIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(HideNotificationIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(QuitAllRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(QuitRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(GetWindowLayoutRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::GetWindowLayoutArgs);
TYPED_EVENT(AttachRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::AttachRequest);
TYPED_EVENT(SendContentRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::RequestReceiveContentArgs);
private:
Peasant(const uint64_t testPID);
uint64_t _ourPID;

View File

@ -89,10 +89,10 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
// done when we become the king. This will be called both for the first
// window, and when the current monarch dies.
_monarch.WindowCreated({ get_weak(), &WindowManager::_WindowCreatedHandlers });
_monarch.WindowClosed({ get_weak(), &WindowManager::_WindowClosedHandlers });
_monarch.WindowCreated({ get_weak(), &WindowManager::_bubbleWindowCreated });
_monarch.WindowClosed({ get_weak(), &WindowManager::_bubbleWindowClosed });
_monarch.FindTargetWindowRequested({ this, &WindowManager::_raiseFindTargetWindowRequested });
_monarch.QuitAllRequested({ get_weak(), &WindowManager::_QuitAllRequestedHandlers });
_monarch.QuitAllRequested({ get_weak(), &WindowManager::_bubbleQuitAllRequested });
_monarch.RequestNewWindow({ get_weak(), &WindowManager::_raiseRequestNewWindow });
}
@ -109,12 +109,12 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
void WindowManager::_raiseFindTargetWindowRequested(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Microsoft::Terminal::Remoting::FindTargetWindowArgs& args)
{
_FindTargetWindowRequestedHandlers(sender, args);
FindTargetWindowRequested.raise(sender, args);
}
void WindowManager::_raiseRequestNewWindow(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Microsoft::Terminal::Remoting::WindowRequestedArgs& args)
{
_RequestNewWindowHandlers(sender, args);
RequestNewWindow.raise(sender, args);
}
Remoting::ProposeCommandlineResult WindowManager::ProposeCommandline(const Remoting::CommandlineArgs& args, const bool isolatedMode)
@ -162,7 +162,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
auto findWindowArgs{ winrt::make_self<Remoting::implementation::FindTargetWindowArgs>(args) };
// This is handled by some handler in-proc
_FindTargetWindowRequestedHandlers(*this, *findWindowArgs);
FindTargetWindowRequested.raise(*this, *findWindowArgs);
// After the event was handled, ResultTargetWindow() will be filled with
// the parsed result.
@ -356,7 +356,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
_monarch.AddPeasant(*p);
p->GetWindowLayoutRequested({ get_weak(), &WindowManager::_GetWindowLayoutRequestedHandlers });
p->GetWindowLayoutRequested({ get_weak(), &WindowManager::_bubbleGetWindowLayoutRequested });
TraceLoggingWrite(g_hRemotingProvider,
"WindowManager_CreateOurPeasant",
@ -367,6 +367,23 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
return *p;
}
void WindowManager::_bubbleGetWindowLayoutRequested(const winrt::Windows::Foundation::IInspectable& s, const winrt::Microsoft::Terminal::Remoting::GetWindowLayoutArgs& e)
{
GetWindowLayoutRequested.raise(s, e);
}
void WindowManager::_bubbleWindowCreated(const winrt::Windows::Foundation::IInspectable& s, const winrt::Windows::Foundation::IInspectable& e)
{
WindowCreated.raise(s, e);
}
void WindowManager::_bubbleWindowClosed(const winrt::Windows::Foundation::IInspectable& s, const winrt::Windows::Foundation::IInspectable& e)
{
WindowClosed.raise(s, e);
}
void WindowManager::_bubbleQuitAllRequested(const winrt::Windows::Foundation::IInspectable& s, const winrt::Microsoft::Terminal::Remoting::QuitAllRequestedArgs& e)
{
QuitAllRequested.raise(s, e);
}
void WindowManager::SignalClose(const Remoting::Peasant& peasant)
{
if (_monarch)

View File

@ -47,14 +47,13 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
winrt::fire_and_forget RequestMoveContent(winrt::hstring window, winrt::hstring content, uint32_t tabIndex, Windows::Foundation::IReference<Windows::Foundation::Rect> windowBounds);
winrt::fire_and_forget RequestSendContent(Remoting::RequestReceiveContentArgs args);
TYPED_EVENT(FindTargetWindowRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::FindTargetWindowArgs);
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::FindTargetWindowArgs> FindTargetWindowRequested;
TYPED_EVENT(WindowCreated, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(WindowClosed, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(QuitAllRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::QuitAllRequestedArgs);
TYPED_EVENT(GetWindowLayoutRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::GetWindowLayoutArgs);
TYPED_EVENT(RequestNewWindow, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::WindowRequestedArgs);
til::typed_event<> WindowCreated;
til::typed_event<> WindowClosed;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::QuitAllRequestedArgs> QuitAllRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::GetWindowLayoutArgs> GetWindowLayoutRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::WindowRequestedArgs> RequestNewWindow;
private:
DWORD _registrationHostClass{ 0 };
@ -70,6 +69,10 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
const winrt::Microsoft::Terminal::Remoting::FindTargetWindowArgs& args);
void _raiseRequestNewWindow(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Microsoft::Terminal::Remoting::WindowRequestedArgs& args);
void _bubbleWindowCreated(const winrt::Windows::Foundation::IInspectable& s, const winrt::Windows::Foundation::IInspectable& e);
void _bubbleWindowClosed(const winrt::Windows::Foundation::IInspectable& s, const winrt::Windows::Foundation::IInspectable& e);
void _bubbleQuitAllRequested(const winrt::Windows::Foundation::IInspectable& s, const winrt::Microsoft::Terminal::Remoting::QuitAllRequestedArgs& e);
void _bubbleGetWindowLayoutRequested(const winrt::Windows::Foundation::IInspectable& s, const winrt::Microsoft::Terminal::Remoting::GetWindowLayoutArgs& e);
};
}

View File

@ -15,9 +15,9 @@ namespace winrt::TerminalApp::implementation
winrt::hstring ApplicationDisplayName();
winrt::hstring ApplicationVersion();
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(bool, UpdatesAvailable, _PropertyChangedHandlers, false);
WINRT_OBSERVABLE_PROPERTY(bool, CheckingForUpdates, _PropertyChangedHandlers, false);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(bool, UpdatesAvailable, PropertyChanged.raise, false);
WINRT_OBSERVABLE_PROPERTY(bool, CheckingForUpdates, PropertyChanged.raise, false);
private:
friend struct AboutDialogT<AboutDialog>; // for Xaml to bind events

View File

@ -118,7 +118,7 @@ namespace winrt::TerminalApp::implementation
void TerminalPage::_HandleCloseWindow(const IInspectable& /*sender*/,
const ActionEventArgs& args)
{
_CloseRequestedHandlers(nullptr, nullptr);
CloseRequested.raise(nullptr, nullptr);
args.Handled(true);
}
@ -949,7 +949,7 @@ namespace winrt::TerminalApp::implementation
void TerminalPage::_HandleIdentifyWindows(const IInspectable& /*sender*/,
const ActionEventArgs& args)
{
_IdentifyWindowsRequestedHandlers(*this, nullptr);
IdentifyWindowsRequested.raise(*this, nullptr);
args.Handled(true);
}
@ -978,7 +978,7 @@ namespace winrt::TerminalApp::implementation
{
const auto newName = realArgs.Name();
const auto request = winrt::make_self<implementation::RenameWindowRequestedArgs>(newName);
_RenameWindowRequestedHandlers(*this, *request);
RenameWindowRequested.raise(*this, *request);
args.Handled(true);
}
}
@ -1148,7 +1148,7 @@ namespace winrt::TerminalApp::implementation
void TerminalPage::_HandleOpenSystemMenu(const IInspectable& /*sender*/,
const ActionEventArgs& args)
{
_OpenSystemMenuHandlers(*this, nullptr);
OpenSystemMenu.raise(*this, nullptr);
args.Handled(true);
}

View File

@ -423,7 +423,7 @@ namespace winrt::TerminalApp::implementation
_settingsLoadExceptionText,
warnings,
_settings);
_SettingsChangedHandlers(*this, *ev);
SettingsChanged.raise(*this, *ev);
return;
}
}
@ -452,7 +452,7 @@ namespace winrt::TerminalApp::implementation
_settingsLoadExceptionText,
warnings,
_settings);
_SettingsChangedHandlers(*this, *ev);
SettingsChanged.raise(*this, *ev);
}
// This is a continuation of AppLogic::Create() and includes the more expensive parts.

View File

@ -74,7 +74,7 @@ namespace winrt::TerminalApp::implementation
TerminalApp::ParseCommandlineResult GetParseCommandlineMessage(array_view<const winrt::hstring> args);
TYPED_EVENT(SettingsChanged, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::SettingsLoadEventArgs);
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::SettingsLoadEventArgs> SettingsChanged;
private:
bool _isElevated{ false };

View File

@ -32,7 +32,7 @@ namespace winrt::TerminalApp::implementation
{
auto button{ sender.as<Windows::UI::Xaml::Controls::Button>() };
auto rectClr{ button.Background().as<Windows::UI::Xaml::Media::SolidColorBrush>() };
_ColorSelectedHandlers(rectClr.Color());
ColorSelected.raise(rectClr.Color());
Hide();
}
@ -45,7 +45,7 @@ namespace winrt::TerminalApp::implementation
// - <none>
void ColorPickupFlyout::ClearColorButton_Click(const IInspectable&, const Windows::UI::Xaml::RoutedEventArgs&)
{
_ColorClearedHandlers();
ColorCleared.raise();
Hide();
}
@ -80,12 +80,12 @@ namespace winrt::TerminalApp::implementation
void ColorPickupFlyout::CustomColorButton_Click(const Windows::Foundation::IInspectable&, const Windows::UI::Xaml::RoutedEventArgs&)
{
auto color = customColorPicker().Color();
_ColorSelectedHandlers(color);
ColorSelected.raise(color);
Hide();
}
void ColorPickupFlyout::ColorPicker_ColorChanged(const Microsoft::UI::Xaml::Controls::ColorPicker&, const Microsoft::UI::Xaml::Controls::ColorChangedEventArgs& args)
{
_ColorSelectedHandlers(args.NewColor());
ColorSelected.raise(args.NewColor());
}
}

View File

@ -13,8 +13,8 @@ namespace winrt::TerminalApp::implementation
void ClearColorButton_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& args);
void ColorPicker_ColorChanged(const Microsoft::UI::Xaml::Controls::ColorPicker&, const Microsoft::UI::Xaml::Controls::ColorChangedEventArgs& args);
WINRT_CALLBACK(ColorCleared, TerminalApp::ColorClearedArgs);
WINRT_CALLBACK(ColorSelected, TerminalApp::ColorSelectedArgs);
til::event<TerminalApp::ColorClearedArgs> ColorCleared;
til::event<TerminalApp::ColorSelectedArgs> ColorSelected;
};
}

View File

@ -235,7 +235,7 @@ namespace winrt::TerminalApp::implementation
{
if (const auto actionPaletteItem{ filteredCommand.Item().try_as<winrt::TerminalApp::ActionPaletteItem>() })
{
_PreviewActionHandlers(*this, actionPaletteItem.Command());
PreviewAction.raise(*this, actionPaletteItem.Command());
}
}
else if (_currentMode == CommandPaletteMode::CommandlineMode)
@ -569,7 +569,7 @@ namespace winrt::TerminalApp::implementation
void CommandPalette::_moveBackButtonClicked(const Windows::Foundation::IInspectable& /*sender*/,
const Windows::UI::Xaml::RoutedEventArgs&)
{
_PreviewActionHandlers(*this, nullptr);
PreviewAction.raise(*this, nullptr);
_searchBox().Focus(FocusState::Programmatic);
const auto previousAction{ _nestedActionStack.GetAt(_nestedActionStack.Size() - 1) };
@ -714,7 +714,7 @@ namespace winrt::TerminalApp::implementation
// All other actions can just be dispatched.
if (actionPaletteItem.Command().ActionAndArgs().Action() != ShortcutAction::ToggleCommandPalette)
{
_DispatchCommandRequestedHandlers(*this, actionPaletteItem.Command());
DispatchCommandRequested.raise(*this, actionPaletteItem.Command());
}
TraceLoggingWrite(
@ -768,7 +768,7 @@ namespace winrt::TerminalApp::implementation
{
if (const auto tab{ tabPaletteItem.Tab() })
{
_SwitchToTabRequestedHandlers(*this, tab);
SwitchToTabRequested.raise(*this, tab);
}
}
}
@ -796,7 +796,7 @@ namespace winrt::TerminalApp::implementation
if (const auto commandLinePaletteItem{ filteredCommand.value().Item().try_as<winrt::TerminalApp::CommandLinePaletteItem>() })
{
_CommandLineExecutionRequestedHandlers(*this, commandLinePaletteItem.CommandLine());
CommandLineExecutionRequested.raise(*this, commandLinePaletteItem.CommandLine());
_close();
}
}
@ -1187,7 +1187,7 @@ namespace winrt::TerminalApp::implementation
{
Visibility(Visibility::Collapsed);
_PreviewActionHandlers(*this, nullptr);
PreviewAction.raise(*this, nullptr);
// Reset visibility in case anchor mode tab switcher just finished.
_searchBox().Visibility(Visibility::Visible);

View File

@ -48,18 +48,18 @@ namespace winrt::TerminalApp::implementation
void EnableTabSwitcherMode(const uint32_t startIdx, Microsoft::Terminal::Settings::Model::TabSwitcherMode tabSwitcherMode);
void EnableTabSearchMode();
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, NoMatchesText, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, SearchBoxPlaceholderText, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, PrefixCharacter, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ControlName, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ParentCommandName, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ParsedCommandLineText, _PropertyChangedHandlers);
til::property_changed_event PropertyChanged;
til::typed_event<winrt::TerminalApp::CommandPalette, winrt::TerminalApp::TabBase> SwitchToTabRequested;
til::typed_event<winrt::TerminalApp::CommandPalette, winrt::hstring> CommandLineExecutionRequested;
til::typed_event<winrt::TerminalApp::CommandPalette, Microsoft::Terminal::Settings::Model::Command> DispatchCommandRequested;
til::typed_event<Windows::Foundation::IInspectable, Microsoft::Terminal::Settings::Model::Command> PreviewAction;
TYPED_EVENT(SwitchToTabRequested, winrt::TerminalApp::CommandPalette, winrt::TerminalApp::TabBase);
TYPED_EVENT(CommandLineExecutionRequested, winrt::TerminalApp::CommandPalette, winrt::hstring);
TYPED_EVENT(DispatchCommandRequested, winrt::TerminalApp::CommandPalette, Microsoft::Terminal::Settings::Model::Command);
TYPED_EVENT(PreviewAction, Windows::Foundation::IInspectable, Microsoft::Terminal::Settings::Model::Command);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, NoMatchesText, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, SearchBoxPlaceholderText, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, PrefixCharacter, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ControlName, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ParentCommandName, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ParsedCommandLineText, PropertyChanged.raise);
private:
struct winrt_object_hash

View File

@ -62,7 +62,7 @@ namespace winrt::Microsoft::TerminalApp::implementation
{
_outputRevoker = wrappedConnection.TerminalOutput(winrt::auto_revoke, { this, &DebugTapConnection::_OutputHandler });
_stateChangedRevoker = wrappedConnection.StateChanged(winrt::auto_revoke, [this](auto&& /*s*/, auto&& /*e*/) {
_StateChangedHandlers(*this, nullptr);
StateChanged.raise(*this, nullptr);
});
_wrappedConnection = wrappedConnection;
}
@ -127,7 +127,7 @@ namespace winrt::Microsoft::TerminalApp::implementation
{
output.insert(++lfPos, L"\r\n");
}
_TerminalOutputHandlers(output);
TerminalOutput.raise(output);
}
// Called by the DebugInputTapConnection to print user input
@ -135,7 +135,7 @@ namespace winrt::Microsoft::TerminalApp::implementation
{
auto clean{ til::visualize_control_codes(str) };
auto formatted{ wil::str_printf<std::wstring>(L"\x1b[91m%ls\x1b[m", clean.data()) };
_TerminalOutputHandlers(formatted);
TerminalOutput.raise(formatted);
}
// Wire us up so that we can forward input through

View File

@ -25,9 +25,9 @@ namespace winrt::Microsoft::TerminalApp::implementation
void SetInputTap(const Microsoft::Terminal::TerminalConnection::ITerminalConnection& inputTap);
WINRT_CALLBACK(TerminalOutput, winrt::Microsoft::Terminal::TerminalConnection::TerminalOutputHandler);
til::event<winrt::Microsoft::Terminal::TerminalConnection::TerminalOutputHandler> TerminalOutput;
TYPED_EVENT(StateChanged, winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection, winrt::Windows::Foundation::IInspectable);
til::typed_event<winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection, winrt::Windows::Foundation::IInspectable> StateChanged;
private:
void _PrintInput(const hstring& data);

View File

@ -23,11 +23,11 @@ namespace winrt::TerminalApp::implementation
static int Compare(const winrt::TerminalApp::FilteredCommand& first, const winrt::TerminalApp::FilteredCommand& second);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(winrt::TerminalApp::PaletteItem, Item, _PropertyChangedHandlers, nullptr);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Filter, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::TerminalApp::HighlightedText, HighlightedName, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(int, Weight, _PropertyChangedHandlers);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(winrt::TerminalApp::PaletteItem, Item, PropertyChanged.raise, nullptr);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Filter, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::TerminalApp::HighlightedText, HighlightedName, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(int, Weight, PropertyChanged.raise);
private:
winrt::TerminalApp::HighlightedText _computeHighlightedName();

View File

@ -13,9 +13,9 @@ namespace winrt::TerminalApp::implementation
HighlightedTextSegment() = default;
HighlightedTextSegment(const winrt::hstring& text, bool isHighlighted);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, TextSegment, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(bool, IsHighlighted, _PropertyChangedHandlers);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, TextSegment, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(bool, IsHighlighted, PropertyChanged.raise);
};
struct HighlightedText : HighlightedTextT<HighlightedText>
@ -23,8 +23,8 @@ namespace winrt::TerminalApp::implementation
HighlightedText() = default;
HighlightedText(const Windows::Foundation::Collections::IObservableVector<winrt::TerminalApp::HighlightedTextSegment>& segments);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(Windows::Foundation::Collections::IObservableVector<winrt::TerminalApp::HighlightedTextSegment>, Segments, _PropertyChangedHandlers);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(Windows::Foundation::Collections::IObservableVector<winrt::TerminalApp::HighlightedTextSegment>, Segments, PropertyChanged.raise);
};
}

View File

@ -69,18 +69,18 @@ namespace winrt::TerminalApp::implementation
void MinMaxCloseControl::_MinimizeClick(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const RoutedEventArgs& e)
{
_MinimizeClickHandlers(*this, e);
MinimizeClick.raise(*this, e);
}
void MinMaxCloseControl::_MaximizeClick(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const RoutedEventArgs& e)
{
_MaximizeClickHandlers(*this, e);
MaximizeClick.raise(*this, e);
}
void MinMaxCloseControl::_CloseClick(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const RoutedEventArgs& e)
{
_CloseClickHandlers(*this, e);
CloseClick.raise(*this, e);
}
void MinMaxCloseControl::SetWindowVisualState(WindowVisualState visualState)

View File

@ -28,9 +28,9 @@ namespace winrt::TerminalApp::implementation
void _CloseClick(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
TYPED_EVENT(MinimizeClick, TerminalApp::MinMaxCloseControl, winrt::Windows::UI::Xaml::RoutedEventArgs);
TYPED_EVENT(MaximizeClick, TerminalApp::MinMaxCloseControl, winrt::Windows::UI::Xaml::RoutedEventArgs);
TYPED_EVENT(CloseClick, TerminalApp::MinMaxCloseControl, winrt::Windows::UI::Xaml::RoutedEventArgs);
til::typed_event<TerminalApp::MinMaxCloseControl, winrt::Windows::UI::Xaml::RoutedEventArgs> MinimizeClick;
til::typed_event<TerminalApp::MinMaxCloseControl, winrt::Windows::UI::Xaml::RoutedEventArgs> MaximizeClick;
til::typed_event<TerminalApp::MinMaxCloseControl, winrt::Windows::UI::Xaml::RoutedEventArgs> CloseClick;
std::shared_ptr<ThrottledFuncTrailing<winrt::Windows::UI::Xaml::Controls::Button>> _displayToolTip{ nullptr };
std::optional<CaptionButton> _lastPressedButton{ std::nullopt };

View File

@ -11,10 +11,10 @@ namespace winrt::TerminalApp::implementation
public:
Windows::UI::Xaml::Controls::IconElement ResolvedIcon();
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Name, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Icon, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, KeyChordText, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Name, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Icon, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, KeyChordText, PropertyChanged.raise);
};
}

View File

@ -993,7 +993,7 @@ void Pane::_ContentGotFocusHandler(const winrt::Windows::Foundation::IInspectabl
{
f = o.FocusState();
}
_GotFocusHandlers(shared_from_this(), f);
GotFocus.raise(shared_from_this(), f);
}
// Event Description:
@ -1003,7 +1003,7 @@ void Pane::_ContentGotFocusHandler(const winrt::Windows::Foundation::IInspectabl
void Pane::_ContentLostFocusHandler(const winrt::Windows::Foundation::IInspectable& /* sender */,
const RoutedEventArgs& /* args */)
{
_LostFocusHandlers(shared_from_this());
LostFocus.raise(shared_from_this());
}
// Method Description:
@ -1015,7 +1015,7 @@ void Pane::_ContentLostFocusHandler(const winrt::Windows::Foundation::IInspectab
void Pane::Close()
{
// Fire our Closed event to tell our parent that we should be removed.
_ClosedHandlers(nullptr, nullptr);
Closed.raise(nullptr, nullptr);
}
// Method Description:
@ -1268,12 +1268,11 @@ void Pane::UpdateVisuals()
// - <none>
void Pane::_Focus()
{
_GotFocusHandlers(shared_from_this(), FocusState::Programmatic);
GotFocus.raise(shared_from_this(), FocusState::Programmatic);
if (const auto& lastContent{ GetLastFocusedContent() })
{
lastContent.Focus(FocusState::Programmatic);
}
}
// Method Description:
@ -1388,7 +1387,7 @@ std::shared_ptr<Pane> Pane::DetachPane(std::shared_ptr<Pane> pane)
// Trigger the detached event on each child
detached->WalkTree([](auto pane) {
pane->_DetachedHandlers(pane);
pane->Detached.raise(pane);
});
return detached;
@ -1505,7 +1504,7 @@ void Pane::_CloseChild(const bool closeFirst)
// the control. Because Tab is relying on GotFocus to know who the
// active pane in the tree is, without this call, _no one_ will be
// the active pane any longer.
_GotFocusHandlers(shared_from_this(), FocusState::Programmatic);
GotFocus.raise(shared_from_this(), FocusState::Programmatic);
}
_UpdateBorders();
@ -1607,7 +1606,7 @@ void Pane::_CloseChild(const bool closeFirst)
}
// Notify the discarded child that it was closed by its parent
closedChild->_ClosedByParentHandlers();
closedChild->ClosedByParent.raise();
}
void Pane::_CloseChildRoutine(const bool closeFirst)

View File

@ -215,15 +215,15 @@ public:
void CollectTaskbarStates(std::vector<winrt::TerminalApp::TaskbarState>& states);
WINRT_CALLBACK(ClosedByParent, winrt::delegate<>);
WINRT_CALLBACK(Closed, winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>);
til::event<winrt::delegate<>> ClosedByParent;
til::event<winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>> Closed;
using gotFocusArgs = winrt::delegate<std::shared_ptr<Pane>, winrt::Windows::UI::Xaml::FocusState>;
WINRT_CALLBACK(GotFocus, gotFocusArgs);
WINRT_CALLBACK(LostFocus, winrt::delegate<std::shared_ptr<Pane>>);
WINRT_CALLBACK(PaneRaiseBell, winrt::Windows::Foundation::EventHandler<bool>);
WINRT_CALLBACK(Detached, winrt::delegate<std::shared_ptr<Pane>>);
til::event<gotFocusArgs> GotFocus;
til::event<winrt::delegate<std::shared_ptr<Pane>>> LostFocus;
til::event<winrt::Windows::Foundation::EventHandler<bool>> PaneRaiseBell;
til::event<winrt::delegate<std::shared_ptr<Pane>>> Detached;
private:
struct PanePoint;

View File

@ -268,7 +268,7 @@ namespace winrt::TerminalApp::implementation
const auto selectedCommand = _filteredActionsView().SelectedItem();
const auto filteredCommand{ selectedCommand.try_as<winrt::TerminalApp::FilteredCommand>() };
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"SelectedItem" });
PropertyChanged.raise(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"SelectedItem" });
// Make sure to not send the preview if we're collapsed. This can
// sometimes fire after we've been closed, which can trigger us to

View File

@ -50,12 +50,12 @@ namespace winrt::TerminalApp::implementation
til::typed_event<winrt::TerminalApp::SuggestionsControl, Microsoft::Terminal::Settings::Model::Command> DispatchCommandRequested;
til::typed_event<Windows::Foundation::IInspectable, Microsoft::Terminal::Settings::Model::Command> PreviewAction;
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, NoMatchesText, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, SearchBoxPlaceholderText, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ControlName, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ParentCommandName, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ParsedCommandLineText, _PropertyChangedHandlers);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, NoMatchesText, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, SearchBoxPlaceholderText, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ControlName, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ParentCommandName, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ParsedCommandLineText, PropertyChanged.raise);
private:
struct winrt_object_hash

View File

@ -53,7 +53,7 @@ namespace winrt::TerminalApp::implementation
contextMenuFlyout.Closed([weakThis](auto&&, auto&&) {
if (auto tab{ weakThis.get() })
{
tab->_RequestFocusActiveControlHandlers();
tab->RequestFocusActiveControl.raise();
}
});
_AppendCloseMenuItems(contextMenuFlyout);
@ -106,7 +106,7 @@ namespace winrt::TerminalApp::implementation
closeTabMenuItem.Click([weakThis](auto&&, auto&&) {
if (auto tab{ weakThis.get() })
{
tab->_CloseRequestedHandlers(nullptr, nullptr);
tab->CloseRequested.raise(nullptr, nullptr);
}
});
closeTabMenuItem.Text(RS_(L"TabClose"));
@ -260,7 +260,7 @@ namespace winrt::TerminalApp::implementation
TabViewItem().Tapped([weakThis{ get_weak() }](auto&&, auto&&) {
if (auto tab{ weakThis.get() })
{
tab->_RequestFocusActiveControlHandlers();
tab->RequestFocusActiveControl.raise();
}
});

View File

@ -32,23 +32,23 @@ namespace winrt::TerminalApp::implementation
Microsoft::Terminal::Settings::Model::TabCloseButtonVisibility CloseButtonVisibility();
void CloseButtonVisibility(Microsoft::Terminal::Settings::Model::TabCloseButtonVisibility visible);
WINRT_CALLBACK(RequestFocusActiveControl, winrt::delegate<void()>);
til::event<winrt::delegate<void()>> RequestFocusActiveControl;
WINRT_CALLBACK(Closed, winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>);
WINRT_CALLBACK(CloseRequested, winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
til::event<winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>> Closed;
til::event<winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>> CloseRequested;
til::property_changed_event PropertyChanged;
// The TabViewIndex is the index this Tab object resides in TerminalPage's _tabs vector.
WINRT_PROPERTY(uint32_t, TabViewIndex, 0);
// The TabViewNumTabs is the number of Tab objects in TerminalPage's _tabs vector.
WINRT_PROPERTY(uint32_t, TabViewNumTabs, 0);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Title, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Icon, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(bool, ReadOnly, _PropertyChangedHandlers, false);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Title, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Icon, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(bool, ReadOnly, PropertyChanged.raise, false);
WINRT_PROPERTY(winrt::Microsoft::UI::Xaml::Controls::TabViewItem, TabViewItem, nullptr);
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::UI::Xaml::FrameworkElement, Content, _PropertyChangedHandlers, nullptr);
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::UI::Xaml::FrameworkElement, Content, PropertyChanged.raise, nullptr);
protected:
winrt::Windows::UI::Xaml::FocusState _focusState{ winrt::Windows::UI::Xaml::FocusState::Unfocused };

View File

@ -120,7 +120,7 @@ namespace winrt::TerminalApp::implementation
_CloseRenameBox();
if (!_renameCancelled)
{
_TitleChangeRequestedHandlers(HeaderRenamerTextBox().Text());
TitleChangeRequested.raise(HeaderRenamerTextBox().Text());
}
}
@ -132,7 +132,7 @@ namespace winrt::TerminalApp::implementation
{
HeaderRenamerTextBox().Visibility(Windows::UI::Xaml::Visibility::Collapsed);
HeaderTextBlock().Visibility(Windows::UI::Xaml::Visibility::Visible);
_RenameEndedHandlers(*this, nullptr);
RenameEnded.raise(*this, nullptr);
}
}
}

View File

@ -19,14 +19,13 @@ namespace winrt::TerminalApp::implementation
bool InRename();
WINRT_CALLBACK(TitleChangeRequested, TerminalApp::TitleChangeRequestedArgs);
til::event<TerminalApp::TitleChangeRequestedArgs> TitleChangeRequested;
til::typed_event<> RenameEnded;
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Title, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(double, RenamerMaxWidth, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::TerminalApp::TerminalTabStatus, TabStatus, _PropertyChangedHandlers);
TYPED_EVENT(RenameEnded, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Title, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(double, RenamerMaxWidth, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::TerminalApp::TerminalTabStatus, TabStatus, PropertyChanged.raise);
private:
bool _receivedKeyDown{ false };

View File

@ -147,7 +147,7 @@ namespace winrt::TerminalApp::implementation
// 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->_SetTaskbarProgressHandlers(*page, nullptr);
page->SetTaskbarProgress.raise(*page, nullptr);
auto profile = tab->GetFocusedProfile();
page->_UpdateBackground(profile);
@ -163,7 +163,7 @@ namespace winrt::TerminalApp::implementation
if (page && tab)
{
page->_RaiseVisualBellHandlers(nullptr, nullptr);
page->RaiseVisualBell.raise(nullptr, nullptr);
}
});
@ -480,7 +480,7 @@ namespace winrt::TerminalApp::implementation
// if the user manually closed all tabs.
// Do this only if we are the last window; the monarch will notice
// we are missing and remove us that way otherwise.
_LastTabClosedHandlers(*this, winrt::make<LastTabClosedEventArgs>(!_maintainStateOnTabClose));
LastTabClosed.raise(*this, winrt::make<LastTabClosedEventArgs>(!_maintainStateOnTabClose));
}
else if (focusedTabIndex.has_value() && focusedTabIndex.value() == gsl::narrow_cast<uint32_t>(tabIndex))
{
@ -940,7 +940,7 @@ namespace winrt::TerminalApp::implementation
// Raise an event that our title changed
if (_settings.GlobalSettings().ShowTitleInTitlebar())
{
_TitleChangedHandlers(*this, tab.Title());
TitleChanged.raise(*this, tab.Title());
}
_updateThemeColors();

View File

@ -52,7 +52,7 @@ namespace winrt::TerminalApp::implementation
// Sometimes nested bindings do not get updated,
// thus let's notify property changed on TabStatus when one of its properties changes
auto item{ weakThis.get() };
item->_PropertyChangedHandlers(*item, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"TabStatus" });
item->PropertyChanged.raise(*item, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"TabStatus" });
});
}
}

View File

@ -18,7 +18,7 @@ namespace winrt::TerminalApp::implementation
return _tab.get();
}
WINRT_OBSERVABLE_PROPERTY(winrt::TerminalApp::TerminalTabStatus, TabStatus, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::TerminalApp::TerminalTabStatus, TabStatus, PropertyChanged.raise);
private:
winrt::weak_ref<winrt::TerminalApp::TabBase> _tab;

View File

@ -17,8 +17,8 @@ namespace winrt::TerminalApp::implementation
void OnNewTabButtonDrop(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::DragEventArgs& e);
void OnNewTabButtonDragOver(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::DragEventArgs& e);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(bool, ShowElevationShield, _PropertyChangedHandlers, false);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(bool, ShowElevationShield, PropertyChanged.raise, false);
};
}

View File

@ -187,7 +187,7 @@ namespace winrt::TerminalApp::implementation
}
// Inform the host that our titlebar content has changed.
_SetTitleBarContentHandlers(*this, _tabRow);
SetTitleBarContent.raise(*this, _tabRow);
// GH#13143 Manually set the tab row's background to transparent here.
//
@ -658,7 +658,7 @@ namespace winrt::TerminalApp::implementation
// have a tab yet, but will once we're initialized.
if (_tabs.Size() == 0 && !(_shouldStartInboundListener || _isEmbeddingInboundListener))
{
_LastTabClosedHandlers(*this, winrt::make<LastTabClosedEventArgs>(false));
LastTabClosed.raise(*this, winrt::make<LastTabClosedEventArgs>(false));
co_return;
}
else
@ -689,7 +689,7 @@ namespace winrt::TerminalApp::implementation
Dispatcher().RunAsync(CoreDispatcherPriority::Low, [weak = get_weak()]() {
if (auto self{ weak.get() })
{
self->_InitializedHandlers(*self, nullptr);
self->Initialized.raise(*self, nullptr);
}
});
}
@ -1628,7 +1628,7 @@ namespace winrt::TerminalApp::implementation
if (tab == _GetFocusedTab())
{
_TitleChangedHandlers(*this, newTabTitle);
TitleChanged.raise(*this, newTabTitle);
}
}
@ -1897,7 +1897,7 @@ namespace winrt::TerminalApp::implementation
co_return;
}
_QuitRequestedHandlers(nullptr, nullptr);
QuitRequested.raise(nullptr, nullptr);
}
}
@ -2185,7 +2185,7 @@ namespace winrt::TerminalApp::implementation
{
request->WindowPosition(dragPoint->to_winrt_point());
}
_RequestMoveContentHandlers(*this, *request);
RequestMoveContent.raise(*this, *request);
}
bool TerminalPage::_MoveTab(winrt::com_ptr<TerminalTab> tab, MoveTabArgs args)
@ -2960,7 +2960,7 @@ namespace winrt::TerminalApp::implementation
winrt::fire_and_forget TerminalPage::_SetTaskbarProgressHandler(const IInspectable /*sender*/, const IInspectable /*eventArgs*/)
{
co_await wil::resume_foreground(Dispatcher());
_SetTaskbarProgressHandlers(*this, nullptr);
SetTaskbarProgress.raise(*this, nullptr);
}
// Method Description:
@ -2970,7 +2970,7 @@ namespace winrt::TerminalApp::implementation
// - args: the arguments specifying how to set the display status to ShowWindow for our window handle
void TerminalPage::_ShowWindowChangedHandler(const IInspectable /*sender*/, const Microsoft::Terminal::Control::ShowWindowArgs args)
{
_ShowWindowChangedHandlers(*this, args);
ShowWindowChanged.raise(*this, args);
}
// Method Description:
@ -3349,7 +3349,7 @@ namespace winrt::TerminalApp::implementation
// will let the user hot-reload this setting, but any runtime changes to
// the alwaysOnTop setting will be lost.
_isAlwaysOnTop = _settings.GlobalSettings().AlwaysOnTop();
_AlwaysOnTopChangedHandlers(*this, nullptr);
AlwaysOnTopChanged.raise(*this, nullptr);
// Settings AllowDependentAnimations will affect whether animations are
// enabled application-wide, so we don't need to check it each time we
@ -3557,7 +3557,7 @@ namespace winrt::TerminalApp::implementation
{
_isInFocusMode = newInFocusMode;
_UpdateTabView();
_FocusModeChangedHandlers(*this, nullptr);
FocusModeChanged.raise(*this, nullptr);
}
}
@ -3582,7 +3582,7 @@ namespace winrt::TerminalApp::implementation
void TerminalPage::ToggleAlwaysOnTop()
{
_isAlwaysOnTop = !_isAlwaysOnTop;
_AlwaysOnTopChangedHandlers(*this, nullptr);
AlwaysOnTopChanged.raise(*this, nullptr);
}
// Method Description:
@ -3783,7 +3783,7 @@ namespace winrt::TerminalApp::implementation
}
_isFullscreen = newFullscreen;
_UpdateTabView();
_FullscreenChangedHandlers(*this, nullptr);
FullscreenChanged.raise(*this, nullptr);
}
// Method Description:
@ -3802,7 +3802,7 @@ namespace winrt::TerminalApp::implementation
return;
}
_isMaximized = newMaximized;
_ChangeMaximizeRequestedHandlers(*this, nullptr);
ChangeMaximizeRequested.raise(*this, nullptr);
}
HRESULT TerminalPage::_OnNewConnection(const ConptyConnection& connection)
@ -3845,7 +3845,7 @@ namespace winrt::TerminalApp::implementation
_CreateNewTabFromPane(newPane);
// Request a summon of this window to the foreground
_SummonWindowRequestedHandlers(*this, nullptr);
SummonWindowRequested.raise(*this, nullptr);
const IInspectable unused{ nullptr };
_SetAsDefaultDismissHandler(unused, unused);
@ -4258,7 +4258,7 @@ namespace winrt::TerminalApp::implementation
{
WindowRenamer().IsOpen(false);
}
_RenameWindowRequestedHandlers(*this, request);
RenameWindowRequested.raise(*this, request);
// We can't just use request.Successful here, because the handler might
// (will) be handling this asynchronously, so when control returns to
// us, this hasn't actually been handled yet. We'll get called back in
@ -5067,7 +5067,7 @@ namespace winrt::TerminalApp::implementation
// This will go up to the monarch, who will then dispatch the request
// back down to the source TerminalPage, who will then perform a
// RequestMoveContent to move their tab to us.
_RequestReceiveContentHandlers(*this, *request);
RequestReceiveContent.raise(*this, *request);
}
}

View File

@ -172,33 +172,33 @@ namespace winrt::TerminalApp::implementation
uint32_t NumberOfTabs() const;
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
til::property_changed_event PropertyChanged;
// -------------------------------- WinRT Events ---------------------------------
TYPED_EVENT(TitleChanged, IInspectable, winrt::hstring);
TYPED_EVENT(LastTabClosed, IInspectable, winrt::TerminalApp::LastTabClosedEventArgs);
TYPED_EVENT(SetTitleBarContent, IInspectable, winrt::Windows::UI::Xaml::UIElement);
TYPED_EVENT(FocusModeChanged, IInspectable, IInspectable);
TYPED_EVENT(FullscreenChanged, IInspectable, IInspectable);
TYPED_EVENT(ChangeMaximizeRequested, IInspectable, IInspectable);
TYPED_EVENT(AlwaysOnTopChanged, IInspectable, IInspectable);
TYPED_EVENT(RaiseVisualBell, IInspectable, IInspectable);
TYPED_EVENT(SetTaskbarProgress, IInspectable, IInspectable);
TYPED_EVENT(Initialized, IInspectable, IInspectable);
TYPED_EVENT(IdentifyWindowsRequested, IInspectable, IInspectable);
TYPED_EVENT(RenameWindowRequested, Windows::Foundation::IInspectable, winrt::TerminalApp::RenameWindowRequestedArgs);
TYPED_EVENT(SummonWindowRequested, IInspectable, IInspectable);
til::typed_event<IInspectable, winrt::hstring> TitleChanged;
til::typed_event<IInspectable, winrt::TerminalApp::LastTabClosedEventArgs> LastTabClosed;
til::typed_event<IInspectable, winrt::Windows::UI::Xaml::UIElement> SetTitleBarContent;
til::typed_event<IInspectable, IInspectable> FocusModeChanged;
til::typed_event<IInspectable, IInspectable> FullscreenChanged;
til::typed_event<IInspectable, IInspectable> ChangeMaximizeRequested;
til::typed_event<IInspectable, IInspectable> AlwaysOnTopChanged;
til::typed_event<IInspectable, IInspectable> RaiseVisualBell;
til::typed_event<IInspectable, IInspectable> SetTaskbarProgress;
til::typed_event<IInspectable, IInspectable> Initialized;
til::typed_event<IInspectable, IInspectable> IdentifyWindowsRequested;
til::typed_event<Windows::Foundation::IInspectable, winrt::TerminalApp::RenameWindowRequestedArgs> RenameWindowRequested;
til::typed_event<IInspectable, IInspectable> SummonWindowRequested;
TYPED_EVENT(CloseRequested, IInspectable, IInspectable);
TYPED_EVENT(OpenSystemMenu, IInspectable, IInspectable);
TYPED_EVENT(QuitRequested, IInspectable, IInspectable);
TYPED_EVENT(ShowWindowChanged, IInspectable, winrt::Microsoft::Terminal::Control::ShowWindowArgs)
til::typed_event<IInspectable, IInspectable> CloseRequested;
til::typed_event<IInspectable, IInspectable> OpenSystemMenu;
til::typed_event<IInspectable, IInspectable> QuitRequested;
til::typed_event<IInspectable, winrt::Microsoft::Terminal::Control::ShowWindowArgs> ShowWindowChanged;
TYPED_EVENT(RequestMoveContent, Windows::Foundation::IInspectable, winrt::TerminalApp::RequestMoveContentArgs);
TYPED_EVENT(RequestReceiveContent, Windows::Foundation::IInspectable, winrt::TerminalApp::RequestReceiveContentArgs);
til::typed_event<Windows::Foundation::IInspectable, winrt::TerminalApp::RequestMoveContentArgs> RequestMoveContent;
til::typed_event<Windows::Foundation::IInspectable, winrt::TerminalApp::RequestReceiveContentArgs> RequestReceiveContent;
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::UI::Xaml::Media::Brush, TitlebarBrush, _PropertyChangedHandlers, nullptr);
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::UI::Xaml::Media::Brush, FrameBrush, _PropertyChangedHandlers, nullptr);
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::UI::Xaml::Media::Brush, TitlebarBrush, PropertyChanged.raise, nullptr);
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::UI::Xaml::Media::Brush, FrameBrush, PropertyChanged.raise, nullptr);
private:
friend struct TerminalPageT<TerminalPage>; // for Xaml to bind events

View File

@ -80,7 +80,7 @@ namespace winrt::TerminalApp::implementation
void TerminalTab::_Setup()
{
_rootClosedToken = _rootPane->Closed([=](auto&& /*s*/, auto&& /*e*/) {
_ClosedHandlers(nullptr, nullptr);
Closed.raise(nullptr, nullptr);
});
Content(_rootPane->GetRootElement());
@ -103,7 +103,7 @@ namespace winrt::TerminalApp::implementation
_headerControl.RenameEnded([weakThis = get_weak()](auto&&, auto&&) {
if (auto tab{ weakThis.get() })
{
tab->_RequestFocusActiveControlHandlers();
tab->RequestFocusActiveControl.raise();
}
});
@ -633,14 +633,14 @@ namespace winrt::TerminalApp::implementation
_rootPane->Closed(_rootClosedToken);
auto p = _rootPane;
p->WalkTree([](auto pane) {
pane->_DetachedHandlers(pane);
pane->Detached.raise(pane);
});
// Clean up references and close the tab
_rootPane = nullptr;
_activePane = nullptr;
Content(nullptr);
_ClosedHandlers(nullptr, nullptr);
Closed.raise(nullptr, nullptr);
return p;
}
@ -1122,7 +1122,7 @@ namespace winrt::TerminalApp::implementation
}
// fire an event signaling that our taskbar progress changed.
_TaskbarProgressChangedHandlers(nullptr, nullptr);
TaskbarProgressChanged.raise(nullptr, nullptr);
}
// Method Description:
@ -1202,7 +1202,7 @@ namespace winrt::TerminalApp::implementation
_RecalculateAndApplyReadOnly();
// Raise our own ActivePaneChanged event.
_ActivePaneChangedHandlers();
ActivePaneChanged.raise();
}
// Method Description:
@ -1521,7 +1521,7 @@ namespace winrt::TerminalApp::implementation
if (!tab->_headerControl.InRename() &&
(terminalControl == nullptr || !terminalControl.SearchBoxEditInFocus()))
{
tab->_RequestFocusActiveControlHandlers();
tab->RequestFocusActiveControl.raise();
}
}
});

View File

@ -97,9 +97,9 @@ namespace winrt::TerminalApp::implementation
return _tabStatus;
}
WINRT_CALLBACK(ActivePaneChanged, winrt::delegate<>);
WINRT_CALLBACK(TabRaiseVisualBell, winrt::delegate<>);
TYPED_EVENT(TaskbarProgressChanged, IInspectable, IInspectable);
til::event<winrt::delegate<>> ActivePaneChanged;
til::event<winrt::delegate<>> TabRaiseVisualBell;
til::typed_event<IInspectable, IInspectable> TaskbarProgressChanged;
private:
static constexpr double HeaderRenameBoxWidthDefault{ 165 };

View File

@ -11,15 +11,15 @@ namespace winrt::TerminalApp::implementation
{
TerminalTabStatus() = default;
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(bool, IsConnectionClosed, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(bool, IsPaneZoomed, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(bool, IsProgressRingActive, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(bool, IsProgressRingIndeterminate, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(bool, BellIndicator, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(bool, IsReadOnlyActive, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(uint32_t, ProgressValue, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(bool, IsInputBroadcastActive, _PropertyChangedHandlers);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(bool, IsConnectionClosed, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(bool, IsPaneZoomed, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(bool, IsProgressRingActive, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(bool, IsProgressRingIndeterminate, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(bool, BellIndicator, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(bool, IsReadOnlyActive, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(uint32_t, ProgressValue, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(bool, IsInputBroadcastActive, PropertyChanged.raise);
};
}

View File

@ -226,7 +226,7 @@ namespace winrt::TerminalApp::implementation
auto args = winrt::make_self<SystemMenuChangeArgs>(RS_(L"SettingsMenuItem"),
SystemMenuChangeAction::Add,
SystemMenuItemHandler(this, &TerminalWindow::_OpenSettingsUI));
_SystemMenuChangeRequestedHandlers(*this, *args);
SystemMenuChangeRequested.raise(*this, *args);
TraceLoggingWrite(
g_hTerminalAppProvider,
@ -748,7 +748,7 @@ namespace winrt::TerminalApp::implementation
void TerminalWindow::_RefreshThemeRoutine()
{
// Propagate the event to the host layer, so it can update its own UI
_RequestedThemeChangedHandlers(*this, Theme());
RequestedThemeChanged.raise(*this, Theme());
}
// This may be called on a background thread, or the main thread, but almost
@ -767,7 +767,7 @@ namespace winrt::TerminalApp::implementation
_root->SetSettings(_settings, true);
// Bubble the notification up to the AppHost, now that we've updated our _settings.
_SettingsChangedHandlers(*this, args);
SettingsChanged.raise(*this, args);
if (FAILED(args.Result()))
{
@ -1239,7 +1239,7 @@ namespace winrt::TerminalApp::implementation
// If we're entering Quake Mode from Focus Mode, then this will do nothing
// If we're leaving Quake Mode (we're already in Focus Mode), then this will do nothing
_root->SetFocusMode(true);
_IsQuakeWindowChangedHandlers(*this, nullptr);
IsQuakeWindowChanged.raise(*this, nullptr);
}
}
void TerminalWindow::WindowId(const uint64_t& id)
@ -1359,8 +1359,8 @@ namespace winrt::TerminalApp::implementation
// PropertyChangedEventArgs will throw.
try
{
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"WindowName" });
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"WindowNameForDisplay" });
PropertyChanged.raise(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"WindowName" });
PropertyChanged.raise(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"WindowNameForDisplay" });
}
CATCH_LOG();
}

View File

@ -48,9 +48,9 @@ namespace winrt::TerminalApp::implementation
winrt::hstring WindowNameForDisplay() const noexcept;
bool IsQuakeWindow() const noexcept;
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, VirtualWorkingDirectory, _PropertyChangedHandlers, L"");
til::property_changed_event PropertyChanged;
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, VirtualWorkingDirectory, PropertyChanged.raise, L"");
public:
// Used for setting the initial CWD, before we have XAML set up for property change notifications.
@ -156,14 +156,17 @@ namespace winrt::TerminalApp::implementation
// -------------------------------- WinRT Events ---------------------------------
// PropertyChanged is surprisingly not a typed event, so we'll define that one manually.
// Usually we'd just do
// WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
// til::property_changed_event PropertyChanged;
//
// But what we're doing here is exposing the Page's PropertyChanged _as
// our own event_. It's a FORWARDED_CALLBACK, essentially.
winrt::event_token PropertyChanged(Windows::UI::Xaml::Data::PropertyChangedEventHandler const& handler) { return _root->PropertyChanged(handler); }
void PropertyChanged(winrt::event_token const& token) { _root->PropertyChanged(token); }
TYPED_EVENT(RequestedThemeChanged, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Settings::Model::Theme);
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Settings::Model::Theme> RequestedThemeChanged;
til::typed_event<Windows::Foundation::IInspectable, Windows::Foundation::IInspectable> IsQuakeWindowChanged;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::SystemMenuChangeArgs> SystemMenuChangeRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::SettingsLoadEventArgs> SettingsChanged;
private:
// If you add controls here, but forget to null them either here or in
@ -230,12 +233,6 @@ namespace winrt::TerminalApp::implementation
FORWARDED_TYPED_EVENT(QuitRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, QuitRequested);
FORWARDED_TYPED_EVENT(ShowWindowChanged, Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Control::ShowWindowArgs, _root, ShowWindowChanged);
TYPED_EVENT(IsQuakeWindowChanged, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable);
TYPED_EVENT(SystemMenuChangeRequested, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::SystemMenuChangeArgs);
TYPED_EVENT(SettingsChanged, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::SettingsLoadEventArgs);
FORWARDED_TYPED_EVENT(RequestMoveContent, Windows::Foundation::IInspectable, winrt::TerminalApp::RequestMoveContentArgs, _root, RequestMoveContent);
FORWARDED_TYPED_EVENT(RequestReceiveContent, Windows::Foundation::IInspectable, winrt::TerminalApp::RequestReceiveContentArgs, _root, RequestReceiveContent);

View File

@ -40,6 +40,7 @@
#include <winrt/Windows.UI.Xaml.Automation.Peers.h>
#include <winrt/Windows.UI.Xaml.Controls.h>
#include <winrt/Windows.UI.Xaml.Controls.Primitives.h>
#include <winrt/Windows.UI.Xaml.Data.h>
#include <winrt/Windows.UI.Xaml.Documents.h>
#include <winrt/Windows.UI.Xaml.Input.h>
#include <winrt/Windows.UI.Xaml.Markup.h>

View File

@ -94,7 +94,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
// - str: the string to write.
void AzureConnection::_WriteStringWithNewline(const std::wstring_view str)
{
_TerminalOutputHandlers(str + L"\r\n");
TerminalOutput.raise(str + L"\r\n");
}
// Method description:
@ -110,7 +110,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
catch (const std::exception& runtimeException)
{
// This also catches the AzureException, which has a .what()
_TerminalOutputHandlers(_colorize(91, til::u8u16(std::string{ runtimeException.what() })));
TerminalOutput.raise(_colorize(91, til::u8u16(std::string{ runtimeException.what() })));
}
catch (...)
{
@ -160,13 +160,13 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
_currentInputMode = mode;
_TerminalOutputHandlers(L"> \x1b[92m"); // Make prompted user input green
TerminalOutput.raise(L"> \x1b[92m"); // Make prompted user input green
_inputEvent.wait(inputLock, [this, mode]() {
return _currentInputMode != mode || _isStateAtOrBeyond(ConnectionState::Closing);
});
_TerminalOutputHandlers(L"\x1b[m");
TerminalOutput.raise(L"\x1b[m");
if (_isStateAtOrBeyond(ConnectionState::Closing))
{
@ -204,19 +204,19 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
if (_userInput.size() > 0)
{
_userInput.pop_back();
_TerminalOutputHandlers(L"\x08 \x08"); // overstrike the character with a space
TerminalOutput.raise(L"\x08 \x08"); // overstrike the character with a space
}
}
else
{
_TerminalOutputHandlers(data); // echo back
TerminalOutput.raise(data); // echo back
switch (_currentInputMode)
{
case InputMode::Line:
if (data.size() > 0 && gsl::at(data, 0) == UNICODE_CARRIAGERETURN)
{
_TerminalOutputHandlers(L"\r\n"); // we probably got a \r, so we need to advance to the next line.
TerminalOutput.raise(L"\r\n"); // we probably got a \r, so we need to advance to the next line.
_currentInputMode = InputMode::None; // toggling the mode indicates completion
_inputEvent.notify_one();
break;
@ -279,7 +279,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
if (_hOutputThread)
{
// Waiting for the output thread to exit ensures that all pending _TerminalOutputHandlers()
// Waiting for the output thread to exit ensures that all pending TerminalOutput.raise()
// calls have returned and won't notify our caller (ControlCore) anymore. This ensures that
// we don't call a destroyed event handler asynchronously from a background thread (GH#13880).
WaitForSingleObject(_hOutputThread.get(), INFINITE);
@ -422,7 +422,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
}
// Pass the output to our registered event handlers
_TerminalOutputHandlers(_u16Str);
TerminalOutput.raise(_u16Str);
break;
}
case WINHTTP_WEB_SOCKET_CLOSE_BUFFER_TYPE:
@ -765,7 +765,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
const auto shellType = _ParsePreferredShellType(settingsResponse);
_WriteStringWithNewline(RS_(L"AzureRequestingTerminal"));
const auto socketUri = _GetTerminal(shellType);
_TerminalOutputHandlers(L"\r\n");
TerminalOutput.raise(L"\r\n");
//// Step 8: connecting to said terminal
{

View File

@ -26,7 +26,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
void Resize(uint32_t rows, uint32_t columns);
void Close();
WINRT_CALLBACK(TerminalOutput, TerminalOutputHandler);
til::event<TerminalOutputHandler> TerminalOutput;
private:
til::CoordType _initialRows{};

View File

@ -17,7 +17,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
return _connectionState;
}
TYPED_EVENT(StateChanged, ITerminalConnection, winrt::Windows::Foundation::IInspectable);
til::typed_event<ITerminalConnection, winrt::Windows::Foundation::IInspectable> StateChanged;
protected:
template<typename U>
@ -49,7 +49,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
}
// Dispatch the event outside of lock.
#pragma warning(suppress : 26491) // We can't avoid static_cast downcast because this is template magic.
_StateChangedHandlers(*static_cast<T*>(this), nullptr);
StateChanged.raise(*static_cast<T*>(this), nullptr);
return true;
}
CATCH_FAIL_FAST()

View File

@ -415,15 +415,15 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
winrt::hstring failureText{ fmt::format(std::wstring_view{ RS_(L"ProcessFailedToLaunch") },
fmt::format(_errorFormat, static_cast<unsigned int>(hr)),
_commandline) };
_TerminalOutputHandlers(failureText);
TerminalOutput.raise(failureText);
// If the path was invalid, let's present an informative message to the user
if (hr == HRESULT_FROM_WIN32(ERROR_DIRECTORY))
{
winrt::hstring badPathText{ fmt::format(std::wstring_view{ RS_(L"BadPathText") },
_startingDirectory) };
_TerminalOutputHandlers(L"\r\n");
_TerminalOutputHandlers(badPathText);
TerminalOutput.raise(L"\r\n");
TerminalOutput.raise(badPathText);
}
_transitionToState(ConnectionState::Failed);
@ -442,11 +442,11 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
{
// GH#11556 - make sure to format the error code to this string as an UNSIGNED int
winrt::hstring exitText{ fmt::format(std::wstring_view{ RS_(L"ProcessExited") }, fmt::format(_errorFormat, status)) };
_TerminalOutputHandlers(L"\r\n");
_TerminalOutputHandlers(exitText);
_TerminalOutputHandlers(L"\r\n");
_TerminalOutputHandlers(RS_(L"CtrlDToClose"));
_TerminalOutputHandlers(L"\r\n");
TerminalOutput.raise(L"\r\n");
TerminalOutput.raise(exitText);
TerminalOutput.raise(L"\r\n");
TerminalOutput.raise(RS_(L"CtrlDToClose"));
TerminalOutput.raise(L"\r\n");
}
CATCH_LOG();
}
@ -554,7 +554,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
// thread exit as fast as possible by aborting any ongoing writes coming from OpenConsole.
CancelSynchronousIo(_hOutputThread.get());
// Waiting for the output thread to exit ensures that all pending _TerminalOutputHandlers()
// Waiting for the output thread to exit ensures that all pending TerminalOutput.raise()
// calls have returned and won't notify our caller (ControlCore) anymore. This ensures that
// we don't call a destroyed event handler asynchronously from a background thread (GH#13880).
const auto result = WaitForSingleObject(_hOutputThread.get(), 1000);
@ -676,7 +676,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
}
// Pass the output to our registered event handlers
_TerminalOutputHandlers(_u16Str);
TerminalOutput.raise(_u16Str);
}
return 0;

View File

@ -57,7 +57,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
const winrt::guid& guid,
const winrt::guid& profileGuid);
WINRT_CALLBACK(TerminalOutput, TerminalOutputHandler);
til::event<TerminalOutputHandler> TerminalOutput;
private:
static void closePseudoConsoleAsync(HPCON hPC) noexcept;

View File

@ -33,7 +33,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
prettyPrint << wch;
}
}
_TerminalOutputHandlers(prettyPrint.str());
TerminalOutput.raise(prettyPrint.str());
}
void EchoConnection::Resize(uint32_t /*rows*/, uint32_t /*columns*/) noexcept

View File

@ -21,8 +21,8 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
winrt::guid SessionId() const noexcept { return {}; }
ConnectionState State() const noexcept { return ConnectionState::Connected; }
WINRT_CALLBACK(TerminalOutput, TerminalOutputHandler);
TYPED_EVENT(StateChanged, ITerminalConnection, IInspectable);
til::event<TerminalOutputHandler> TerminalOutput;
til::typed_event<ITerminalConnection, IInspectable> StateChanged;
};
}

View File

@ -37,5 +37,6 @@ TRACELOGGING_DECLARE_PROVIDER(g_hTerminalConnectionProvider);
#include <telemetry/ProjectTelemetry.h>
#include "til.h"
#include <til/winrt.h>
#include <cppwinrt_utils.h>

View File

@ -144,7 +144,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_renderer->SetBackgroundColorChangedCallback([this]() { _rendererBackgroundColorChanged(); });
_renderer->SetFrameColorChangedCallback([this]() { _rendererTabColorChanged(); });
_renderer->SetRendererEnteredErrorStateCallback([this]() { _RendererEnteredErrorStateHandlers(nullptr, nullptr); });
_renderer->SetRendererEnteredErrorStateCallback([this]() { RendererEnteredErrorState.raise(nullptr, nullptr); });
THROW_IF_FAILED(localPointerToThread->Initialize(_renderer.get()));
}
@ -186,7 +186,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
[weakThis = get_weak()]() {
if (auto core{ weakThis.get() }; !core->_IsClosing())
{
core->_CursorPositionChangedHandlers(*core, nullptr);
core->CursorPositionChanged.raise(*core, nullptr);
}
});
@ -208,7 +208,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
[weakThis = get_weak()](const auto& update) {
if (auto core{ weakThis.get() }; !core->_IsClosing())
{
core->_ScrollPositionChangedHandlers(*core, update);
core->ScrollPositionChanged.raise(*core, update);
}
});
}
@ -244,11 +244,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_setupDispatcherAndCallbacks();
const auto actualNewSize = _actualFont.GetSize();
// Bubble this up, so our new control knows how big we want the font.
_FontSizeChangedHandlers(*this, winrt::make<FontSizeChangedArgs>(actualNewSize.width, actualNewSize.height));
FontSizeChanged.raise(*this, winrt::make<FontSizeChangedArgs>(actualNewSize.width, actualNewSize.height));
// The renderer will be re-enabled in Initialize
_AttachedHandlers(*this, nullptr);
Attached.raise(*this, nullptr);
}
TerminalConnection::ITerminalConnection ControlCore::Connection()
@ -276,7 +276,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
// Subscribe to the connection's disconnected event and call our connection closed handlers.
_connectionStateChangedRevoker = newConnection.StateChanged(winrt::auto_revoke, [this](auto&& /*s*/, auto&& /*v*/) {
_ConnectionStateChangedHandlers(*this, nullptr);
ConnectionStateChanged.raise(*this, nullptr);
});
// Get our current size in rows/cols, and hook them up to
@ -304,7 +304,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
if (oldState != ConnectionState())
{ // rely on the null handling again
// send the notification
_ConnectionStateChangedHandlers(*this, nullptr);
ConnectionStateChanged.raise(*this, nullptr);
}
}
@ -475,14 +475,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
if (ch == CtrlD)
{
_CloseTerminalRequestedHandlers(*this, nullptr);
CloseTerminalRequested.raise(*this, nullptr);
return true;
}
if (ch == Enter)
{
// Ask the hosting application to give us a new connection.
_RestartTerminalRequestedHandlers(*this, nullptr);
RestartTerminalRequested.raise(*this, nullptr);
return true;
}
}
@ -561,13 +561,13 @@ namespace winrt::Microsoft::Terminal::Control::implementation
if (const auto uri = _terminal->GetHyperlinkAtBufferPosition(_terminal->GetSelectionAnchor()); !uri.empty())
{
lock.unlock();
_OpenHyperlinkHandlers(*this, winrt::make<OpenHyperlinkEventArgs>(winrt::hstring{ uri }));
OpenHyperlink.raise(*this, winrt::make<OpenHyperlinkEventArgs>(winrt::hstring{ uri }));
}
else
{
const auto selectedText = _terminal->GetTextBuffer().GetPlainText(_terminal->GetSelectionAnchor(), _terminal->GetSelectionEnd());
lock.unlock();
_OpenHyperlinkHandlers(*this, winrt::make<OpenHyperlinkEventArgs>(winrt::hstring{ selectedText }));
OpenHyperlink.raise(*this, winrt::make<OpenHyperlinkEventArgs>(winrt::hstring{ selectedText }));
}
return true;
}
@ -746,7 +746,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
auto eventArgs = winrt::make_self<TransparencyChangedEventArgs>(newOpacity);
_TransparencyChangedHandlers(*this, *eventArgs);
TransparencyChanged.raise(*this, *eventArgs);
}
void ControlCore::ToggleShaderEffects()
@ -824,7 +824,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_renderer->TriggerRedrawAll();
}
_HoveredHyperlinkChangedHandlers(*this, nullptr);
HoveredHyperlinkChanged.raise(*this, nullptr);
}
}
@ -937,7 +937,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_renderer->NotifyPaintFrame();
auto eventArgs = winrt::make_self<TransparencyChangedEventArgs>(Opacity());
_TransparencyChangedHandlers(*this, *eventArgs);
TransparencyChanged.raise(*this, *eventArgs);
_renderer->TriggerRedrawAll(true, true);
}
@ -1016,11 +1016,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_desiredFont.GetFaceName(),
_actualFont.GetFaceName()) };
auto noticeArgs = winrt::make<NoticeEventArgs>(NoticeLevel::Warning, message);
_RaiseNoticeHandlers(*this, std::move(noticeArgs));
RaiseNotice.raise(*this, std::move(noticeArgs));
}
const auto actualNewSize = _actualFont.GetSize();
_FontSizeChangedHandlers(*this, winrt::make<FontSizeChangedArgs>(actualNewSize.width, actualNewSize.height));
FontSizeChanged.raise(*this, winrt::make<FontSizeChangedArgs>(actualNewSize.width, actualNewSize.height));
}
// Method Description:
@ -1222,7 +1222,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// when an OSC 52 is emitted.
void ControlCore::_terminalCopyToClipboard(std::wstring_view wstr)
{
_CopyToClipboardHandlers(*this, winrt::make<implementation::CopyToClipboardEventArgs>(winrt::hstring{ wstr }));
CopyToClipboard.raise(*this, winrt::make<implementation::CopyToClipboardEventArgs>(winrt::hstring{ wstr }));
}
// Method Description:
@ -1255,11 +1255,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
const auto& [textData, htmlData, rtfData] = _terminal->RetrieveSelectedTextFromBuffer(singleLine, copyHtml, copyRtf);
// send data up for clipboard
_CopyToClipboardHandlers(*this,
winrt::make<CopyToClipboardEventArgs>(winrt::hstring{ textData },
winrt::to_hstring(htmlData),
winrt::to_hstring(rtfData),
copyFormats));
CopyToClipboard.raise(*this,
winrt::make<CopyToClipboardEventArgs>(winrt::hstring{ textData },
winrt::to_hstring(htmlData),
winrt::to_hstring(rtfData),
copyFormats));
return true;
}
@ -1483,7 +1483,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// Since this can only ever be triggered by output from the connection,
// then the Terminal already has the write lock when calling this
// callback.
_WarningBellHandlers(*this, nullptr);
WarningBell.raise(*this, nullptr);
}
// Method Description:
@ -1500,7 +1500,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// Since this can only ever be triggered by output from the connection,
// then the Terminal already has the write lock when calling this
// callback.
_TitleChangedHandlers(*this, winrt::make<TitleChangedEventArgs>(winrt::hstring{ wstr }));
TitleChanged.raise(*this, winrt::make<TitleChangedEventArgs>(winrt::hstring{ wstr }));
}
// Method Description:
@ -1529,7 +1529,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
if (_inUnitTests) [[unlikely]]
{
_ScrollPositionChangedHandlers(*this, update);
ScrollPositionChanged.raise(*this, update);
}
else
{
@ -1554,13 +1554,13 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void ControlCore::_terminalTaskbarProgressChanged()
{
_TaskbarProgressChangedHandlers(*this, nullptr);
TaskbarProgressChanged.raise(*this, nullptr);
}
void ControlCore::_terminalShowWindowChanged(bool showOrHide)
{
auto showWindow = winrt::make_self<implementation::ShowWindowArgs>(showOrHide);
_ShowWindowChangedHandlers(*this, *showWindow);
ShowWindowChanged.raise(*this, *showWindow);
}
// Method Description:
@ -1645,7 +1645,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// DO NOT call _updateSelectionUI() here.
// We don't want to show the markers so manually tell it to clear it.
_terminal->SetBlockSelection(false);
_UpdateSelectionMarkersHandlers(*this, winrt::make<implementation::UpdateSelectionMarkersEventArgs>(true));
UpdateSelectionMarkers.raise(*this, winrt::make<implementation::UpdateSelectionMarkersEventArgs>(true));
foundResults->TotalMatches(gsl::narrow<int32_t>(_searcher.Results().size()));
foundResults->CurrentMatch(gsl::narrow<int32_t>(_searcher.CurrentMatch()));
@ -1656,7 +1656,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// Raise a FoundMatch event, which the control will use to notify
// narrator if there was any results in the buffer
_FoundMatchHandlers(*this, *foundResults);
FoundMatch.raise(*this, *foundResults);
}
Windows::Foundation::Collections::IVector<int32_t> ControlCore::SearchResultRows()
@ -1708,7 +1708,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void ControlCore::_rendererWarning(const HRESULT hr)
{
_RendererWarningHandlers(*this, winrt::make<RendererWarningArgs>(hr));
RendererWarning.raise(*this, winrt::make<RendererWarningArgs>(hr));
}
winrt::fire_and_forget ControlCore::_renderEngineSwapChainChanged(const HANDLE sourceHandle)
@ -1737,18 +1737,18 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_lastSwapChainHandle = std::move(duplicatedHandle);
// Now bubble the event up to the control.
_SwapChainChangedHandlers(*this, winrt::box_value<uint64_t>(reinterpret_cast<uint64_t>(_lastSwapChainHandle.get())));
SwapChainChanged.raise(*this, winrt::box_value<uint64_t>(reinterpret_cast<uint64_t>(_lastSwapChainHandle.get())));
}
}
void ControlCore::_rendererBackgroundColorChanged()
{
_BackgroundColorChangedHandlers(*this, nullptr);
BackgroundColorChanged.raise(*this, nullptr);
}
void ControlCore::_rendererTabColorChanged()
{
_TabColorChangedHandlers(*this, nullptr);
TabColorChanged.raise(*this, nullptr);
}
void ControlCore::BlinkAttributeTick()
@ -1953,7 +1953,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_renderer->TriggerSelection();
// only show the markers if we're doing a keyboard selection or in mark mode
const bool showMarkers{ _terminal->SelectionMode() >= ::Microsoft::Terminal::Core::Terminal::SelectionInteractionMode::Keyboard };
_UpdateSelectionMarkersHandlers(*this, winrt::make<implementation::UpdateSelectionMarkersEventArgs>(!showMarkers));
UpdateSelectionMarkers.raise(*this, winrt::make<implementation::UpdateSelectionMarkersEventArgs>(!showMarkers));
}
void ControlCore::AttachUiaEngine(::Microsoft::Console::Render::IRenderEngine* const pEngine)
@ -1986,7 +1986,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void ControlCore::_raiseReadOnlyWarning()
{
auto noticeArgs = winrt::make<NoticeEventArgs>(NoticeLevel::Info, RS_(L"TermControlReadOnly"));
_RaiseNoticeHandlers(*this, std::move(noticeArgs));
RaiseNotice.raise(*this, std::move(noticeArgs));
}
void ControlCore::_connectionOutputHandler(const hstring& hstr)
{
@ -2481,7 +2481,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
co_await winrt::resume_background();
_CompletionsChangedHandlers(*this, *args);
CompletionsChanged.raise(*this, *args);
}
void ControlCore::_selectSpan(til::point_span s)
{

View File

@ -252,34 +252,34 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// -------------------------------- WinRT Events ---------------------------------
// clang-format off
TYPED_EVENT(FontSizeChanged, IInspectable, Control::FontSizeChangedArgs);
til::typed_event<IInspectable, Control::FontSizeChangedArgs> FontSizeChanged;
TYPED_EVENT(CopyToClipboard, IInspectable, Control::CopyToClipboardEventArgs);
TYPED_EVENT(TitleChanged, IInspectable, Control::TitleChangedEventArgs);
TYPED_EVENT(WarningBell, IInspectable, IInspectable);
TYPED_EVENT(TabColorChanged, IInspectable, IInspectable);
TYPED_EVENT(BackgroundColorChanged, IInspectable, IInspectable);
TYPED_EVENT(ScrollPositionChanged, IInspectable, Control::ScrollPositionChangedArgs);
TYPED_EVENT(CursorPositionChanged, IInspectable, IInspectable);
TYPED_EVENT(TaskbarProgressChanged, IInspectable, IInspectable);
TYPED_EVENT(ConnectionStateChanged, IInspectable, IInspectable);
TYPED_EVENT(HoveredHyperlinkChanged, IInspectable, IInspectable);
TYPED_EVENT(RendererEnteredErrorState, IInspectable, IInspectable);
TYPED_EVENT(SwapChainChanged, IInspectable, IInspectable);
TYPED_EVENT(RendererWarning, IInspectable, Control::RendererWarningArgs);
TYPED_EVENT(RaiseNotice, IInspectable, Control::NoticeEventArgs);
TYPED_EVENT(TransparencyChanged, IInspectable, Control::TransparencyChangedEventArgs);
TYPED_EVENT(ReceivedOutput, IInspectable, IInspectable);
TYPED_EVENT(FoundMatch, IInspectable, Control::FoundResultsArgs);
TYPED_EVENT(ShowWindowChanged, IInspectable, Control::ShowWindowArgs);
TYPED_EVENT(UpdateSelectionMarkers, IInspectable, Control::UpdateSelectionMarkersEventArgs);
TYPED_EVENT(OpenHyperlink, IInspectable, Control::OpenHyperlinkEventArgs);
TYPED_EVENT(CompletionsChanged, IInspectable, Control::CompletionsChangedEventArgs);
til::typed_event<IInspectable, Control::CopyToClipboardEventArgs> CopyToClipboard;
til::typed_event<IInspectable, Control::TitleChangedEventArgs> TitleChanged;
til::typed_event<> WarningBell;
til::typed_event<> TabColorChanged;
til::typed_event<> BackgroundColorChanged;
til::typed_event<IInspectable, Control::ScrollPositionChangedArgs> ScrollPositionChanged;
til::typed_event<> CursorPositionChanged;
til::typed_event<> TaskbarProgressChanged;
til::typed_event<> ConnectionStateChanged;
til::typed_event<> HoveredHyperlinkChanged;
til::typed_event<IInspectable, IInspectable> RendererEnteredErrorState;
til::typed_event<> SwapChainChanged;
til::typed_event<IInspectable, Control::RendererWarningArgs> RendererWarning;
til::typed_event<IInspectable, Control::NoticeEventArgs> RaiseNotice;
til::typed_event<IInspectable, Control::TransparencyChangedEventArgs> TransparencyChanged;
til::typed_event<> ReceivedOutput;
til::typed_event<IInspectable, Control::FoundResultsArgs> FoundMatch;
til::typed_event<IInspectable, Control::ShowWindowArgs> ShowWindowChanged;
til::typed_event<IInspectable, Control::UpdateSelectionMarkersEventArgs> UpdateSelectionMarkers;
til::typed_event<IInspectable, Control::OpenHyperlinkEventArgs> OpenHyperlink;
til::typed_event<IInspectable, Control::CompletionsChangedEventArgs> CompletionsChanged;
TYPED_EVENT(CloseTerminalRequested, IInspectable, IInspectable);
TYPED_EVENT(RestartTerminalRequested, IInspectable, IInspectable);
til::typed_event<> CloseTerminalRequested;
til::typed_event<> RestartTerminalRequested;
TYPED_EVENT(Attached, IInspectable, IInspectable);
til::typed_event<> Attached;
// clang-format on
private:

View File

@ -52,7 +52,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_core->Attached([weakThis = get_weak()](auto&&, auto&&) {
if (auto self{ weakThis.get() })
{
self->_AttachedHandlers(*self, nullptr);
self->Attached.raise(*self, nullptr);
}
});
}
@ -117,7 +117,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void ControlInteractivity::Close()
{
_ClosedHandlers(*this, nullptr);
Closed.raise(*this, nullptr);
if (_core)
{
_core->Close();
@ -230,7 +230,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_core->BracketedPasteEnabled());
// send paste event up to TermApp
_PasteFromClipboardHandlers(*this, std::move(args));
PasteFromClipboard.raise(*this, std::move(args));
}
void ControlInteractivity::PointerPressed(Control::MouseButtonState buttonState,
@ -307,7 +307,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_core->AnchorContextMenu(terminalPosition);
auto contextArgs = winrt::make<ContextMenuRequestedEventArgs>(til::point{ pixelPosition }.to_winrt_point());
_ContextMenuRequestedHandlers(*this, contextArgs);
ContextMenuRequested.raise(*this, contextArgs);
}
else
{
@ -616,16 +616,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_core->UserScrollViewport(viewTop);
// _core->ScrollOffset() is now set to newValue
_ScrollPositionChangedHandlers(*this,
winrt::make<ScrollPositionChangedArgs>(_core->ScrollOffset(),
_core->ViewHeight(),
_core->BufferHeight()));
ScrollPositionChanged.raise(*this,
winrt::make<ScrollPositionChangedArgs>(_core->ScrollOffset(),
_core->ViewHeight(),
_core->BufferHeight()));
}
}
void ControlInteractivity::_hyperlinkHandler(const std::wstring_view uri)
{
_OpenHyperlinkHandlers(*this, winrt::make<OpenHyperlinkEventArgs>(winrt::hstring{ uri }));
OpenHyperlink.raise(*this, winrt::make<OpenHyperlinkEventArgs>(winrt::hstring{ uri }));
}
bool ControlInteractivity::_canSendVTMouseInput(const ::Microsoft::Terminal::Core::ControlKeyStates modifiers)

View File

@ -91,13 +91,13 @@ namespace winrt::Microsoft::Terminal::Control::implementation
uint64_t Id();
void AttachToNewControl(const Microsoft::Terminal::Control::IKeyBindings& keyBindings);
TYPED_EVENT(OpenHyperlink, IInspectable, Control::OpenHyperlinkEventArgs);
TYPED_EVENT(PasteFromClipboard, IInspectable, Control::PasteFromClipboardEventArgs);
TYPED_EVENT(ScrollPositionChanged, IInspectable, Control::ScrollPositionChangedArgs);
TYPED_EVENT(ContextMenuRequested, IInspectable, Control::ContextMenuRequestedEventArgs);
til::typed_event<IInspectable, Control::OpenHyperlinkEventArgs> OpenHyperlink;
til::typed_event<IInspectable, Control::PasteFromClipboardEventArgs> PasteFromClipboard;
til::typed_event<IInspectable, Control::ScrollPositionChangedArgs> ScrollPositionChanged;
til::typed_event<IInspectable, Control::ContextMenuRequestedEventArgs> ContextMenuRequested;
TYPED_EVENT(Attached, IInspectable, IInspectable);
TYPED_EVENT(Closed, IInspectable, IInspectable);
til::typed_event<IInspectable, IInspectable> Attached;
til::typed_event<IInspectable, IInspectable> Closed;
private:
// NOTE: _uiaEngine must be ordered before _core.

View File

@ -60,7 +60,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - <none>
void InteractivityAutomationPeer::SignalSelectionChanged()
{
_SelectionChangedHandlers(*this, nullptr);
SelectionChanged.raise(*this, nullptr);
}
// Method Description:
@ -75,7 +75,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - <none>
void InteractivityAutomationPeer::SignalTextChanged()
{
_TextChangedHandlers(*this, nullptr);
TextChanged.raise(*this, nullptr);
}
// Method Description:
@ -90,12 +90,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - <none>
void InteractivityAutomationPeer::SignalCursorChanged()
{
_CursorChangedHandlers(*this, nullptr);
CursorChanged.raise(*this, nullptr);
}
void InteractivityAutomationPeer::NotifyNewOutput(std::wstring_view newOutput)
{
_NewOutputHandlers(*this, hstring{ newOutput });
NewOutput.raise(*this, hstring{ newOutput });
}
#pragma region ITextProvider

View File

@ -71,10 +71,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
virtual HRESULT GetHostUiaProvider(IRawElementProviderSimple** provider) override;
#pragma endregion
TYPED_EVENT(SelectionChanged, IInspectable, IInspectable);
TYPED_EVENT(TextChanged, IInspectable, IInspectable);
TYPED_EVENT(CursorChanged, IInspectable, IInspectable);
TYPED_EVENT(NewOutput, IInspectable, hstring);
til::typed_event<IInspectable, IInspectable> SelectionChanged;
til::typed_event<IInspectable, IInspectable> TextChanged;
til::typed_event<IInspectable, IInspectable> CursorChanged;
til::typed_event<IInspectable, hstring> NewOutput;
private:
Windows::UI::Xaml::Automation::Provider::ITextRangeProvider _CreateXamlUiaTextRange(::ITextRangeProvider* returnVal) const;

View File

@ -28,7 +28,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// to immediately perform the search with the value appearing in the box.
if (Visibility() == Visibility::Visible)
{
_SearchChangedHandlers(TextBox().Text(), _GoForward(), _CaseSensitive());
SearchChanged.raise(TextBox().Text(), _GoForward(), _CaseSensitive());
}
});
@ -86,11 +86,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
const auto state = CoreWindow::GetForCurrentThread().GetKeyState(winrt::Windows::System::VirtualKey::Shift);
if (WI_IsFlagSet(state, CoreVirtualKeyStates::Down))
{
_SearchHandlers(TextBox().Text(), !_GoForward(), _CaseSensitive());
Search.raise(TextBox().Text(), !_GoForward(), _CaseSensitive());
}
else
{
_SearchHandlers(TextBox().Text(), _GoForward(), _CaseSensitive());
Search.raise(TextBox().Text(), _GoForward(), _CaseSensitive());
}
e.Handled(true);
}
@ -110,7 +110,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
if (e.OriginalKey() == winrt::Windows::System::VirtualKey::Escape)
{
_ClosedHandlers(*this, e);
Closed.raise(*this, e);
e.Handled(true);
}
}
@ -181,7 +181,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
// kick off search
_SearchHandlers(TextBox().Text(), _GoForward(), _CaseSensitive());
Search.raise(TextBox().Text(), _GoForward(), _CaseSensitive());
}
// Method Description:
@ -202,7 +202,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
// kick off search
_SearchHandlers(TextBox().Text(), _GoForward(), _CaseSensitive());
Search.raise(TextBox().Text(), _GoForward(), _CaseSensitive());
}
// Method Description:
@ -215,7 +215,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - <none>
void SearchBoxControl::CloseClick(const winrt::Windows::Foundation::IInspectable& /*sender*/, const RoutedEventArgs& e)
{
_ClosedHandlers(*this, e);
Closed.raise(*this, e);
}
// Method Description:
@ -240,7 +240,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - <none>
void SearchBoxControl::TextBoxTextChanged(winrt::Windows::Foundation::IInspectable const& /*sender*/, winrt::Windows::UI::Xaml::RoutedEventArgs const& /*e*/)
{
_SearchChangedHandlers(TextBox().Text(), _GoForward(), _CaseSensitive());
SearchChanged.raise(TextBox().Text(), _GoForward(), _CaseSensitive());
}
// Method Description:
@ -252,7 +252,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - <none>
void SearchBoxControl::CaseSensitivityButtonClicked(winrt::Windows::Foundation::IInspectable const& /*sender*/, winrt::Windows::UI::Xaml::RoutedEventArgs const& /*e*/)
{
_SearchChangedHandlers(TextBox().Text(), _GoForward(), _CaseSensitive());
SearchChanged.raise(TextBox().Text(), _GoForward(), _CaseSensitive());
}
// Method Description:

View File

@ -44,9 +44,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void TextBoxTextChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
void CaseSensitivityButtonClicked(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
WINRT_CALLBACK(Search, SearchHandler);
WINRT_CALLBACK(SearchChanged, SearchHandler);
TYPED_EVENT(Closed, Control::SearchBoxControl, Windows::UI::Xaml::RoutedEventArgs);
til::event<SearchHandler> Search;
til::event<SearchHandler> SearchChanged;
til::typed_event<Control::SearchBoxControl, Windows::UI::Xaml::RoutedEventArgs> Closed;
private:
std::unordered_set<winrt::Windows::Foundation::IInspectable> _focusableElements;

View File

@ -124,7 +124,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// Get the cursor position in text buffer position
auto cursorArgs = winrt::make_self<CursorPositionEventArgs>();
_CurrentCursorPositionHandlers(*this, *cursorArgs);
CurrentCursorPosition.raise(*this, *cursorArgs);
const til::point cursorPos{ til::math::flooring, cursorArgs->CurrentPosition() };
const auto actualCanvasWidth{ Canvas().ActualWidth() };
@ -159,7 +159,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
// Get Font Info as we use this is the pixel size for characters in the display
auto fontArgs = winrt::make_self<FontInfoEventArgs>();
_CurrentFontInfoHandlers(*this, *fontArgs);
CurrentFontInfo.raise(*this, *fontArgs);
const til::size fontSize{ til::math::flooring, fontArgs->FontSize() };
@ -408,7 +408,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return;
}
_CompositionCompletedHandlers(text);
CompositionCompleted.raise(text);
_activeTextStart = _inputBuffer.size();

View File

@ -43,9 +43,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void Close();
// -------------------------------- WinRT Events ---------------------------------
TYPED_EVENT(CurrentCursorPosition, Control::TSFInputControl, Control::CursorPositionEventArgs);
TYPED_EVENT(CurrentFontInfo, Control::TSFInputControl, Control::FontInfoEventArgs);
WINRT_CALLBACK(CompositionCompleted, Control::CompositionCompletedEventArgs);
til::typed_event<Control::TSFInputControl, Control::CursorPositionEventArgs> CurrentCursorPosition;
til::typed_event<Control::TSFInputControl, Control::FontInfoEventArgs> CurrentFontInfo;
til::event<Control::CompositionCompletedEventArgs> CompositionCompleted;
private:
void _layoutRequestedHandler(winrt::Windows::UI::Text::Core::CoreTextEditContext sender, const winrt::Windows::UI::Text::Core::CoreTextLayoutRequestedEventArgs& args);

View File

@ -131,7 +131,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
[weakThis = get_weak()]() {
if (auto control{ weakThis.get() }; !control->_IsClosing())
{
control->_WarningBellHandlers(*control, nullptr);
control->WarningBell.raise(*control, nullptr);
}
});
@ -616,9 +616,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void TermControl::SendInput(const winrt::hstring& wstr)
{
// only broadcast if there's an actual listener. Saves the overhead of some object creation.
if (_StringSentHandlers)
if (StringSent)
{
_StringSentHandlers(*this, winrt::make<StringSentEventArgs>(wstr));
StringSent.raise(*this, winrt::make<StringSentEventArgs>(wstr));
}
RawWriteString(wstr);
@ -868,7 +868,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
//
// Firing it manually makes sure it does.
_BackgroundBrush = RootGrid().Background();
_PropertyChangedHandlers(*this, Data::PropertyChangedEventArgs{ L"BackgroundBrush" });
PropertyChanged.raise(*this, Data::PropertyChangedEventArgs{ L"BackgroundBrush" });
_isBackgroundLight = _isColorLight(bg);
}
@ -921,7 +921,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// transparency of the titlebar too.
if (changed)
{
_PropertyChangedHandlers(*this, Data::PropertyChangedEventArgs{ L"BackgroundBrush" });
PropertyChanged.raise(*this, Data::PropertyChangedEventArgs{ L"BackgroundBrush" });
}
}
@ -1021,7 +1021,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
auto noticeArgs = winrt::make<NoticeEventArgs>(NoticeLevel::Warning, std::move(message));
control->_RaiseNoticeHandlers(*control, std::move(noticeArgs));
control->RaiseNotice.raise(*control, std::move(noticeArgs));
}
}
@ -1142,7 +1142,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// Likewise, run the event handlers outside of lock (they could
// be reentrant)
_InitializedHandlers(*this, nullptr);
Initialized.raise(*this, nullptr);
return true;
}
@ -1167,7 +1167,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// to simply force TSF to clear its text whenever we have input focus.
TSFInputControl().ClearBuffer();
_HidePointerCursorHandlers(*this, nullptr);
HidePointerCursor.raise(*this, nullptr);
const auto ch = e.Character();
const auto keyStatus = e.KeyStatus();
@ -1181,10 +1181,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// Broadcast the character to all listeners
// only broadcast if there's an actual listener. Saves the overhead of some object creation.
if (_CharSentHandlers)
if (CharSent)
{
auto charSentArgs = winrt::make<CharSentEventArgs>(ch, scanCode, modifiers);
_CharSentHandlers(*this, charSentArgs);
CharSent.raise(*this, charSentArgs);
}
const auto handled = RawWriteChar(ch, scanCode, modifiers);
@ -1453,10 +1453,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
// Broadcast the key to all listeners
// only broadcast if there's an actual listener. Saves the overhead of some object creation.
if (_KeySentHandlers)
if (KeySent)
{
auto keySentArgs = winrt::make<KeySentEventArgs>(vkey, scanCode, modifiers, keyDown);
_KeySentHandlers(*this, keySentArgs);
KeySent.raise(*this, keySentArgs);
}
return RawWriteKeyEvent(vkey, scanCode, modifiers, keyDown);
@ -1519,7 +1519,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return;
}
_RestorePointerCursorHandlers(*this, nullptr);
RestorePointerCursor.raise(*this, nullptr);
_CapturePointer(sender, args);
@ -1574,7 +1574,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return;
}
_RestorePointerCursorHandlers(*this, nullptr);
RestorePointerCursor.raise(*this, nullptr);
const auto ptr = args.Pointer();
const auto point = args.GetCurrentPoint(*this);
@ -1584,7 +1584,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
if (!_focused && _core.Settings().FocusFollowMouse())
{
_FocusFollowMouseRequestedHandlers(*this, nullptr);
FocusFollowMouseRequested.raise(*this, nullptr);
}
if (type == Windows::Devices::Input::PointerDeviceType::Mouse ||
@ -1700,7 +1700,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return;
}
_RestorePointerCursorHandlers(*this, nullptr);
RestorePointerCursor.raise(*this, nullptr);
const auto point = args.GetCurrentPoint(*this);
// GH#10329 - we don't need to handle horizontal scrolls. Only vertical ones.
@ -1994,7 +1994,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return;
}
_RestorePointerCursorHandlers(*this, nullptr);
RestorePointerCursor.raise(*this, nullptr);
_focused = false;
@ -2263,7 +2263,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
autoPeerImpl->Close();
}
_RestorePointerCursorHandlers(*this, nullptr);
RestorePointerCursor.raise(*this, nullptr);
_revokers = {};
@ -2962,9 +2962,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void TermControl::_pasteTextWithBroadcast(const winrt::hstring& text)
{
// only broadcast if there's an actual listener. Saves the overhead of some object creation.
if (_StringSentHandlers)
if (StringSent)
{
_StringSentHandlers(*this, winrt::make<StringSentEventArgs>(text));
StringSent.raise(*this, winrt::make<StringSentEventArgs>(text));
}
_core.PasteText(text);
}
@ -3033,7 +3033,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// (like ShellExecute pumping our messaging thread...GH#7994)
co_await winrt::resume_foreground(Dispatcher());
_OpenHyperlinkHandlers(*strongThis, args);
OpenHyperlink.raise(*strongThis, args);
}
// Method Description:
@ -3167,7 +3167,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void TermControl::ToggleReadOnly()
{
_core.ToggleReadOnlyMode();
_ReadOnlyChangedHandlers(*this, winrt::box_value(_core.IsInReadOnlyMode()));
ReadOnlyChanged.raise(*this, winrt::box_value(_core.IsInReadOnlyMode()));
}
// Method Description:
@ -3175,7 +3175,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void TermControl::SetReadOnly(const bool readOnlyState)
{
_core.SetReadOnlyMode(readOnlyState);
_ReadOnlyChangedHandlers(*this, winrt::box_value(_core.IsInReadOnlyMode()));
ReadOnlyChanged.raise(*this, winrt::box_value(_core.IsInReadOnlyMode()));
}
// Method Description:
@ -3388,7 +3388,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// while it's holding its write lock. If the handlers calls back to some
// method on the TermControl on the same thread, and _that_ method calls
// to ControlCore, we might be in danger of deadlocking.
_RaiseNoticeHandlers(*this, eventArgs);
RaiseNotice.raise(*this, eventArgs);
}
Control::MouseButtonState TermControl::GetPressedMouseButtons(const winrt::Windows::UI::Input::PointerPoint point)

View File

@ -165,7 +165,19 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// -------------------------------- WinRT Events ---------------------------------
// clang-format off
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
til::property_changed_event PropertyChanged;
til::typed_event<IInspectable, Control::OpenHyperlinkEventArgs> OpenHyperlink;
til::typed_event<IInspectable, Control::NoticeEventArgs> RaiseNotice;
til::typed_event<> HidePointerCursor;
til::typed_event<> RestorePointerCursor;
til::typed_event<> ReadOnlyChanged;
til::typed_event<IInspectable, IInspectable> FocusFollowMouseRequested;
til::typed_event<Control::TermControl, Windows::UI::Xaml::RoutedEventArgs> Initialized;
til::typed_event<> WarningBell;
til::typed_event<IInspectable, Control::KeySentEventArgs> KeySent;
til::typed_event<IInspectable, Control::CharSentEventArgs> CharSent;
til::typed_event<IInspectable, Control::StringSentEventArgs> StringSent;
// UNDER NO CIRCUMSTANCES SHOULD YOU ADD A (PROJECTED_)FORWARDED_TYPED_EVENT HERE
// Those attach the handler to the core directly, and will explode if
@ -182,20 +194,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
BUBBLED_FORWARDED_TYPED_EVENT(PasteFromClipboard, IInspectable, Control::PasteFromClipboardEventArgs);
TYPED_EVENT(OpenHyperlink, IInspectable, Control::OpenHyperlinkEventArgs);
TYPED_EVENT(RaiseNotice, IInspectable, Control::NoticeEventArgs);
TYPED_EVENT(HidePointerCursor, IInspectable, IInspectable);
TYPED_EVENT(RestorePointerCursor, IInspectable, IInspectable);
TYPED_EVENT(ReadOnlyChanged, IInspectable, IInspectable);
TYPED_EVENT(FocusFollowMouseRequested, IInspectable, IInspectable);
TYPED_EVENT(Initialized, Control::TermControl, Windows::UI::Xaml::RoutedEventArgs);
TYPED_EVENT(WarningBell, IInspectable, IInspectable);
TYPED_EVENT(KeySent, IInspectable, Control::KeySentEventArgs);
TYPED_EVENT(CharSent, IInspectable, Control::CharSentEventArgs);
TYPED_EVENT(StringSent, IInspectable, Control::StringSentEventArgs);
// clang-format on
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::UI::Xaml::Media::Brush, BackgroundBrush, _PropertyChangedHandlers, nullptr);
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::UI::Xaml::Media::Brush, BackgroundBrush, PropertyChanged.raise, nullptr);
private:
friend struct TermControlT<TermControl>; // friend our parent so it can bind private event handlers

View File

@ -20,8 +20,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void AddNew_Click(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(Editor::ActionsViewModel, ViewModel, _PropertyChangedHandlers, nullptr);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(Editor::ActionsViewModel, ViewModel, PropertyChanged.raise, nullptr);
};
}

View File

@ -90,14 +90,14 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
newKeys, // NewKeys
_IsNewlyAdded ? hstring{} : _CurrentAction, // OldAction
unbox_value<hstring>(_ProposedAction)) }; // NewAction
_ModifyKeyBindingRequestedHandlers(*this, *args);
ModifyKeyBindingRequested.raise(*this, *args);
}
void KeyBindingViewModel::CancelChanges()
{
if (_IsNewlyAdded)
{
_DeleteNewlyAddedKeyBindingHandlers(*this, nullptr);
DeleteNewlyAddedKeyBinding.raise(*this, nullptr);
}
else
{
@ -158,13 +158,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
// We also have to do this manually because it hasn't been added to the list yet.
kbdVM->IsInEditMode(true);
// Emit an event to let the page know to update the background of this key binding VM
_UpdateBackgroundHandlers(*this, *kbdVM);
UpdateBackground.raise(*this, *kbdVM);
// IMPORTANT: do this _after_ setting IsInEditMode. Otherwise, it'll get deleted immediately
// by the PropertyChangedHandler below (where we delete any IsNewlyAdded items)
kbdVM->IsNewlyAdded(true);
_KeyBindingList.InsertAt(0, *kbdVM);
_FocusContainerHandlers(*this, *kbdVM);
FocusContainer.raise(*this, *kbdVM);
}
void ActionsViewModel::_KeyBindingViewModelPropertyChangedHandler(const IInspectable& sender, const Windows::UI::Xaml::Data::PropertyChangedEventArgs& args)
@ -187,7 +187,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
// This is the view model entry that went into edit mode.
// Emit an event to let the page know to move focus to
// this VM's container.
_FocusContainerHandlers(*this, senderVM);
FocusContainer.raise(*this, senderVM);
}
else if (kbdVM.IsNewlyAdded())
{
@ -205,11 +205,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
// Emit an event to let the page know to move focus to
// this VM's container.
_FocusContainerHandlers(*this, senderVM);
FocusContainer.raise(*this, senderVM);
}
// Emit an event to let the page know to update the background of this key binding VM
_UpdateBackgroundHandlers(*this, senderVM);
UpdateBackground.raise(*this, senderVM);
}
}
@ -231,7 +231,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
const auto newFocusedIndex{ std::clamp(index, 0u, _KeyBindingList.Size() - 1) };
// Emit an event to let the page know to move focus to
// this VM's container.
_FocusContainerHandlers(*this, winrt::box_value(newFocusedIndex));
FocusContainer.raise(*this, winrt::box_value(newFocusedIndex));
}
}
}

View File

@ -61,7 +61,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void AttemptAcceptChanges();
void AttemptAcceptChanges(const Control::KeyChord newKeys);
void CancelChanges();
void DeleteKeyBinding() { _DeleteKeyBindingRequestedHandlers(*this, _CurrentKeys); }
void DeleteKeyBinding() { DeleteKeyBindingRequested.raise(*this, _CurrentKeys); }
// ProposedAction: the entry selected by the combo box; may disagree with the settings model.
// CurrentAction: the combo box item that maps to the settings model value.
@ -89,9 +89,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
VIEW_MODEL_OBSERVABLE_PROPERTY(bool, IsContainerFocused, false);
VIEW_MODEL_OBSERVABLE_PROPERTY(bool, IsEditButtonFocused, false);
VIEW_MODEL_OBSERVABLE_PROPERTY(Windows::UI::Xaml::Media::Brush, ContainerBackground, nullptr);
TYPED_EVENT(ModifyKeyBindingRequested, Editor::KeyBindingViewModel, Editor::ModifyKeyBindingEventArgs);
TYPED_EVENT(DeleteKeyBindingRequested, Editor::KeyBindingViewModel, Terminal::Control::KeyChord);
TYPED_EVENT(DeleteNewlyAddedKeyBinding, Editor::KeyBindingViewModel, IInspectable);
public:
til::typed_event<Editor::KeyBindingViewModel, Editor::ModifyKeyBindingEventArgs> ModifyKeyBindingRequested;
til::typed_event<Editor::KeyBindingViewModel, Terminal::Control::KeyChord> DeleteKeyBindingRequested;
til::typed_event<Editor::KeyBindingViewModel, IInspectable> DeleteNewlyAddedKeyBinding;
private:
hstring _KeyChordText{};
@ -105,9 +107,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void OnAutomationPeerAttached();
void AddNewKeybinding();
til::typed_event<IInspectable, IInspectable> FocusContainer;
til::typed_event<IInspectable, IInspectable> UpdateBackground;
WINRT_PROPERTY(Windows::Foundation::Collections::IObservableVector<Editor::KeyBindingViewModel>, KeyBindingList);
TYPED_EVENT(FocusContainer, IInspectable, IInspectable);
TYPED_EVENT(UpdateBackground, IInspectable, IInspectable);
private:
bool _AutomationPeerAttached{ false };

View File

@ -31,16 +31,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void RequestAddNew()
{
_AddNewHandlers(winrt::guid{});
AddNew.raise(winrt::guid{});
}
void RequestDuplicate(GUID profile)
{
_AddNewHandlers(profile);
AddNew.raise(profile);
}
WINRT_PROPERTY(Model::CascadiaSettings, Settings, nullptr)
WINRT_CALLBACK(AddNew, AddNewArgs);
til::event<AddNewArgs> AddNew;
WINRT_PROPERTY(Model::CascadiaSettings, Settings, nullptr);
};
struct AddProfile : public HasScrollViewer<AddProfile>, AddProfileT<AddProfile>
@ -54,9 +55,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void DuplicateClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
void ProfilesSelectionChanged(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
til::property_changed_event PropertyChanged;
WINRT_PROPERTY(Editor::AddProfilePageNavigationState, State, nullptr);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(bool, IsProfileSelected, _PropertyChangedHandlers, nullptr);
WINRT_OBSERVABLE_PROPERTY(bool, IsProfileSelected, PropertyChanged.raise, nullptr);
};
}

View File

@ -220,7 +220,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_baseMap.Remove(_AxisKey);
_AxisValue = axisValue;
_baseMap.Insert(_AxisKey, _AxisValue);
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"AxisValue" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"AxisValue" });
}
}
@ -231,7 +231,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_baseMap.Remove(_AxisKey);
_AxisKey = axisKey;
_baseMap.Insert(_AxisKey, _AxisValue);
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"AxisKey" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"AxisKey" });
}
}
@ -301,7 +301,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_baseMap.Remove(_FeatureKey);
_FeatureValue = featureValue;
_baseMap.Insert(_FeatureKey, _FeatureValue);
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"FeatureValue" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"FeatureValue" });
}
}
@ -312,7 +312,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_baseMap.Remove(_FeatureKey);
_FeatureKey = featureKey;
_baseMap.Insert(_FeatureKey, _FeatureValue);
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"FeatureKey" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"FeatureKey" });
}
}
@ -878,7 +878,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
if (_ShowAllFonts != value)
{
_ShowAllFonts = value;
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"ShowAllFonts" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"ShowAllFonts" });
}
}
@ -974,16 +974,16 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
const auto settingName{ args.PropertyName() };
if (settingName == L"CursorShape")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentCursorShape" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"IsVintageCursor" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentCursorShape" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"IsVintageCursor" });
}
else if (settingName == L"DarkColorSchemeName" || settingName == L"LightColorSchemeName")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentColorScheme" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentColorScheme" });
}
else if (settingName == L"BackgroundImageStretchMode")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentBackgroundImageStretchMode" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentBackgroundImageStretchMode" });
}
else if (settingName == L"BackgroundImageAlignment")
{
@ -991,8 +991,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
else if (settingName == L"FontWeight")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentFontWeight" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"IsCustomFontWeight" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentFontWeight" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"IsCustomFontWeight" });
}
else if (settingName == L"FontFace" || settingName == L"CurrentFontList")
{
@ -1001,28 +1001,28 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
_ShowAllFonts = true;
}
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentFontFace" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"ShowAllFonts" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"UsingMonospaceFont" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentFontFace" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"ShowAllFonts" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"UsingMonospaceFont" });
}
else if (settingName == L"IntenseTextStyle")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentIntenseTextStyle" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentIntenseTextStyle" });
}
else if (settingName == L"AdjustIndistinguishableColors")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentAdjustIndistinguishableColors" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentAdjustIndistinguishableColors" });
}
else if (settingName == L"ShowProportionalFontWarning")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"ShowProportionalFontWarning" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"ShowProportionalFontWarning" });
}
// YOU THERE ADDING A NEW APPEARANCE SETTING
// Make sure you add a block like
//
// else if (settingName == L"MyNewSetting")
// {
// _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentMyNewSetting" });
// PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentMyNewSetting" });
// }
//
// To make sure that changes to the AppearanceViewModel will
@ -1036,19 +1036,19 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
// make sure to send all the property changed events once here
// we do this in the case an old appearance was deleted and then a new one is created,
// the old settings need to be updated in xaml
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentCursorShape" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"IsVintageCursor" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentColorScheme" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentBackgroundImageStretchMode" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentCursorShape" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"IsVintageCursor" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentColorScheme" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentBackgroundImageStretchMode" });
_UpdateBIAlignmentControl(static_cast<int32_t>(Appearance().BackgroundImageAlignment()));
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentFontWeight" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"IsCustomFontWeight" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentFontFace" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"ShowAllFonts" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"UsingMonospaceFont" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentIntenseTextStyle" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentAdjustIndistinguishableColors" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"ShowProportionalFontWarning" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentFontWeight" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"IsCustomFontWeight" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentFontFace" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"ShowAllFonts" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"UsingMonospaceFont" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentIntenseTextStyle" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"CurrentAdjustIndistinguishableColors" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"ShowProportionalFontWarning" });
}
}
@ -1150,7 +1150,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
// So the TwoWay binding doesn't update on the State --> Slider direction
FontWeightSlider().Value(weight);
}
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"IsCustomFontWeight" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"IsCustomFontWeight" });
}
}

View File

@ -70,7 +70,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
int32_t AxisIndex();
void AxisIndex(int32_t axisIndex);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
til::property_changed_event PropertyChanged;
private:
winrt::hstring _AxisKey;
@ -93,7 +93,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
int32_t FeatureIndex();
void FeatureIndex(int32_t featureIndex);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
til::property_changed_event PropertyChanged;
private:
winrt::hstring _FeatureKey;
@ -204,19 +204,21 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
Windows::Foundation::IInspectable CurrentFontWeight() const;
void CurrentFontWeight(const Windows::Foundation::IInspectable& enumEntry);
bool IsCustomFontWeight();
til::property_changed_event PropertyChanged;
WINRT_PROPERTY(Windows::Foundation::Collections::IObservableVector<Microsoft::Terminal::Settings::Editor::EnumEntry>, FontWeightList);
GETSET_BINDABLE_ENUM_SETTING(CursorShape, Microsoft::Terminal::Core::CursorStyle, Appearance().CursorShape);
GETSET_BINDABLE_ENUM_SETTING(AdjustIndistinguishableColors, Microsoft::Terminal::Core::AdjustTextMode, Appearance().AdjustIndistinguishableColors);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
DEPENDENCY_PROPERTY(Editor::AppearanceViewModel, Appearance);
WINRT_PROPERTY(Editor::ProfileViewModel, SourceProfile, nullptr);
WINRT_PROPERTY(IHostedInWindow, WindowRoot, nullptr);
GETSET_BINDABLE_ENUM_SETTING(BackgroundImageStretchMode, Windows::UI::Xaml::Media::Stretch, Appearance().BackgroundImageStretchMode);
GETSET_BINDABLE_ENUM_SETTING(IntenseTextStyle, Microsoft::Terminal::Settings::Model::IntenseStyle, Appearance().IntenseTextStyle);
WINRT_OBSERVABLE_PROPERTY(bool, ShowProportionalFontWarning, _PropertyChangedHandlers, nullptr);
WINRT_OBSERVABLE_PROPERTY(bool, ShowProportionalFontWarning, PropertyChanged.raise, nullptr);
private:
bool _ShowAllFonts;

View File

@ -209,7 +209,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
const auto propertyName{ args.PropertyName() };
if (propertyName == L"Color" || propertyName == L"Name")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"AccessibleName" });
PropertyChanged.raise(*this, PropertyChangedEventArgs{ L"AccessibleName" });
}
}

View File

@ -69,10 +69,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
return hstring{ fmt::format(FMT_COMPILE(L"{} RGB({}, {}, {})"), _Name, _Color.R, _Color.G, _Color.B) };
}
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(Windows::UI::Color, Color, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Name, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(IInspectable, Tag, _PropertyChangedHandlers);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(Windows::UI::Color, Color, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Name, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(IInspectable, Tag, PropertyChanged.raise);
private:
Windows::UI::Color _color;

View File

@ -21,10 +21,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void AddNew_Click(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
void ListView_PreviewKeyDown(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs& e);
WINRT_PROPERTY(Model::ColorScheme, CurrentColorScheme, nullptr);
WINRT_OBSERVABLE_PROPERTY(Editor::ColorSchemesPageViewModel, ViewModel, _PropertyChangedHandlers, nullptr);
til::property_changed_event PropertyChanged;
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_PROPERTY(Model::ColorScheme, CurrentColorScheme, nullptr);
WINRT_OBSERVABLE_PROPERTY(Editor::ColorSchemesPageViewModel, ViewModel, PropertyChanged.raise, nullptr);
private:
winrt::Windows::UI::Xaml::FrameworkElement::LayoutUpdated_revoker _layoutUpdatedRevoker;

View File

@ -20,9 +20,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void RenameCancel_Click(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
void NameBox_PreviewKeyDown(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs& e);
WINRT_OBSERVABLE_PROPERTY(Editor::ColorSchemeViewModel, ViewModel, _PropertyChangedHandlers, nullptr);
til::property_changed_event PropertyChanged;
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(Editor::ColorSchemeViewModel, ViewModel, PropertyChanged.raise, nullptr);
private:
void _RenameCurrentScheme(hstring newName);

View File

@ -51,8 +51,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
return EnumName();
}
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, EnumName, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::Foundation::IInspectable, EnumValue, _PropertyChangedHandlers);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, EnumName, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::Foundation::IInspectable, EnumValue, PropertyChanged.raise);
};
}

View File

@ -15,8 +15,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(Editor::GlobalAppearanceViewModel, ViewModel, _PropertyChangedHandlers, nullptr);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(Editor::GlobalAppearanceViewModel, ViewModel, PropertyChanged.raise, nullptr);
};
}

View File

@ -14,8 +14,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(Editor::InteractionViewModel, ViewModel, _PropertyChangedHandlers, nullptr);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(Editor::InteractionViewModel, ViewModel, PropertyChanged.raise, nullptr);
};
}

View File

@ -15,8 +15,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(Editor::LaunchViewModel, ViewModel, _PropertyChangedHandlers, nullptr);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(Editor::LaunchViewModel, ViewModel, PropertyChanged.raise, nullptr);
};
}

View File

@ -467,7 +467,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
WI_IsFlagSet(rAltState, CoreVirtualKeyStates::Down);
const auto target = altPressed ? SettingsTarget::DefaultsFile : SettingsTarget::SettingsFile;
_OpenJsonHandlers(nullptr, target);
OpenJson.raise(nullptr, target);
}
void MainPage::OpenJsonKeyDown(const IInspectable& /*sender*/, const Windows::UI::Xaml::Input::KeyRoutedEventArgs& args)
@ -475,7 +475,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
if (args.Key() == VirtualKey::Enter || args.Key() == VirtualKey::Space)
{
const auto target = args.KeyStatus().IsMenuKeyDown ? SettingsTarget::DefaultsFile : SettingsTarget::SettingsFile;
_OpenJsonHandlers(nullptr, target);
OpenJson.raise(nullptr, target);
}
}
@ -622,7 +622,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
});
// Add an event handler for when the user wants to delete a profile.
profile.DeleteProfile({ this, &MainPage::_DeleteProfile });
profile.DeleteProfileRequested({ this, &MainPage::_DeleteProfile });
return profileNavItem;
}

View File

@ -46,7 +46,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
Windows::Foundation::Collections::IObservableVector<IInspectable> Breadcrumbs() noexcept;
TYPED_EVENT(OpenJson, Windows::Foundation::IInspectable, Model::SettingsTarget);
til::typed_event<Windows::Foundation::IInspectable, Model::SettingsTarget> OpenJson;
private:
Windows::Foundation::Collections::IObservableVector<IInspectable> _breadcrumbs;

View File

@ -32,7 +32,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void PreviewConnection::Start() noexcept
{
// Send the preview text
_TerminalOutputHandlers(fmt::format(PreviewText, _displayPowerlineGlyphs ? PromptTextPowerline : PromptTextPlain));
TerminalOutput.raise(fmt::format(PreviewText, _displayPowerlineGlyphs ? PromptTextPowerline : PromptTextPlain));
}
void PreviewConnection::Initialize(const Windows::Foundation::Collections::ValueSet& /*settings*/) noexcept

View File

@ -32,8 +32,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
winrt::guid SessionId() const noexcept { return {}; }
winrt::Microsoft::Terminal::TerminalConnection::ConnectionState State() const noexcept { return winrt::Microsoft::Terminal::TerminalConnection::ConnectionState::Connected; }
WINRT_CALLBACK(TerminalOutput, winrt::Microsoft::Terminal::TerminalConnection::TerminalOutputHandler);
TYPED_EVENT(StateChanged, winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection, IInspectable);
til::event<winrt::Microsoft::Terminal::TerminalConnection::TerminalOutputHandler> TerminalOutput;
til::typed_event<winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection, IInspectable> StateChanged;
private:
bool _displayPowerlineGlyphs{ false };

View File

@ -398,7 +398,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void ProfileViewModel::DeleteProfile()
{
auto deleteProfileArgs{ winrt::make_self<DeleteProfileEventArgs>(Guid()) };
_DeleteProfileHandlers(*this, *deleteProfileArgs);
DeleteProfileRequested.raise(*this, *deleteProfileArgs);
}
void ProfileViewModel::SetupAppearances(Windows::Foundation::Collections::IObservableVector<Editor::ColorSchemeViewModel> schemesList)

View File

@ -83,6 +83,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void DeleteUnfocusedAppearance();
bool VtPassthroughAvailable() const noexcept;
til::typed_event<Editor::ProfileViewModel, Editor::DeleteProfileEventArgs> DeleteProfileRequested;
VIEW_MODEL_OBSERVABLE_PROPERTY(ProfileSubPage, CurrentPage);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_profile, Guid);
@ -120,8 +122,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
GETSET_BINDABLE_ENUM_SETTING(CloseOnExitMode, Microsoft::Terminal::Settings::Model::CloseOnExitMode, CloseOnExit);
GETSET_BINDABLE_ENUM_SETTING(ScrollState, Microsoft::Terminal::Control::ScrollbarState, ScrollState);
TYPED_EVENT(DeleteProfile, Editor::ProfileViewModel, Editor::DeleteProfileEventArgs);
private:
Model::Profile _profile;
winrt::guid _originalProfileGuid{};

View File

@ -40,7 +40,7 @@ namespace Microsoft.Terminal.Settings.Editor
Microsoft.Terminal.Settings.Model.TerminalSettings TermSettings { get; };
event Windows.Foundation.TypedEventHandler<ProfileViewModel, DeleteProfileEventArgs> DeleteProfile;
event Windows.Foundation.TypedEventHandler<ProfileViewModel, DeleteProfileEventArgs> DeleteProfileRequested;
void SetupAppearances(Windows.Foundation.Collections.IObservableVector<ColorSchemeViewModel> schemesList);

View File

@ -17,7 +17,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void OnNavigatedTo(const Windows::UI::Xaml::Navigation::NavigationEventArgs& e);
void OnNavigatedFrom(const Windows::UI::Xaml::Navigation::NavigationEventArgs& e);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
til::property_changed_event PropertyChanged;
WINRT_PROPERTY(Editor::ProfileViewModel, Profile, nullptr);
private:

View File

@ -22,7 +22,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
Editor::IHostedInWindow WindowRoot() { return _windowRoot; };
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
til::property_changed_event PropertyChanged;
WINRT_PROPERTY(Editor::ProfileViewModel, Profile, nullptr);
private:

View File

@ -24,7 +24,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void Advanced_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);
void DeleteConfirmation_Click(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
til::property_changed_event PropertyChanged;
WINRT_PROPERTY(Editor::ProfileViewModel, Profile, nullptr);
private:

View File

@ -14,8 +14,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(Editor::RenderingViewModel, ViewModel, _PropertyChangedHandlers, nullptr);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(Editor::RenderingViewModel, ViewModel, PropertyChanged.raise, nullptr);
};
}

View File

@ -100,7 +100,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
// When clicked, we dispatch the bound ClearSettingValue event,
// resulting in inheriting the setting value from the parent.
button.Click([=](auto&&, auto&&) {
_ClearSettingValueHandlers(*this, nullptr);
ClearSettingValue.raise(*this, nullptr);
// move the focus to the child control
if (const auto& content{ Content() })

View File

@ -31,13 +31,14 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void SetExpanded(bool expanded);
til::typed_event<Editor::SettingContainer, Windows::Foundation::IInspectable> ClearSettingValue;
DEPENDENCY_PROPERTY(Windows::Foundation::IInspectable, Header);
DEPENDENCY_PROPERTY(hstring, HelpText);
DEPENDENCY_PROPERTY(hstring, CurrentValue);
DEPENDENCY_PROPERTY(bool, HasSettingValue);
DEPENDENCY_PROPERTY(bool, StartExpanded);
DEPENDENCY_PROPERTY(IInspectable, SettingOverrideSource);
TYPED_EVENT(ClearSettingValue, Editor::SettingContainer, Windows::Foundation::IInspectable);
private:
static void _InitializeProperties();

View File

@ -57,5 +57,6 @@
// Manually include til after we include Windows.Foundation to give it winrt superpowers
#include "til.h"
#include <til/winrt.h>
#include <cppwinrt_utils.h>

View File

@ -18,7 +18,7 @@ namespace ControlUnitTests
void Start() noexcept {};
void WriteInput(const winrt::hstring& data)
{
_TerminalOutputHandlers(data);
TerminalOutput.raise(data);
}
void Resize(uint32_t /*rows*/, uint32_t /*columns*/) noexcept {}
void Close() noexcept {}
@ -26,7 +26,7 @@ namespace ControlUnitTests
winrt::guid SessionId() const noexcept { return {}; }
winrt::Microsoft::Terminal::TerminalConnection::ConnectionState State() const noexcept { return winrt::Microsoft::Terminal::TerminalConnection::ConnectionState::Connected; }
WINRT_CALLBACK(TerminalOutput, winrt::Microsoft::Terminal::TerminalConnection::TerminalOutputHandler);
TYPED_EVENT(StateChanged, winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection, IInspectable);
til::event<winrt::Microsoft::Terminal::TerminalConnection::TerminalOutputHandler> TerminalOutput;
til::typed_event<winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection, IInspectable> StateChanged;
};
}

View File

@ -87,19 +87,19 @@ namespace RemotingUnitTests
void Quit() DIE;
void AttachContentToWindow(Remoting::AttachRequest) DIE;
void SendContent(winrt::Microsoft::Terminal::Remoting::RequestReceiveContentArgs) DIE;
TYPED_EVENT(WindowActivated, winrt::Windows::Foundation::IInspectable, Remoting::WindowActivatedArgs);
TYPED_EVENT(ExecuteCommandlineRequested, winrt::Windows::Foundation::IInspectable, Remoting::CommandlineArgs);
TYPED_EVENT(IdentifyWindowsRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(DisplayWindowIdRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(RenameRequested, winrt::Windows::Foundation::IInspectable, Remoting::RenameRequestArgs);
TYPED_EVENT(SummonRequested, winrt::Windows::Foundation::IInspectable, Remoting::SummonWindowBehavior);
TYPED_EVENT(ShowNotificationIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(HideNotificationIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(QuitAllRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(QuitRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(GetWindowLayoutRequested, winrt::Windows::Foundation::IInspectable, Remoting::GetWindowLayoutArgs);
TYPED_EVENT(AttachRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::AttachRequest);
TYPED_EVENT(SendContentRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::RequestReceiveContentArgs);
til::typed_event<winrt::Windows::Foundation::IInspectable, Remoting::WindowActivatedArgs> WindowActivated;
til::typed_event<winrt::Windows::Foundation::IInspectable, Remoting::CommandlineArgs> ExecuteCommandlineRequested;
til::typed_event<> IdentifyWindowsRequested;
til::typed_event<> DisplayWindowIdRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, Remoting::RenameRequestArgs> RenameRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, Remoting::SummonWindowBehavior> SummonRequested;
til::typed_event<> ShowNotificationIconRequested;
til::typed_event<> HideNotificationIconRequested;
til::typed_event<> QuitAllRequested;
til::typed_event<> QuitRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, Remoting::GetWindowLayoutArgs> GetWindowLayoutRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::AttachRequest> AttachRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::RequestReceiveContentArgs> SendContentRequested;
};
// Same idea.
@ -121,13 +121,13 @@ namespace RemotingUnitTests
void RequestMoveContent(winrt::hstring, winrt::hstring, uint32_t, winrt::Windows::Foundation::IReference<winrt::Windows::Foundation::Rect>) DIE;
void RequestSendContent(Remoting::RequestReceiveContentArgs) DIE;
TYPED_EVENT(FindTargetWindowRequested, winrt::Windows::Foundation::IInspectable, Remoting::FindTargetWindowArgs);
TYPED_EVENT(ShowNotificationIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(HideNotificationIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(WindowCreated, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(WindowClosed, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(QuitAllRequested, winrt::Windows::Foundation::IInspectable, Remoting::QuitAllRequestedArgs);
TYPED_EVENT(RequestNewWindow, winrt::Windows::Foundation::IInspectable, Remoting::WindowRequestedArgs);
til::typed_event<winrt::Windows::Foundation::IInspectable, Remoting::FindTargetWindowArgs> FindTargetWindowRequested;
til::typed_event<> ShowNotificationIconRequested;
til::typed_event<> HideNotificationIconRequested;
til::typed_event<> WindowCreated;
til::typed_event<> WindowClosed;
til::typed_event<winrt::Windows::Foundation::IInspectable, Remoting::QuitAllRequestedArgs> QuitAllRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, Remoting::WindowRequestedArgs> RequestNewWindow;
};
class RemotingTests

View File

@ -43,6 +43,8 @@ class TerminalCoreUnitTests::TilWinRtHelpersTests final
TEST_METHOD(TestEvent);
TEST_METHOD(TestTypedEvent);
TEST_METHOD(TestPropertyChanged);
};
void TilWinRtHelpersTests::TestPropertySimple()
@ -243,3 +245,22 @@ void TilWinRtHelpersTests::TestTypedEvent()
VERIFY_ARE_EQUAL(true, handledOne);
VERIFY_ARE_EQUAL(true, handledTwo);
}
void TilWinRtHelpersTests::TestPropertyChanged()
{
auto handler = [&](const auto& /*sender*/, const auto& args) -> void {
VERIFY_ARE_EQUAL(L"BackgroundBrush", args.PropertyName());
};
til::property_changed_event PropertyChanged;
PropertyChanged(handler);
// We can't actually run this test in our usual unit tests. As you may
// suspect, because the PropertyChanged event is a _XAML_ event, it expects
// to be run on the UI thread. Which, we most definitely don't have here.
//
// At least, this does compile. We use this everywhere, so the scream test is LOUD.
// winrt::Windows::Foundation::IInspectable mySender{};
// PropertyChanged.raise(mySender, winrt::Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"BackgroundBrush" });
}

View File

@ -58,6 +58,7 @@ Author(s):
#include <winrt/Windows.system.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.UI.Xaml.Data.h>
#include <winrt/Microsoft.Terminal.Core.h>

View File

@ -1561,5 +1561,5 @@ void AppHost::_handleSendContent(const winrt::Windows::Foundation::IInspectable&
// thread.
void AppHost::_requestUpdateSettings()
{
_UpdateSettingsRequestedHandlers();
UpdateSettingsRequested.raise();
}

View File

@ -33,7 +33,7 @@ public:
static void s_DisplayMessageBox(const winrt::TerminalApp::ParseCommandlineResult& message);
WINRT_CALLBACK(UpdateSettingsRequested, winrt::delegate<void()>);
til::event<winrt::delegate<void()>> UpdateSettingsRequested;
private:
std::unique_ptr<IslandWindow> _window;

View File

@ -524,7 +524,7 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize
{
// wparam = 0 indicates the window was deactivated
const bool activated = LOWORD(wparam) != 0;
_WindowActivatedHandlers(activated);
WindowActivated.raise(activated);
if (_autoHideWindow && !activated)
{
@ -552,7 +552,7 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize
{
// If we clicked in the titlebar, raise an event so the app host can
// dispatch an appropriate event.
_DragRegionClickedHandlers();
DragRegionClicked.raise();
break;
}
case WM_MENUCHAR:
@ -570,13 +570,13 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize
{
if (wparam == SIZE_RESTORED || wparam == SIZE_MAXIMIZED)
{
_WindowVisibilityChangedHandlers(true);
_MaximizeChangedHandlers(wparam == SIZE_MAXIMIZED);
WindowVisibilityChanged.raise(true);
MaximizeChanged.raise(wparam == SIZE_MAXIMIZED);
}
if (wparam == SIZE_MINIMIZED)
{
_WindowVisibilityChangedHandlers(false);
WindowVisibilityChanged.raise(false);
if (_isQuakeWindow)
{
ShowWindow(GetHandle(), SW_HIDE);
@ -609,7 +609,7 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize
}
case WM_MOVE:
{
_WindowMovedHandlers();
WindowMoved.raise();
break;
}
case WM_CLOSE:
@ -617,7 +617,7 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize
// If the user wants to close the app by clicking 'X' button,
// we hand off the close experience to the app layer. If all the tabs
// are closed, the window will be closed as well.
_WindowCloseButtonClickedHandlers();
WindowCloseButtonClicked.raise();
return 0;
}
case WM_MOUSEWHEEL:
@ -651,7 +651,7 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize
const auto wheelDelta = static_cast<short>(HIWORD(wparam));
// Raise an event, so any listeners can handle the mouse wheel event manually.
_MouseScrolledHandlers(real, wheelDelta);
MouseScrolled.raise(real, wheelDelta);
return 0;
}
CATCH_LOG();
@ -721,12 +721,12 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize
auto highBits = wparam & 0xFFF0;
if (highBits == SC_RESTORE || highBits == SC_MAXIMIZE)
{
_MaximizeChangedHandlers(highBits == SC_MAXIMIZE);
MaximizeChanged.raise(highBits == SC_MAXIMIZE);
}
if (wparam == SC_RESTORE && _fullscreen)
{
_ShouldExitFullscreenHandlers();
ShouldExitFullscreen.raise();
return 0;
}
auto search = _systemMenuItems.find(LOWORD(wparam));
@ -757,7 +757,7 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize
if (isCurrentlyDark != _currentSystemThemeIsDark)
{
_currentSystemThemeIsDark = isCurrentlyDark;
_UpdateSettingsRequestedHandlers();
UpdateSettingsRequested.raise();
}
}
}
@ -797,7 +797,7 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
TraceLoggingKeyword(TIL_KEYWORD_TRACE));
_AutomaticShutdownRequestedHandlers();
AutomaticShutdownRequested.raise();
return true;
}
}

View File

@ -72,22 +72,22 @@ public:
void UseDarkTheme(const bool v);
virtual void UseMica(const bool newValue, const double titlebarOpacity);
WINRT_CALLBACK(DragRegionClicked, winrt::delegate<>);
WINRT_CALLBACK(WindowCloseButtonClicked, winrt::delegate<>);
WINRT_CALLBACK(MouseScrolled, winrt::delegate<void(til::point, int32_t)>);
WINRT_CALLBACK(WindowActivated, winrt::delegate<void(bool)>);
WINRT_CALLBACK(NotifyNotificationIconPressed, winrt::delegate<void()>);
WINRT_CALLBACK(NotifyWindowHidden, winrt::delegate<void()>);
WINRT_CALLBACK(NotifyShowNotificationIconContextMenu, winrt::delegate<void(til::point)>);
WINRT_CALLBACK(NotifyNotificationIconMenuItemSelected, winrt::delegate<void(HMENU, UINT)>);
WINRT_CALLBACK(NotifyReAddNotificationIcon, winrt::delegate<void()>);
WINRT_CALLBACK(ShouldExitFullscreen, winrt::delegate<void()>);
WINRT_CALLBACK(MaximizeChanged, winrt::delegate<void(bool)>);
WINRT_CALLBACK(AutomaticShutdownRequested, winrt::delegate<void(void)>);
til::event<winrt::delegate<>> DragRegionClicked;
til::event<winrt::delegate<>> WindowCloseButtonClicked;
til::event<winrt::delegate<void(til::point, int32_t)>> MouseScrolled;
til::event<winrt::delegate<void(bool)>> WindowActivated;
til::event<winrt::delegate<void()>> NotifyNotificationIconPressed;
til::event<winrt::delegate<void()>> NotifyWindowHidden;
til::event<winrt::delegate<void(til::point)>> NotifyShowNotificationIconContextMenu;
til::event<winrt::delegate<void(HMENU, UINT)>> NotifyNotificationIconMenuItemSelected;
til::event<winrt::delegate<void()>> NotifyReAddNotificationIcon;
til::event<winrt::delegate<void()>> ShouldExitFullscreen;
til::event<winrt::delegate<void(bool)>> MaximizeChanged;
til::event<winrt::delegate<void(void)>> AutomaticShutdownRequested;
WINRT_CALLBACK(WindowMoved, winrt::delegate<void()>);
WINRT_CALLBACK(WindowVisibilityChanged, winrt::delegate<void(bool)>);
WINRT_CALLBACK(UpdateSettingsRequested, winrt::delegate<void()>);
til::event<winrt::delegate<void()>> WindowMoved;
til::event<winrt::delegate<void(bool)>> WindowVisibilityChanged;
til::event<winrt::delegate<void()>> UpdateSettingsRequested;
protected:
void ForceResize()

View File

@ -216,7 +216,7 @@ void NotificationIcon::MenuItemSelected(const HMENU menu, const UINT menuItemInd
args.SummonBehavior().ToggleVisibility(false);
args.SummonBehavior().MoveToCurrentDesktop(false);
args.SummonBehavior().ToMonitor(Remoting::MonitorBehavior::InPlace);
_SummonWindowRequestedHandlers(args);
SummonWindowRequested.raise(args);
return;
}
}
@ -231,7 +231,7 @@ void NotificationIcon::MenuItemSelected(const HMENU menu, const UINT menuItemInd
args.SummonBehavior().ToggleVisibility(false);
args.SummonBehavior().MoveToCurrentDesktop(false);
args.SummonBehavior().ToMonitor(Remoting::MonitorBehavior::InPlace);
_SummonWindowRequestedHandlers(args);
SummonWindowRequested.raise(args);
break;
}
}
@ -250,7 +250,7 @@ void NotificationIcon::NotificationIconPressed()
args.SummonBehavior().MoveToCurrentDesktop(false);
args.SummonBehavior().ToMonitor(Remoting::MonitorBehavior::InPlace);
args.SummonBehavior().ToggleVisibility(false);
_SummonWindowRequestedHandlers(args);
SummonWindowRequested.raise(args);
}
// Method Description:

View File

@ -27,7 +27,7 @@ public:
void ShowContextMenu(const til::point coord, const winrt::Windows::Foundation::Collections::IVectorView<winrt::Microsoft::Terminal::Remoting::PeasantInfo>& peasants);
void MenuItemSelected(const HMENU menu, const UINT menuItemIndex);
WINRT_CALLBACK(SummonWindowRequested, winrt::delegate<void(winrt::Microsoft::Terminal::Remoting::SummonWindowSelectionArgs)>);
til::event<winrt::delegate<void(winrt::Microsoft::Terminal::Remoting::SummonWindowSelectionArgs)>> SummonWindowRequested;
private:
void _CreateWindow();

View File

@ -31,7 +31,7 @@ void WindowThread::CreateHost()
_manager,
_peasant);
_UpdateSettingsRequestedToken = _host->UpdateSettingsRequested([this]() { _UpdateSettingsRequestedHandlers(); });
_UpdateSettingsRequestedToken = _host->UpdateSettingsRequested([this]() { UpdateSettingsRequested.raise(); });
winrt::init_apartment(winrt::apartment_type::single_threaded);
@ -111,7 +111,7 @@ bool WindowThread::KeepWarm()
// state transitions. In this case, the window is actually being woken up.
if (msg.message == AppHost::WM_REFRIGERATE)
{
_UpdateSettingsRequestedToken = _host->UpdateSettingsRequested([this]() { _UpdateSettingsRequestedHandlers(); });
_UpdateSettingsRequestedToken = _host->UpdateSettingsRequested([this]() { UpdateSettingsRequested.raise(); });
// Re-initialize the host here, on the window thread
_host->Initialize();
return true;

Some files were not shown because too many files have changed in this diff Show More