diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 11eb698965..e51c358bdf 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -60,7 +60,8 @@ "enum": [ "audible", "window", - "taskbar" + "taskbar", + "notification" ] } }, @@ -70,6 +71,7 @@ "audible", "taskbar", "window", + "notification", "all", "none" ] diff --git a/src/cascadia/TerminalApp/IPaneContent.idl b/src/cascadia/TerminalApp/IPaneContent.idl index 8128776247..2f5da33efe 100644 --- a/src/cascadia/TerminalApp/IPaneContent.idl +++ b/src/cascadia/TerminalApp/IPaneContent.idl @@ -14,6 +14,7 @@ namespace TerminalApp runtimeclass BellEventArgs { Boolean FlashTaskbar { get; }; + Boolean SendNotification { get; }; }; runtimeclass NotificationEventArgs diff --git a/src/cascadia/TerminalApp/Tab.cpp b/src/cascadia/TerminalApp/Tab.cpp index 236ab16382..ed58f8e460 100644 --- a/src/cascadia/TerminalApp/Tab.cpp +++ b/src/cascadia/TerminalApp/Tab.cpp @@ -1148,6 +1148,14 @@ namespace winrt::TerminalApp::implementation tab->TabRaiseVisualBell.raise(); } + // Send a desktop toast notification if requested, but only if + // the pane isn't already in the belled state. This prevents + // sending repeated toasts for repeated BEL characters. + if (bellArgs.SendNotification() && !tab->_tabStatus.BellIndicator()) + { + tab->TabToastNotificationRequested.raise(tab->Title(), L"", sender); + } + // Show the bell indicator in the tab header tab->ShowBellIndicator(true); diff --git a/src/cascadia/TerminalApp/TerminalPaneContent.cpp b/src/cascadia/TerminalApp/TerminalPaneContent.cpp index 3a2c487db9..a14e0c326f 100644 --- a/src/cascadia/TerminalApp/TerminalPaneContent.cpp +++ b/src/cascadia/TerminalApp/TerminalPaneContent.cpp @@ -291,9 +291,11 @@ namespace winrt::TerminalApp::implementation _control.BellLightOn(); } - // raise the event with the bool value corresponding to the taskbar flag + // raise the event with the bool values corresponding to the taskbar and notification flags BellRequested.raise(*this, - *winrt::make_self(WI_IsFlagSet(_profile.BellStyle(), BellStyle::Taskbar))); + *winrt::make_self( + WI_IsFlagSet(_profile.BellStyle(), BellStyle::Taskbar), + WI_IsFlagSet(_profile.BellStyle(), BellStyle::Notification))); } } } diff --git a/src/cascadia/TerminalApp/TerminalPaneContent.h b/src/cascadia/TerminalApp/TerminalPaneContent.h index b2f38ba249..0388aae935 100644 --- a/src/cascadia/TerminalApp/TerminalPaneContent.h +++ b/src/cascadia/TerminalApp/TerminalPaneContent.h @@ -14,10 +14,11 @@ namespace winrt::TerminalApp::implementation struct BellEventArgs : public BellEventArgsT { public: - BellEventArgs(bool flashTaskbar) : - FlashTaskbar(flashTaskbar) {} + BellEventArgs(bool flashTaskbar, bool sendNotification) : + FlashTaskbar(flashTaskbar), SendNotification(sendNotification) {} til::property FlashTaskbar; + til::property SendNotification; }; struct NotificationEventArgs : public NotificationEventArgsT diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp index 661d077b7e..d7e1df4a83 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp @@ -574,7 +574,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation hstring ProfileViewModel::BellStylePreview() const { const auto bellStyle = BellStyle(); - if (WI_AreAllFlagsSet(bellStyle, BellStyle::Audible | BellStyle::Window | BellStyle::Taskbar)) + if (WI_AreAllFlagsSet(bellStyle, BellStyle::Audible | BellStyle::Window | BellStyle::Taskbar | BellStyle::Notification)) { return RS_(L"Profile_BellStyleAll/Content"); } @@ -584,7 +584,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } std::vector resultList; - resultList.reserve(3); + resultList.reserve(4); if (WI_IsFlagSet(bellStyle, BellStyle::Audible)) { resultList.emplace_back(RS_(L"Profile_BellStyleAudible/Content")); @@ -597,6 +597,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { resultList.emplace_back(RS_(L"Profile_BellStyleTaskbar/Content")); } + if (WI_IsFlagSet(bellStyle, BellStyle::Notification)) + { + resultList.emplace_back(RS_(L"Profile_BellStyleNotification/Content")); + } // add in the commas hstring result{}; @@ -640,6 +644,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation BellStyle(currentStyle); } + void ProfileViewModel::SetBellStyleNotification(winrt::Windows::Foundation::IReference on) + { + auto currentStyle = BellStyle(); + WI_UpdateFlag(currentStyle, Model::BellStyle::Notification, winrt::unbox_value(on)); + BellStyle(currentStyle); + } + // Method Description: // - Construct _CurrentBellSounds by importing the _inherited_ value from the model // - Adds a PropertyChanged handler to each BellSoundViewModel to propagate changes to the model diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h index 1112a2f8ef..fa403952e5 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h @@ -46,6 +46,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void SetBellStyleAudible(winrt::Windows::Foundation::IReference on); void SetBellStyleWindow(winrt::Windows::Foundation::IReference on); void SetBellStyleTaskbar(winrt::Windows::Foundation::IReference on); + void SetBellStyleNotification(winrt::Windows::Foundation::IReference on); hstring BellSoundPreview(); void RequestAddBellSound(hstring path); diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl index 8b1aeba792..c2d99246d0 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl @@ -49,6 +49,7 @@ namespace Microsoft.Terminal.Settings.Editor void SetBellStyleAudible(Windows.Foundation.IReference on); void SetBellStyleWindow(Windows.Foundation.IReference on); void SetBellStyleTaskbar(Windows.Foundation.IReference on); + void SetBellStyleNotification(Windows.Foundation.IReference on); String BellSoundPreview { get; }; Windows.Foundation.Collections.IObservableVector CurrentBellSounds { get; }; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml b/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml index 941f410e97..b00c1753bb 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml +++ b/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml @@ -111,6 +111,8 @@ IsChecked="{x:Bind Profile.IsBellStyleFlagSet(2), BindBack=Profile.SetBellStyleWindow, Mode=TwoWay}" /> + diff --git a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw index 9eb703a6e2..74967fc61d 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw @@ -1553,6 +1553,10 @@ Flash window An option to choose from for the "bell style" setting. When selected, a visual notification is used to notify the user. In this case, the window is flashed. + + Desktop notification + An option to choose from for the "bell style" setting. When selected, a Windows desktop notification (toast) is sent to notify the user. + Add new Button label that creates a new color scheme. diff --git a/src/cascadia/TerminalSettingsModel/Profile.idl b/src/cascadia/TerminalSettingsModel/Profile.idl index 96bc79ad19..874b37235a 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.idl +++ b/src/cascadia/TerminalSettingsModel/Profile.idl @@ -29,6 +29,7 @@ namespace Microsoft.Terminal.Settings.Model Audible = 0x1, Window = 0x2, Taskbar = 0x4, + Notification = 0x8, All = 0xffffffff }; diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h index 9c071945a2..d5bfaf6f07 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h @@ -90,12 +90,13 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Core::MatchMode) JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::BellStyle) { - static constexpr std::array mappings = { + static constexpr std::array mappings = { pair_type{ "none", AllClear }, pair_type{ "audible", ValueType::Audible }, pair_type{ "visual", ValueType::Window | ValueType::Taskbar }, pair_type{ "window", ValueType::Window }, pair_type{ "taskbar", ValueType::Taskbar }, + pair_type{ "notification", ValueType::Notification }, pair_type{ "all", AllSet }, };