From 844d46a132b2e142d98efb7a28d940caa5096b3e Mon Sep 17 00:00:00 2001 From: Leon Liang Date: Tue, 14 Sep 2021 09:12:40 -0700 Subject: [PATCH] Replace TrayIcon with NotificationIcon (#11219) This PR simply replaces all uses of "TrayIcon" and "Tray" with "NotificationIcon" and "NotificationArea" to be more accurate. Originally I kinda wanted to only replace all occurrences of it in settings and user facing things, but I figured I might as well make it consistent throughout all of our code. --- doc/cascadia/profiles.schema.json | 8 +- src/cascadia/Remoting/Monarch.cpp | 4 +- src/cascadia/Remoting/Monarch.h | 4 +- src/cascadia/Remoting/Monarch.idl | 4 +- src/cascadia/Remoting/Peasant.cpp | 12 +- src/cascadia/Remoting/Peasant.h | 8 +- src/cascadia/Remoting/Peasant.idl | 8 +- src/cascadia/Remoting/WindowManager.cpp | 18 +-- src/cascadia/Remoting/WindowManager.h | 8 +- src/cascadia/Remoting/WindowManager.idl | 8 +- src/cascadia/TerminalApp/AppLogic.cpp | 12 +- src/cascadia/TerminalApp/AppLogic.h | 4 +- src/cascadia/TerminalApp/AppLogic.idl | 4 +- .../Resources/en-US/Resources.resw | 4 +- .../GlobalAppearance.cpp | 4 +- .../TerminalSettingsEditor/GlobalAppearance.h | 2 +- .../GlobalAppearance.idl | 2 +- .../GlobalAppearance.xaml | 16 +-- .../Resources/en-US/Resources.resw | 10 +- .../GlobalAppSettings.cpp | 16 +-- .../TerminalSettingsModel/GlobalAppSettings.h | 4 +- .../GlobalAppSettings.idl | 4 +- .../Resources/en-US/Resources.resw | 3 - .../TerminalSettingsModel/defaults.json | 4 +- .../UnitTests_Remoting/RemotingTests.cpp | 8 +- src/cascadia/WindowsTerminal/AppHost.cpp | 110 +++++++++--------- src/cascadia/WindowsTerminal/AppHost.h | 20 ++-- .../WindowsTerminal/CustomWindowMessages.h | 2 +- src/cascadia/WindowsTerminal/IslandWindow.cpp | 20 ++-- src/cascadia/WindowsTerminal/IslandWindow.h | 12 +- .../{TrayIcon.cpp => NotificationIcon.cpp} | 96 +++++++-------- .../WindowsTerminal/NotificationIcon.h | 39 +++++++ src/cascadia/WindowsTerminal/TrayIcon.h | 39 ------- .../WindowsTerminal/WindowsTerminal.vcxproj | 4 +- src/cascadia/WindowsTerminal/main.cpp | 2 +- src/features.xml | 4 +- 36 files changed, 262 insertions(+), 265 deletions(-) rename src/cascadia/WindowsTerminal/{TrayIcon.cpp => NotificationIcon.cpp} (67%) create mode 100644 src/cascadia/WindowsTerminal/NotificationIcon.h delete mode 100644 src/cascadia/WindowsTerminal/TrayIcon.h diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 6b989a249..f3ef769ec 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -1262,14 +1262,14 @@ "type": [ "integer", "string" ], "deprecated": true }, - "minimizeToTray": { + "minimizeToNotificationArea": { "default": "false", - "description": "When set to true, minimizing a Terminal window will no longer appear in the taskbar. Instead, a Terminal icon will appear in the system tray through which the user can access their windows.", + "description": "When set to true, minimizing a Terminal window will no longer appear in the taskbar. Instead, a Terminal icon will appear in the notification area through which the user can access their windows.", "type": "boolean" }, - "alwaysShowTrayIcon": { + "alwaysShowNotificationIcon": { "default": "false", - "description": "When set to true, the Terminal's tray icon will always be shown in the system tray.", + "description": "When set to true, the Terminal's notification icon will always be shown in the notification area.", "type": "boolean" }, "useAcrylicInTabRow": { diff --git a/src/cascadia/Remoting/Monarch.cpp b/src/cascadia/Remoting/Monarch.cpp index f1b13480a..9bf60fc8b 100644 --- a/src/cascadia/Remoting/Monarch.cpp +++ b/src/cascadia/Remoting/Monarch.cpp @@ -80,8 +80,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation peasant.IdentifyWindowsRequested({ this, &Monarch::_identifyWindows }); peasant.RenameRequested({ this, &Monarch::_renameRequested }); - peasant.ShowTrayIconRequested([this](auto&&, auto&&) { _ShowTrayIconRequestedHandlers(*this, nullptr); }); - peasant.HideTrayIconRequested([this](auto&&, auto&&) { _HideTrayIconRequestedHandlers(*this, nullptr); }); + peasant.ShowNotificationIconRequested([this](auto&&, auto&&) { _ShowNotificationIconRequestedHandlers(*this, nullptr); }); + peasant.HideNotificationIconRequested([this](auto&&, auto&&) { _HideNotificationIconRequestedHandlers(*this, nullptr); }); peasant.QuitAllRequested({ this, &Monarch::_handleQuitAll }); _peasants[newPeasantsId] = peasant; diff --git a/src/cascadia/Remoting/Monarch.h b/src/cascadia/Remoting/Monarch.h index ae620af80..2e8e40aa1 100644 --- a/src/cascadia/Remoting/Monarch.h +++ b/src/cascadia/Remoting/Monarch.h @@ -60,8 +60,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation Windows::Foundation::Collections::IVectorView GetPeasantInfos(); TYPED_EVENT(FindTargetWindowRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::FindTargetWindowArgs); - TYPED_EVENT(ShowTrayIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable); - TYPED_EVENT(HideTrayIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable); + 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::Windows::Foundation::IInspectable); diff --git a/src/cascadia/Remoting/Monarch.idl b/src/cascadia/Remoting/Monarch.idl index eaf04ad0f..4eb77695a 100644 --- a/src/cascadia/Remoting/Monarch.idl +++ b/src/cascadia/Remoting/Monarch.idl @@ -54,8 +54,8 @@ namespace Microsoft.Terminal.Remoting Windows.Foundation.Collections.IVectorView GetPeasantInfos { get; }; event Windows.Foundation.TypedEventHandler FindTargetWindowRequested; - event Windows.Foundation.TypedEventHandler ShowTrayIconRequested; - event Windows.Foundation.TypedEventHandler HideTrayIconRequested; + event Windows.Foundation.TypedEventHandler ShowNotificationIconRequested; + event Windows.Foundation.TypedEventHandler HideNotificationIconRequested; event Windows.Foundation.TypedEventHandler WindowCreated; event Windows.Foundation.TypedEventHandler WindowClosed; event Windows.Foundation.TypedEventHandler QuitAllRequested; diff --git a/src/cascadia/Remoting/Peasant.cpp b/src/cascadia/Remoting/Peasant.cpp index 2cb6c5b3f..a8cb749d6 100644 --- a/src/cascadia/Remoting/Peasant.cpp +++ b/src/cascadia/Remoting/Peasant.cpp @@ -226,34 +226,34 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation TraceLoggingKeyword(TIL_KEYWORD_TRACE)); } - void Peasant::RequestShowTrayIcon() + void Peasant::RequestShowNotificationIcon() { try { - _ShowTrayIconRequestedHandlers(*this, nullptr); + _ShowNotificationIconRequestedHandlers(*this, nullptr); } catch (...) { LOG_CAUGHT_EXCEPTION(); } TraceLoggingWrite(g_hRemotingProvider, - "Peasant_RequestShowTrayIcon", + "Peasant_RequestShowNotificationIcon", TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE), TraceLoggingKeyword(TIL_KEYWORD_TRACE)); } - void Peasant::RequestHideTrayIcon() + void Peasant::RequestHideNotificationIcon() { try { - _HideTrayIconRequestedHandlers(*this, nullptr); + _HideNotificationIconRequestedHandlers(*this, nullptr); } catch (...) { LOG_CAUGHT_EXCEPTION(); } TraceLoggingWrite(g_hRemotingProvider, - "Peasant_RequestHideTrayIcon", + "Peasant_RequestHideNotificationIcon", TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE), TraceLoggingKeyword(TIL_KEYWORD_TRACE)); } diff --git a/src/cascadia/Remoting/Peasant.h b/src/cascadia/Remoting/Peasant.h index 8636d1345..f6f884491 100644 --- a/src/cascadia/Remoting/Peasant.h +++ b/src/cascadia/Remoting/Peasant.h @@ -28,8 +28,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation void RequestIdentifyWindows(); void DisplayWindowId(); void RequestRename(const winrt::Microsoft::Terminal::Remoting::RenameRequestArgs& args); - void RequestShowTrayIcon(); - void RequestHideTrayIcon(); + void RequestShowNotificationIcon(); + void RequestHideNotificationIcon(); void RequestQuitAll(); void Quit(); @@ -45,8 +45,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation 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(ShowTrayIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable); - TYPED_EVENT(HideTrayIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable); + 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); diff --git a/src/cascadia/Remoting/Peasant.idl b/src/cascadia/Remoting/Peasant.idl index 75896d733..80e24cb2c 100644 --- a/src/cascadia/Remoting/Peasant.idl +++ b/src/cascadia/Remoting/Peasant.idl @@ -65,8 +65,8 @@ namespace Microsoft.Terminal.Remoting void RequestIdentifyWindows(); // Tells us to raise a IdentifyWindowsRequested void RequestRename(RenameRequestArgs args); // Tells us to raise a RenameRequested void Summon(SummonWindowBehavior behavior); - void RequestShowTrayIcon(); - void RequestHideTrayIcon(); + void RequestShowNotificationIcon(); + void RequestHideNotificationIcon(); void RequestQuitAll(); void Quit(); @@ -76,8 +76,8 @@ namespace Microsoft.Terminal.Remoting event Windows.Foundation.TypedEventHandler DisplayWindowIdRequested; event Windows.Foundation.TypedEventHandler RenameRequested; event Windows.Foundation.TypedEventHandler SummonRequested; - event Windows.Foundation.TypedEventHandler ShowTrayIconRequested; - event Windows.Foundation.TypedEventHandler HideTrayIconRequested; + event Windows.Foundation.TypedEventHandler ShowNotificationIconRequested; + event Windows.Foundation.TypedEventHandler HideNotificationIconRequested; event Windows.Foundation.TypedEventHandler QuitAllRequested; event Windows.Foundation.TypedEventHandler QuitRequested; }; diff --git a/src/cascadia/Remoting/WindowManager.cpp b/src/cascadia/Remoting/WindowManager.cpp index 5820f6509..e3b85e0a2 100644 --- a/src/cascadia/Remoting/WindowManager.cpp +++ b/src/cascadia/Remoting/WindowManager.cpp @@ -269,8 +269,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation _monarch.WindowCreated({ get_weak(), &WindowManager::_WindowCreatedHandlers }); _monarch.WindowClosed({ get_weak(), &WindowManager::_WindowClosedHandlers }); _monarch.FindTargetWindowRequested({ this, &WindowManager::_raiseFindTargetWindowRequested }); - _monarch.ShowTrayIconRequested([this](auto&&, auto&&) { _ShowTrayIconRequestedHandlers(*this, nullptr); }); - _monarch.HideTrayIconRequested([this](auto&&, auto&&) { _HideTrayIconRequestedHandlers(*this, nullptr); }); + _monarch.ShowNotificationIconRequested([this](auto&&, auto&&) { _ShowNotificationIconRequestedHandlers(*this, nullptr); }); + _monarch.HideNotificationIconRequested([this](auto&&, auto&&) { _HideNotificationIconRequestedHandlers(*this, nullptr); }); _monarch.QuitAllRequested([this](auto&&, auto&&) { _QuitAllRequestedHandlers(*this, nullptr); }); _BecameMonarchHandlers(*this, nullptr); @@ -529,7 +529,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation void WindowManager::SummonAllWindows() { - if constexpr (Feature_TrayIcon::IsEnabled()) + if constexpr (Feature_NotificationIcon::IsEnabled()) { _monarch.SummonAllWindows(); } @@ -556,28 +556,28 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation } // Method Description: - // - Ask the monarch to show a tray icon. + // - Ask the monarch to show a notification icon. // Arguments: // - // Return Value: // - - winrt::fire_and_forget WindowManager::RequestShowTrayIcon() + winrt::fire_and_forget WindowManager::RequestShowNotificationIcon() { co_await winrt::resume_background(); - _peasant.RequestShowTrayIcon(); + _peasant.RequestShowNotificationIcon(); } // Method Description: - // - Ask the monarch to hide its tray icon. + // - Ask the monarch to hide its notification icon. // Arguments: // - // Return Value: // - - winrt::fire_and_forget WindowManager::RequestHideTrayIcon() + winrt::fire_and_forget WindowManager::RequestHideNotificationIcon() { auto strongThis{ get_strong() }; co_await winrt::resume_background(); - _peasant.RequestHideTrayIcon(); + _peasant.RequestHideNotificationIcon(); } // Method Description: diff --git a/src/cascadia/Remoting/WindowManager.h b/src/cascadia/Remoting/WindowManager.h index 4136a2cb9..3d2eaf6c7 100644 --- a/src/cascadia/Remoting/WindowManager.h +++ b/src/cascadia/Remoting/WindowManager.h @@ -45,8 +45,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation uint64_t GetNumberOfPeasants(); Windows::Foundation::Collections::IVectorView GetPeasantInfos(); - winrt::fire_and_forget RequestShowTrayIcon(); - winrt::fire_and_forget RequestHideTrayIcon(); + winrt::fire_and_forget RequestShowNotificationIcon(); + winrt::fire_and_forget RequestHideNotificationIcon(); winrt::fire_and_forget RequestQuitAll(); bool DoesQuakeWindowExist(); void UpdateActiveTabTitle(winrt::hstring title); @@ -55,8 +55,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation TYPED_EVENT(BecameMonarch, 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(ShowTrayIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable); - TYPED_EVENT(HideTrayIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable); + 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); private: diff --git a/src/cascadia/Remoting/WindowManager.idl b/src/cascadia/Remoting/WindowManager.idl index 611ebd02b..cf15fbb42 100644 --- a/src/cascadia/Remoting/WindowManager.idl +++ b/src/cascadia/Remoting/WindowManager.idl @@ -14,8 +14,8 @@ namespace Microsoft.Terminal.Remoting Boolean IsMonarch { get; }; void SummonWindow(SummonWindowSelectionArgs args); void SummonAllWindows(); - void RequestShowTrayIcon(); - void RequestHideTrayIcon(); + void RequestShowNotificationIcon(); + void RequestHideNotificationIcon(); UInt64 GetNumberOfPeasants(); void RequestQuitAll(); void UpdateActiveTabTitle(String title); @@ -25,8 +25,8 @@ namespace Microsoft.Terminal.Remoting event Windows.Foundation.TypedEventHandler BecameMonarch; event Windows.Foundation.TypedEventHandler WindowCreated; event Windows.Foundation.TypedEventHandler WindowClosed; - event Windows.Foundation.TypedEventHandler ShowTrayIconRequested; - event Windows.Foundation.TypedEventHandler HideTrayIconRequested; + event Windows.Foundation.TypedEventHandler ShowNotificationIconRequested; + event Windows.Foundation.TypedEventHandler HideNotificationIconRequested; event Windows.Foundation.TypedEventHandler QuitAllRequested; }; } diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index 6d53a6ba7..b1b94bc5b 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -1487,9 +1487,9 @@ namespace winrt::TerminalApp::implementation return _root->IsQuakeWindow(); } - bool AppLogic::GetMinimizeToTray() + bool AppLogic::GetMinimizeToNotificationArea() { - if constexpr (Feature_TrayIcon::IsEnabled()) + if constexpr (Feature_NotificationIcon::IsEnabled()) { if (!_loadedInitialSettings) { @@ -1497,7 +1497,7 @@ namespace winrt::TerminalApp::implementation LoadSettings(); } - return _settings.GlobalSettings().MinimizeToTray(); + return _settings.GlobalSettings().MinimizeToNotificationArea(); } else { @@ -1505,9 +1505,9 @@ namespace winrt::TerminalApp::implementation } } - bool AppLogic::GetAlwaysShowTrayIcon() + bool AppLogic::GetAlwaysShowNotificationIcon() { - if constexpr (Feature_TrayIcon::IsEnabled()) + if constexpr (Feature_NotificationIcon::IsEnabled()) { if (!_loadedInitialSettings) { @@ -1515,7 +1515,7 @@ namespace winrt::TerminalApp::implementation LoadSettings(); } - return _settings.GlobalSettings().AlwaysShowTrayIcon(); + return _settings.GlobalSettings().AlwaysShowNotificationIcon(); } else { diff --git a/src/cascadia/TerminalApp/AppLogic.h b/src/cascadia/TerminalApp/AppLogic.h index 5f8c87be1..08dc77007 100644 --- a/src/cascadia/TerminalApp/AppLogic.h +++ b/src/cascadia/TerminalApp/AppLogic.h @@ -95,8 +95,8 @@ namespace winrt::TerminalApp::implementation winrt::TerminalApp::TaskbarState TaskbarState(); - bool GetMinimizeToTray(); - bool GetAlwaysShowTrayIcon(); + bool GetMinimizeToNotificationArea(); + bool GetAlwaysShowNotificationIcon(); bool GetShowTitleInTitlebar(); winrt::Windows::Foundation::IAsyncOperation ShowDialog(winrt::Windows::UI::Xaml::Controls::ContentDialog dialog); diff --git a/src/cascadia/TerminalApp/AppLogic.idl b/src/cascadia/TerminalApp/AppLogic.idl index 7f4c2121e..a600891c4 100644 --- a/src/cascadia/TerminalApp/AppLogic.idl +++ b/src/cascadia/TerminalApp/AppLogic.idl @@ -73,8 +73,8 @@ namespace TerminalApp TaskbarState TaskbarState{ get; }; - Boolean GetMinimizeToTray(); - Boolean GetAlwaysShowTrayIcon(); + Boolean GetMinimizeToNotificationArea(); + Boolean GetAlwaysShowNotificationIcon(); Boolean GetShowTitleInTitlebar(); FindTargetWindowResult FindTargetWindow(String[] args); diff --git a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw index 3f2aaea18..86b0b407f 100644 --- a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw @@ -665,11 +665,11 @@ Command Palette - + Focus Terminal This is displayed as a label for the context menu item that focuses the terminal. - + Windows This is displayed as a label for the context menu item that holds the submenu of available windows. diff --git a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.cpp b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.cpp index b97aea5ec..423662d78 100644 --- a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.cpp +++ b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.cpp @@ -199,8 +199,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } } - bool GlobalAppearance::FeatureTrayIconEnabled() const noexcept + bool GlobalAppearance::FeatureNotificationIconEnabled() const noexcept { - return Feature_TrayIcon::IsEnabled(); + return Feature_NotificationIcon::IsEnabled(); } } diff --git a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.h b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.h index b8112d41a..8b0082a95 100644 --- a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.h +++ b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.h @@ -25,7 +25,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e); - bool FeatureTrayIconEnabled() const noexcept; + bool FeatureNotificationIconEnabled() const noexcept; WINRT_PROPERTY(Editor::GlobalAppearancePageNavigationState, State, nullptr); GETSET_BINDABLE_ENUM_SETTING(Theme, winrt::Windows::UI::Xaml::ElementTheme, State().Globals, Theme); diff --git a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.idl b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.idl index 8218d3cad..9840a4a3d 100644 --- a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.idl +++ b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.idl @@ -26,6 +26,6 @@ namespace Microsoft.Terminal.Settings.Editor IInspectable CurrentTabWidthMode; Windows.Foundation.Collections.IObservableVector TabWidthModeList { get; }; - Boolean FeatureTrayIconEnabled { get; }; + Boolean FeatureNotificationIconEnabled { get; }; } } diff --git a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml index 68800bfb1..9caef1974 100644 --- a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml +++ b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml @@ -85,16 +85,16 @@ - - - + + + - - - + + + diff --git a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw index b7f07195d..4c39ba4d1 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw @@ -1106,13 +1106,13 @@ Pane animations Header for a control to toggle animations on panes. "Enabled" value enables the animations. - + Always display an icon in the notification area - Header for a control to toggle whether the tray icon should always be shown. + Header for a control to toggle whether the notification icon should always be shown. - + Hide Terminal in the notification area when it is minimized - Header for a control to toggle whether the terminal should hide itself in the tray instead of the taskbar when minimized. + Header for a control to toggle whether the terminal should hide itself in the notification area instead of the taskbar when minimized. Reset to inherited value. @@ -1234,4 +1234,4 @@ Bold font with bright colors An option to choose from for the "intense text format" setting. When selected, "intense" text will be rendered as both bold text and in a brighter color - \ No newline at end of file + diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp index 6f1abf837..4a69f148a 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp @@ -50,8 +50,8 @@ static constexpr std::string_view StartupActionsKey{ "startupActions" }; static constexpr std::string_view FocusFollowMouseKey{ "focusFollowMouse" }; static constexpr std::string_view WindowingBehaviorKey{ "windowingBehavior" }; static constexpr std::string_view TrimBlockSelectionKey{ "trimBlockSelection" }; -static constexpr std::string_view AlwaysShowTrayIconKey{ "alwaysShowTrayIcon" }; -static constexpr std::string_view MinimizeToTrayKey{ "minimizeToTray" }; +static constexpr std::string_view AlwaysShowNotificationIconKey{ "alwaysShowNotificationIcon" }; +static constexpr std::string_view MinimizeToNotificationAreaKey{ "minimizeToNotificationArea" }; static constexpr std::string_view DebugFeaturesKey{ "debugFeatures" }; @@ -135,8 +135,8 @@ winrt::com_ptr GlobalAppSettings::Copy() const globals->_WindowingBehavior = _WindowingBehavior; globals->_TrimBlockSelection = _TrimBlockSelection; globals->_DetectURLs = _DetectURLs; - globals->_MinimizeToTray = _MinimizeToTray; - globals->_AlwaysShowTrayIcon = _AlwaysShowTrayIcon; + globals->_MinimizeToNotificationArea = _MinimizeToNotificationArea; + globals->_AlwaysShowNotificationIcon = _AlwaysShowNotificationIcon; globals->_UnparsedDefaultProfile = _UnparsedDefaultProfile; globals->_validDefaultProfile = _validDefaultProfile; @@ -331,9 +331,9 @@ void GlobalAppSettings::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, DetectURLsKey, _DetectURLs); - JsonUtils::GetValueForKey(json, MinimizeToTrayKey, _MinimizeToTray); + JsonUtils::GetValueForKey(json, MinimizeToNotificationAreaKey, _MinimizeToNotificationArea); - JsonUtils::GetValueForKey(json, AlwaysShowTrayIconKey, _AlwaysShowTrayIcon); + JsonUtils::GetValueForKey(json, AlwaysShowNotificationIconKey, _AlwaysShowNotificationIcon); // This is a helper lambda to get the keybindings and commands out of both // and array of objects. We'll use this twice, once on the legacy @@ -432,8 +432,8 @@ Json::Value GlobalAppSettings::ToJson() const JsonUtils::SetValueForKey(json, WindowingBehaviorKey, _WindowingBehavior); JsonUtils::SetValueForKey(json, TrimBlockSelectionKey, _TrimBlockSelection); JsonUtils::SetValueForKey(json, DetectURLsKey, _DetectURLs); - JsonUtils::SetValueForKey(json, MinimizeToTrayKey, _MinimizeToTray); - JsonUtils::SetValueForKey(json, AlwaysShowTrayIconKey, _AlwaysShowTrayIcon); + JsonUtils::SetValueForKey(json, MinimizeToNotificationAreaKey, _MinimizeToNotificationArea); + JsonUtils::SetValueForKey(json, AlwaysShowNotificationIconKey, _AlwaysShowNotificationIcon); // clang-format on json[JsonKey(ActionsKey)] = _actionMap->ToJson(); diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h index ed06ee312..53f47856c 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.h @@ -100,8 +100,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::GlobalAppSettings, Model::WindowingMode, WindowingBehavior, Model::WindowingMode::UseNew); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, TrimBlockSelection, false); INHERITABLE_SETTING(Model::GlobalAppSettings, bool, DetectURLs, true); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, MinimizeToTray, false); - INHERITABLE_SETTING(Model::GlobalAppSettings, bool, AlwaysShowTrayIcon, false); + INHERITABLE_SETTING(Model::GlobalAppSettings, bool, MinimizeToNotificationArea, false); + INHERITABLE_SETTING(Model::GlobalAppSettings, bool, AlwaysShowNotificationIcon, false); private: guid _defaultProfile; diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl index 94a317dad..aabcda7b3 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl @@ -81,8 +81,8 @@ namespace Microsoft.Terminal.Settings.Model INHERITABLE_SETTING(WindowingMode, WindowingBehavior); INHERITABLE_SETTING(Boolean, TrimBlockSelection); INHERITABLE_SETTING(Boolean, DetectURLs); - INHERITABLE_SETTING(Boolean, MinimizeToTray); - INHERITABLE_SETTING(Boolean, AlwaysShowTrayIcon); + INHERITABLE_SETTING(Boolean, MinimizeToNotificationArea); + INHERITABLE_SETTING(Boolean, AlwaysShowNotificationIcon); Windows.Foundation.Collections.IMapView ColorSchemes(); void AddColorScheme(ColorScheme scheme); diff --git a/src/cascadia/TerminalSettingsModel/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsModel/Resources/en-US/Resources.resw index acd619ab5..3ced7eb85 100644 --- a/src/cascadia/TerminalSettingsModel/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsModel/Resources/en-US/Resources.resw @@ -469,9 +469,6 @@ Windows Console Host Name describing the usage of the classic windows console as the terminal UI. (`conhost.exe`) - - Minimize current window to tray - Quit the Terminal diff --git a/src/cascadia/TerminalSettingsModel/defaults.json b/src/cascadia/TerminalSettingsModel/defaults.json index a246d52b9..8f9b3b9d1 100644 --- a/src/cascadia/TerminalSettingsModel/defaults.json +++ b/src/cascadia/TerminalSettingsModel/defaults.json @@ -29,8 +29,8 @@ "disableAnimations": false, "startupActions": "", "focusFollowMouse": false, - "minimizeToTray": false, - "alwaysShowTrayIcon": false, + "minimizeToNotificationArea": false, + "alwaysShowNotificationIcon": false, "profiles": [ diff --git a/src/cascadia/UnitTests_Remoting/RemotingTests.cpp b/src/cascadia/UnitTests_Remoting/RemotingTests.cpp index 2d5131460..ab45b444b 100644 --- a/src/cascadia/UnitTests_Remoting/RemotingTests.cpp +++ b/src/cascadia/UnitTests_Remoting/RemotingTests.cpp @@ -73,8 +73,8 @@ namespace RemotingUnitTests Remoting::WindowActivatedArgs GetLastActivatedArgs() { throw winrt::hresult_error{}; } void RequestRename(const Remoting::RenameRequestArgs& /*args*/) { throw winrt::hresult_error{}; } void Summon(const Remoting::SummonWindowBehavior& /*args*/) { throw winrt::hresult_error{}; }; - void RequestShowTrayIcon() { throw winrt::hresult_error{}; }; - void RequestHideTrayIcon() { throw winrt::hresult_error{}; }; + void RequestShowNotificationIcon() { throw winrt::hresult_error{}; }; + void RequestHideNotificationIcon() { throw winrt::hresult_error{}; }; void RequestQuitAll() { throw winrt::hresult_error{}; }; void Quit() { throw winrt::hresult_error{}; }; TYPED_EVENT(WindowActivated, winrt::Windows::Foundation::IInspectable, Remoting::WindowActivatedArgs); @@ -83,8 +83,8 @@ namespace RemotingUnitTests 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(ShowTrayIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable); - TYPED_EVENT(HideTrayIconRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable); + 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); }; diff --git a/src/cascadia/WindowsTerminal/AppHost.cpp b/src/cascadia/WindowsTerminal/AppHost.cpp index 0e489ca71..e9d9b2416 100644 --- a/src/cascadia/WindowsTerminal/AppHost.cpp +++ b/src/cascadia/WindowsTerminal/AppHost.cpp @@ -63,7 +63,7 @@ AppHost::AppHost() noexcept : // Update our own internal state tracking if we're in quake mode or not. _IsQuakeWindowChanged(nullptr, nullptr); - _window->SetMinimizeToTrayBehavior(_logic.GetMinimizeToTray()); + _window->SetMinimizeToNotificationAreaBehavior(_logic.GetMinimizeToNotificationArea()); // Tell the window to callback to us when it's about to handle a WM_CREATE auto pfn = std::bind(&AppHost::_HandleCreateWindow, @@ -335,13 +335,13 @@ void AppHost::AppTitleChanged(const winrt::Windows::Foundation::IInspectable& /* // - void AppHost::LastTabClosed(const winrt::Windows::Foundation::IInspectable& /*sender*/, const winrt::TerminalApp::LastTabClosedEventArgs& /*args*/) { - if (_windowManager.IsMonarch() && _trayIcon) + if (_windowManager.IsMonarch() && _notificationIcon) { - _DestroyTrayIcon(); + _DestroyNotificationIcon(); } else if (_window->IsQuakeWindow()) { - _HideTrayIconRequested(); + _HideNotificationIconRequested(); } _window->Close(); @@ -678,9 +678,9 @@ void AppHost::_BecomeMonarch(const winrt::Windows::Foundation::IInspectable& /*s if (_windowManager.DoesQuakeWindowExist() || _window->IsQuakeWindow() || - (_logic.GetAlwaysShowTrayIcon() || _logic.GetMinimizeToTray())) + (_logic.GetAlwaysShowNotificationIcon() || _logic.GetMinimizeToNotificationArea())) { - _CreateTrayIcon(); + _CreateNotificationIcon(); } // Set the number of open windows (so we know if we are the last window) @@ -691,8 +691,8 @@ void AppHost::_BecomeMonarch(const winrt::Windows::Foundation::IInspectable& /*s _windowManager.WindowClosed([this](auto&&, auto&&) { _logic.SetNumberOfOpenWindows(_windowManager.GetNumberOfPeasants()); }); // These events are coming from peasants that become or un-become quake windows. - _windowManager.ShowTrayIconRequested([this](auto&&, auto&&) { _ShowTrayIconRequested(); }); - _windowManager.HideTrayIconRequested([this](auto&&, auto&&) { _HideTrayIconRequested(); }); + _windowManager.ShowNotificationIconRequested([this](auto&&, auto&&) { _ShowNotificationIconRequested(); }); + _windowManager.HideNotificationIconRequested([this](auto&&, auto&&) { _HideNotificationIconRequested(); }); // If the monarch receives a QuitAll event it will signal this event to be // ran before each peasant is closed. _windowManager.QuitAllRequested({ this, &AppHost::_QuitAllRequested }); @@ -982,12 +982,12 @@ void AppHost::_HandleSettingsChanged(const winrt::Windows::Foundation::IInspecta { _setupGlobalHotkeys(); - // If we're monarch, we need to check some conditions to show the tray icon. - // If there's a Quake window somewhere, we'll want to keep the tray icon. - // There's two settings - MinimizeToTray and AlwaysShowTrayIcon. If either - // one of them are true, we want to make sure there's a tray icon. - // If both are false, we want to remove our icon from the tray. - // When we remove our icon from the tray, we'll also want to re-summon + // If we're monarch, we need to check some conditions to show the notification icon. + // If there's a Quake window somewhere, we'll want to keep the notification icon. + // There's two settings - MinimizeToNotificationArea and AlwaysShowNotificationIcon. If either + // one of them are true, we want to make sure there's a notification icon. + // If both are false, we want to remove our icon from the notification area. + // When we remove our icon from the notification area, we'll also want to re-summon // any hidden windows, but right now we're not keeping track of who's hidden, // so just summon them all. Tracking the work to do a "summon all minimized" in // GH#10448 @@ -995,36 +995,36 @@ void AppHost::_HandleSettingsChanged(const winrt::Windows::Foundation::IInspecta { if (!_windowManager.DoesQuakeWindowExist()) { - if (!_trayIcon && (_logic.GetMinimizeToTray() || _logic.GetAlwaysShowTrayIcon())) + if (!_notificationIcon && (_logic.GetMinimizeToNotificationArea() || _logic.GetAlwaysShowNotificationIcon())) { - _CreateTrayIcon(); + _CreateNotificationIcon(); } - else if (_trayIcon && !_logic.GetMinimizeToTray() && !_logic.GetAlwaysShowTrayIcon()) + else if (_notificationIcon && !_logic.GetMinimizeToNotificationArea() && !_logic.GetAlwaysShowNotificationIcon()) { _windowManager.SummonAllWindows(); - _DestroyTrayIcon(); + _DestroyNotificationIcon(); } } } - _window->SetMinimizeToTrayBehavior(_logic.GetMinimizeToTray()); + _window->SetMinimizeToNotificationAreaBehavior(_logic.GetMinimizeToNotificationArea()); } void AppHost::_IsQuakeWindowChanged(const winrt::Windows::Foundation::IInspectable&, const winrt::Windows::Foundation::IInspectable&) { - // We want the quake window to be accessible through the tray icon. - // This means if there's a quake window _somewhere_, we want the tray icon - // to show regardless of the tray icon settings. - // This also means we'll need to destroy the tray icon if it was created + // We want the quake window to be accessible through the notification icon. + // This means if there's a quake window _somewhere_, we want the notification icon + // to show regardless of the notification icon settings. + // This also means we'll need to destroy the notification icon if it was created // specifically for the quake window. If not, it should not be destroyed. if (!_window->IsQuakeWindow() && _logic.IsQuakeWindow()) { - _ShowTrayIconRequested(); + _ShowNotificationIconRequested(); } else if (_window->IsQuakeWindow() && !_logic.IsQuakeWindow()) { - _HideTrayIconRequested(); + _HideNotificationIconRequested(); } _window->IsQuakeWindow(_logic.IsQuakeWindow()); @@ -1070,81 +1070,81 @@ void AppHost::_OpenSystemMenu(const winrt::Windows::Foundation::IInspectable&, } // Method Description: -// - Creates a Tray Icon and hooks up its handlers +// - Creates a Notification Icon and hooks up its handlers // Arguments: // - // Return Value: // - -void AppHost::_CreateTrayIcon() +void AppHost::_CreateNotificationIcon() { - if constexpr (Feature_TrayIcon::IsEnabled()) + if constexpr (Feature_NotificationIcon::IsEnabled()) { - _trayIcon = std::make_unique(_window->GetHandle()); + _notificationIcon = std::make_unique(_window->GetHandle()); // Hookup the handlers, save the tokens for revoking if settings change. - _ReAddTrayIconToken = _window->NotifyReAddTrayIcon([this]() { _trayIcon->ReAddTrayIcon(); }); - _TrayIconPressedToken = _window->NotifyTrayIconPressed([this]() { _trayIcon->TrayIconPressed(); }); - _ShowTrayContextMenuToken = _window->NotifyShowTrayContextMenu([this](til::point coord) { _trayIcon->ShowTrayContextMenu(coord, _windowManager.GetPeasantInfos()); }); - _TrayMenuItemSelectedToken = _window->NotifyTrayMenuItemSelected([this](HMENU hm, UINT idx) { _trayIcon->TrayMenuItemSelected(hm, idx); }); - _trayIcon->SummonWindowRequested([this](auto& args) { _windowManager.SummonWindow(args); }); + _ReAddNotificationIconToken = _window->NotifyReAddNotificationIcon([this]() { _notificationIcon->ReAddNotificationIcon(); }); + _NotificationIconPressedToken = _window->NotifyNotificationIconPressed([this]() { _notificationIcon->NotificationIconPressed(); }); + _ShowNotificationIconContextMenuToken = _window->NotifyShowNotificationIconContextMenu([this](til::point coord) { _notificationIcon->ShowContextMenu(coord, _windowManager.GetPeasantInfos()); }); + _NotificationIconMenuItemSelectedToken = _window->NotifyNotificationIconMenuItemSelected([this](HMENU hm, UINT idx) { _notificationIcon->MenuItemSelected(hm, idx); }); + _notificationIcon->SummonWindowRequested([this](auto& args) { _windowManager.SummonWindow(args); }); } } // Method Description: -// - Deletes our tray icon if we have one. +// - Deletes our notification icon if we have one. // Arguments: // - // Return Value: // - -void AppHost::_DestroyTrayIcon() +void AppHost::_DestroyNotificationIcon() { - if constexpr (Feature_TrayIcon::IsEnabled()) + if constexpr (Feature_NotificationIcon::IsEnabled()) { - _window->NotifyReAddTrayIcon(_ReAddTrayIconToken); - _window->NotifyTrayIconPressed(_TrayIconPressedToken); - _window->NotifyShowTrayContextMenu(_ShowTrayContextMenuToken); - _window->NotifyTrayMenuItemSelected(_TrayMenuItemSelectedToken); + _window->NotifyReAddNotificationIcon(_ReAddNotificationIconToken); + _window->NotifyNotificationIconPressed(_NotificationIconPressedToken); + _window->NotifyShowNotificationIconContextMenu(_ShowNotificationIconContextMenuToken); + _window->NotifyNotificationIconMenuItemSelected(_NotificationIconMenuItemSelectedToken); - _trayIcon->RemoveIconFromTray(); - _trayIcon = nullptr; + _notificationIcon->RemoveIconFromNotificationArea(); + _notificationIcon = nullptr; } } -void AppHost::_ShowTrayIconRequested() +void AppHost::_ShowNotificationIconRequested() { - if constexpr (Feature_TrayIcon::IsEnabled()) + if constexpr (Feature_NotificationIcon::IsEnabled()) { if (_windowManager.IsMonarch()) { - if (!_trayIcon) + if (!_notificationIcon) { - _CreateTrayIcon(); + _CreateNotificationIcon(); } } else { - _windowManager.RequestShowTrayIcon(); + _windowManager.RequestShowNotificationIcon(); } } } -void AppHost::_HideTrayIconRequested() +void AppHost::_HideNotificationIconRequested() { - if constexpr (Feature_TrayIcon::IsEnabled()) + if constexpr (Feature_NotificationIcon::IsEnabled()) { if (_windowManager.IsMonarch()) { // Destroy it only if our settings allow it - if (_trayIcon && - !_logic.GetAlwaysShowTrayIcon() && - !_logic.GetMinimizeToTray()) + if (_notificationIcon && + !_logic.GetAlwaysShowNotificationIcon() && + !_logic.GetMinimizeToNotificationArea()) { - _DestroyTrayIcon(); + _DestroyNotificationIcon(); } } else { - _windowManager.RequestHideTrayIcon(); + _windowManager.RequestHideNotificationIcon(); } } } diff --git a/src/cascadia/WindowsTerminal/AppHost.h b/src/cascadia/WindowsTerminal/AppHost.h index ebf38dd17..db8a0bf1b 100644 --- a/src/cascadia/WindowsTerminal/AppHost.h +++ b/src/cascadia/WindowsTerminal/AppHost.h @@ -3,7 +3,7 @@ #include "pch.h" #include "NonClientIslandWindow.h" -#include "TrayIcon.h" +#include "NotificationIcon.h" class AppHost { @@ -97,13 +97,13 @@ private: void _QuitAllRequested(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args); - void _CreateTrayIcon(); - void _DestroyTrayIcon(); - void _ShowTrayIconRequested(); - void _HideTrayIconRequested(); - std::unique_ptr _trayIcon; - winrt::event_token _ReAddTrayIconToken; - winrt::event_token _TrayIconPressedToken; - winrt::event_token _ShowTrayContextMenuToken; - winrt::event_token _TrayMenuItemSelectedToken; + void _CreateNotificationIcon(); + void _DestroyNotificationIcon(); + void _ShowNotificationIconRequested(); + void _HideNotificationIconRequested(); + std::unique_ptr _notificationIcon; + winrt::event_token _ReAddNotificationIconToken; + winrt::event_token _NotificationIconPressedToken; + winrt::event_token _ShowNotificationIconContextMenuToken; + winrt::event_token _NotificationIconMenuItemSelectedToken; }; diff --git a/src/cascadia/WindowsTerminal/CustomWindowMessages.h b/src/cascadia/WindowsTerminal/CustomWindowMessages.h index beb0766af..a1428eeab 100644 --- a/src/cascadia/WindowsTerminal/CustomWindowMessages.h +++ b/src/cascadia/WindowsTerminal/CustomWindowMessages.h @@ -5,4 +5,4 @@ // Custom window messages #define CM_UPDATE_TITLE (WM_USER) -#define CM_NOTIFY_FROM_TRAY (WM_USER + 1) +#define CM_NOTIFY_FROM_NOTIFICATION_AREA (WM_USER + 1) diff --git a/src/cascadia/WindowsTerminal/IslandWindow.cpp b/src/cascadia/WindowsTerminal/IslandWindow.cpp index 879e1c007..0fa5654c4 100644 --- a/src/cascadia/WindowsTerminal/IslandWindow.cpp +++ b/src/cascadia/WindowsTerminal/IslandWindow.cpp @@ -6,7 +6,7 @@ #include "../types/inc/Viewport.hpp" #include "resource.h" #include "icon.h" -#include "TrayIcon.h" +#include "NotificationIcon.h" extern "C" IMAGE_DOS_HEADER __ImageBase; @@ -570,20 +570,20 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize } } } - case CM_NOTIFY_FROM_TRAY: + case CM_NOTIFY_FROM_NOTIFICATION_AREA: { switch (LOWORD(lparam)) { case NIN_SELECT: case NIN_KEYSELECT: { - _NotifyTrayIconPressedHandlers(); + _NotifyNotificationIconPressedHandlers(); return 0; } case WM_CONTEXTMENU: { const til::point eventPoint{ GET_X_LPARAM(wparam), GET_Y_LPARAM(wparam) }; - _NotifyShowTrayContextMenuHandlers(eventPoint); + _NotifyShowNotificationIconContextMenuHandlers(eventPoint); return 0; } } @@ -591,17 +591,17 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize } case WM_MENUCOMMAND: { - _NotifyTrayMenuItemSelectedHandlers((HMENU)lparam, (UINT)wparam); + _NotifyNotificationIconMenuItemSelectedHandlers((HMENU)lparam, (UINT)wparam); return 0; } default: // We'll want to receive this message when explorer.exe restarts - // so that we can re-add our icon to the tray. + // so that we can re-add our icon to the notification area. // This unfortunately isn't a switch case because we register the // message at runtime. if (message == WM_TASKBARCREATED) { - _NotifyReAddTrayIconHandlers(); + _NotifyReAddNotificationIconHandlers(); return 0; } } @@ -628,7 +628,7 @@ void IslandWindow::OnResize(const UINT width, const UINT height) void IslandWindow::OnMinimize() { // TODO GH#1989 Stop rendering island content when the app is minimized. - if (_minimizeToTray) + if (_minimizeToNotificationArea) { HideWindow(); } @@ -1640,9 +1640,9 @@ void IslandWindow::HideWindow() ShowWindow(GetHandle(), SW_HIDE); } -void IslandWindow::SetMinimizeToTrayBehavior(bool minimizeToTray) noexcept +void IslandWindow::SetMinimizeToNotificationAreaBehavior(bool MinimizeToNotificationArea) noexcept { - _minimizeToTray = minimizeToTray; + _minimizeToNotificationArea = MinimizeToNotificationArea; } // Method Description: diff --git a/src/cascadia/WindowsTerminal/IslandWindow.h b/src/cascadia/WindowsTerminal/IslandWindow.h index ad8c54de9..b15f63a23 100644 --- a/src/cascadia/WindowsTerminal/IslandWindow.h +++ b/src/cascadia/WindowsTerminal/IslandWindow.h @@ -49,7 +49,7 @@ public: void HideWindow(); - void SetMinimizeToTrayBehavior(bool minimizeToTray) noexcept; + void SetMinimizeToNotificationAreaBehavior(bool MinimizeToNotificationArea) noexcept; void OpenSystemMenu(const std::optional mouseX, const std::optional mouseY) const noexcept; @@ -58,11 +58,11 @@ public: WINRT_CALLBACK(MouseScrolled, winrt::delegate); WINRT_CALLBACK(WindowActivated, winrt::delegate); WINRT_CALLBACK(HotkeyPressed, winrt::delegate); - WINRT_CALLBACK(NotifyTrayIconPressed, winrt::delegate); + WINRT_CALLBACK(NotifyNotificationIconPressed, winrt::delegate); WINRT_CALLBACK(NotifyWindowHidden, winrt::delegate); - WINRT_CALLBACK(NotifyShowTrayContextMenu, winrt::delegate); - WINRT_CALLBACK(NotifyTrayMenuItemSelected, winrt::delegate); - WINRT_CALLBACK(NotifyReAddTrayIcon, winrt::delegate); + WINRT_CALLBACK(NotifyShowNotificationIconContextMenu, winrt::delegate); + WINRT_CALLBACK(NotifyNotificationIconMenuItemSelected, winrt::delegate); + WINRT_CALLBACK(NotifyReAddNotificationIcon, winrt::delegate); WINRT_CALLBACK(WindowMoved, winrt::delegate); @@ -127,7 +127,7 @@ protected: void _summonWindowRoutineBody(winrt::Microsoft::Terminal::Remoting::SummonWindowBehavior args); - bool _minimizeToTray{ false }; + bool _minimizeToNotificationArea{ false }; private: // This minimum width allows for width the tabs fit diff --git a/src/cascadia/WindowsTerminal/TrayIcon.cpp b/src/cascadia/WindowsTerminal/NotificationIcon.cpp similarity index 67% rename from src/cascadia/WindowsTerminal/TrayIcon.cpp rename to src/cascadia/WindowsTerminal/NotificationIcon.cpp index 34cc8b416..087820769 100644 --- a/src/cascadia/WindowsTerminal/TrayIcon.cpp +++ b/src/cascadia/WindowsTerminal/NotificationIcon.cpp @@ -3,7 +3,7 @@ #include "pch.h" #include "icon.h" -#include "TrayIcon.h" +#include "NotificationIcon.h" #include "CustomWindowMessages.h" #include @@ -12,54 +12,54 @@ using namespace winrt::Windows::Foundation::Collections; using namespace winrt::Microsoft::Terminal; -TrayIcon::TrayIcon(const HWND owningHwnd) : +NotificationIcon::NotificationIcon(const HWND owningHwnd) : _owningHwnd{ owningHwnd } { - CreateTrayIcon(); + CreateNotificationIcon(); } -TrayIcon::~TrayIcon() +NotificationIcon::~NotificationIcon() { - RemoveIconFromTray(); + RemoveIconFromNotificationArea(); } -void TrayIcon::_CreateWindow() +void NotificationIcon::_CreateWindow() { WNDCLASSW wc{}; wc.hCursor = LoadCursor(nullptr, IDC_ARROW); wc.hInstance = wil::GetModuleInstanceHandle(); - wc.lpszClassName = L"TRAY_ICON_HOSTING_WINDOW_CLASS"; + wc.lpszClassName = L"NOTIFICATION_ICON_HOSTING_WINDOW_CLASS"; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = DefWindowProcW; wc.hIcon = static_cast(GetActiveAppIconHandle(true)); RegisterClass(&wc); - _trayIconHwnd = wil::unique_hwnd(CreateWindowW(wc.lpszClassName, - wc.lpszClassName, - WS_DISABLED, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - HWND_MESSAGE, - nullptr, - wc.hInstance, - nullptr)); + _notificationIconHwnd = wil::unique_hwnd(CreateWindowW(wc.lpszClassName, + wc.lpszClassName, + WS_DISABLED, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + HWND_MESSAGE, + nullptr, + wc.hInstance, + nullptr)); - WINRT_VERIFY(_trayIconHwnd); + WINRT_VERIFY(_notificationIconHwnd); } // Method Description: -// - Creates and adds an icon to the notification tray. +// - Creates and adds an icon to the notification area. // If an icon already exists, update the HWND associated // to the icon with this window's HWND. // Arguments: // - // Return Value: // - -void TrayIcon::CreateTrayIcon() +void NotificationIcon::CreateNotificationIcon() { - if (!_trayIconHwnd) + if (!_notificationIconHwnd) { // Creating a disabled, non visible window just so we can set it // as the foreground window when showing the context menu. @@ -71,7 +71,7 @@ void TrayIcon::CreateTrayIcon() NOTIFYICONDATA nid{}; nid.cbSize = sizeof(NOTIFYICONDATA); - // This HWND will receive the callbacks sent by the tray icon. + // This HWND will receive the callbacks sent by the notification icon. nid.hWnd = _owningHwnd; // App-defined identifier of the icon. The HWND and ID are used @@ -80,7 +80,7 @@ void TrayIcon::CreateTrayIcon() // going to be showing one so the ID doesn't really matter. nid.uID = 1; - nid.uCallbackMessage = CM_NOTIFY_FROM_TRAY; + nid.uCallbackMessage = CM_NOTIFY_FROM_NOTIFICATION_AREA; // AppName happens to be in CascadiaPackage's Resources. ScopedResourceLoader loader{ L"Resources" }; @@ -98,7 +98,7 @@ void TrayIcon::CreateTrayIcon() nid.uVersion = NOTIFYICON_VERSION_4; Shell_NotifyIcon(NIM_SETVERSION, &nid); - _trayIconData = nid; + _notificationIconData = nid; } // Method Description: @@ -109,14 +109,14 @@ void TrayIcon::CreateTrayIcon() // - peasants: The map of all peasants that should be available in the context menu. // Return Value: // - -void TrayIcon::ShowTrayContextMenu(const til::point& coord, - const IVectorView& peasants) +void NotificationIcon::ShowContextMenu(const til::point& coord, + const IVectorView& peasants) { - if (const auto hMenu = _CreateTrayContextMenu(peasants)) + if (const auto hMenu = _CreateContextMenu(peasants)) { // We'll need to set our window to the foreground before calling // TrackPopupMenuEx or else the menu won't dismiss when clicking away. - SetForegroundWindow(_trayIconHwnd.get()); + SetForegroundWindow(_notificationIconHwnd.get()); // User can select menu items with the left and right buttons. UINT uFlags = TPM_RIGHTBUTTON; @@ -137,12 +137,12 @@ void TrayIcon::ShowTrayContextMenu(const til::point& coord, } // Method Description: -// - This creates the context menu for our tray icon. +// - This creates the context menu for our notification icon. // Arguments: // - peasants: A map of all peasants' ID to their window name. // Return Value: // - The handle to the newly created context menu. -HMENU TrayIcon::_CreateTrayContextMenu(const IVectorView& peasants) +HMENU NotificationIcon::_CreateContextMenu(const IVectorView& peasants) { auto hMenu = CreatePopupMenu(); if (hMenu) @@ -155,7 +155,7 @@ HMENU TrayIcon::_CreateTrayContextMenu(const IVectorView(TrayMenuItemAction::FocusTerminal), RS_(L"TrayIconFocusTerminal").c_str()); + AppendMenu(hMenu, MF_STRING, gsl::narrow(NotificationIconMenuItemAction::FocusTerminal), RS_(L"NotificationIconFocusTerminal").c_str()); AppendMenu(hMenu, MF_SEPARATOR, 0, L""); // Submenu for Windows @@ -183,10 +183,10 @@ HMENU TrayIcon::_CreateTrayContextMenu(const IVectorView -void TrayIcon::TrayMenuItemSelected(const HMENU menu, const UINT menuItemIndex) +void NotificationIcon::MenuItemSelected(const HMENU menu, const UINT menuItemIndex) { // Check the menu's data for a specific action. MENUINFO mi{}; @@ -209,7 +209,7 @@ void TrayIcon::TrayMenuItemSelected(const HMENU menu, const UINT menuItemIndex) GetMenuInfo(menu, &mi); if (mi.dwMenuData) { - if (gsl::narrow(mi.dwMenuData) == TrayMenuItemAction::SummonWindow) + if (gsl::narrow(mi.dwMenuData) == NotificationIconMenuItemAction::SummonWindow) { winrt::Microsoft::Terminal::Remoting::SummonWindowSelectionArgs args{}; args.WindowID(GetMenuItemID(menu, menuItemIndex)); @@ -222,10 +222,10 @@ void TrayIcon::TrayMenuItemSelected(const HMENU menu, const UINT menuItemIndex) } // Now check the menu item itself for an action. - const auto action = gsl::narrow(GetMenuItemID(menu, menuItemIndex)); + const auto action = gsl::narrow(GetMenuItemID(menu, menuItemIndex)); switch (action) { - case TrayMenuItemAction::FocusTerminal: + case NotificationIconMenuItemAction::FocusTerminal: { winrt::Microsoft::Terminal::Remoting::SummonWindowSelectionArgs args{}; args.SummonBehavior().ToggleVisibility(false); @@ -238,12 +238,12 @@ void TrayIcon::TrayMenuItemSelected(const HMENU menu, const UINT menuItemIndex) } // Method Description: -// - This is the handler for when the tray icon itself is left-clicked. +// - This is the handler for when the notification icon itself is left-clicked. // Arguments: // - // Return Value: // - -void TrayIcon::TrayIconPressed() +void NotificationIcon::NotificationIconPressed() { // No name in the args means summon the mru window. winrt::Microsoft::Terminal::Remoting::SummonWindowSelectionArgs args{}; @@ -254,24 +254,24 @@ void TrayIcon::TrayIconPressed() } // Method Description: -// - Re-add a tray icon using our currently saved tray icon data. +// - Re-add a notification icon using our currently saved notification icon data. // Arguments: // - // Return Value: // - -void TrayIcon::ReAddTrayIcon() +void NotificationIcon::ReAddNotificationIcon() { - Shell_NotifyIcon(NIM_ADD, &_trayIconData); - Shell_NotifyIcon(NIM_SETVERSION, &_trayIconData); + Shell_NotifyIcon(NIM_ADD, &_notificationIconData); + Shell_NotifyIcon(NIM_SETVERSION, &_notificationIconData); } // Method Description: -// - Deletes our tray icon. +// - Deletes our notification icon. // Arguments: // - // Return Value: // - -void TrayIcon::RemoveIconFromTray() +void NotificationIcon::RemoveIconFromNotificationArea() { - Shell_NotifyIcon(NIM_DELETE, &_trayIconData); + Shell_NotifyIcon(NIM_DELETE, &_notificationIconData); } diff --git a/src/cascadia/WindowsTerminal/NotificationIcon.h b/src/cascadia/WindowsTerminal/NotificationIcon.h new file mode 100644 index 000000000..1689737ca --- /dev/null +++ b/src/cascadia/WindowsTerminal/NotificationIcon.h @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#include "pch.h" +#include "../cascadia/inc/cppwinrt_utils.h" + +// This enumerates all the possible actions +// that our notification icon context menu could do. +enum class NotificationIconMenuItemAction +{ + FocusTerminal, // Focus the MRU terminal. + SummonWindow +}; + +class NotificationIcon +{ +public: + NotificationIcon() = delete; + NotificationIcon(const HWND owningHwnd); + ~NotificationIcon(); + + void CreateNotificationIcon(); + void RemoveIconFromNotificationArea(); + void ReAddNotificationIcon(); + + void NotificationIconPressed(); + void ShowContextMenu(const til::point& coord, const winrt::Windows::Foundation::Collections::IVectorView& peasants); + void MenuItemSelected(const HMENU menu, const UINT menuItemIndex); + + WINRT_CALLBACK(SummonWindowRequested, winrt::delegate); + +private: + void _CreateWindow(); + HMENU _CreateContextMenu(const winrt::Windows::Foundation::Collections::IVectorView& peasants); + + wil::unique_hwnd _notificationIconHwnd; + HWND _owningHwnd; + NOTIFYICONDATA _notificationIconData; +}; diff --git a/src/cascadia/WindowsTerminal/TrayIcon.h b/src/cascadia/WindowsTerminal/TrayIcon.h deleted file mode 100644 index 2c3f9c86d..000000000 --- a/src/cascadia/WindowsTerminal/TrayIcon.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -#include "pch.h" -#include "../cascadia/inc/cppwinrt_utils.h" - -// This enumerates all the possible actions -// that our tray icon context menu could do. -enum class TrayMenuItemAction -{ - FocusTerminal, // Focus the MRU terminal. - SummonWindow -}; - -class TrayIcon -{ -public: - TrayIcon() = delete; - TrayIcon(const HWND owningHwnd); - ~TrayIcon(); - - void CreateTrayIcon(); - void RemoveIconFromTray(); - void ReAddTrayIcon(); - - void TrayIconPressed(); - void ShowTrayContextMenu(const til::point& coord, const winrt::Windows::Foundation::Collections::IVectorView& peasants); - void TrayMenuItemSelected(const HMENU menu, const UINT menuItemIndex); - - WINRT_CALLBACK(SummonWindowRequested, winrt::delegate); - -private: - void _CreateWindow(); - HMENU _CreateTrayContextMenu(const winrt::Windows::Foundation::Collections::IVectorView& peasants); - - wil::unique_hwnd _trayIconHwnd; - HWND _owningHwnd; - NOTIFYICONDATA _trayIconData; -}; diff --git a/src/cascadia/WindowsTerminal/WindowsTerminal.vcxproj b/src/cascadia/WindowsTerminal/WindowsTerminal.vcxproj index b20f6fd07..07ba6658f 100644 --- a/src/cascadia/WindowsTerminal/WindowsTerminal.vcxproj +++ b/src/cascadia/WindowsTerminal/WindowsTerminal.vcxproj @@ -47,7 +47,7 @@ - + @@ -58,7 +58,7 @@ - + diff --git a/src/cascadia/WindowsTerminal/main.cpp b/src/cascadia/WindowsTerminal/main.cpp index c53f885b1..fe2353fbf 100644 --- a/src/cascadia/WindowsTerminal/main.cpp +++ b/src/cascadia/WindowsTerminal/main.cpp @@ -25,7 +25,7 @@ TRACELOGGING_DEFINE_PROVIDER( // !! BODGY !! // Manually use the resources from TerminalApp as our resources. // The WindowsTerminal project doesn't actually build a Resources.resw file, but -// we still need to be able to localize strings for the tray icon menu. Anything +// we still need to be able to localize strings for the notification icon menu. Anything // you want localized for WindowsTerminal.exe should be stuck in // ...\TerminalApp\Resources\en-US\Resources.resw #include diff --git a/src/features.xml b/src/features.xml index 14c1364ff..79753f77a 100644 --- a/src/features.xml +++ b/src/features.xml @@ -65,8 +65,8 @@ - Feature_TrayIcon - Controls whether the Tray Icon and related settings (aka. MinimizeToTray and AlwaysShowTrayIcon) are enabled + Feature_NotificationIcon + Controls whether the Notification Icon and related settings (aka. MinimizeToNotificationArea and AlwaysShowNotificationIcon) are enabled AlwaysEnabled