Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the Tray Icon from velocity #12246

Merged
1 commit merged into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/cascadia/Remoting/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation

void WindowManager::SummonAllWindows()
{
if constexpr (Feature_NotificationIcon::IsEnabled())
{
_monarch.SummonAllWindows();
}
_monarch.SummonAllWindows();
}

Windows::Foundation::Collections::IVectorView<winrt::Microsoft::Terminal::Remoting::PeasantInfo> WindowManager::GetPeasantInfos()
Expand Down
34 changes: 10 additions & 24 deletions src/cascadia/TerminalApp/AppLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1587,38 +1587,24 @@ namespace winrt::TerminalApp::implementation

bool AppLogic::GetMinimizeToNotificationArea()
{
if constexpr (Feature_NotificationIcon::IsEnabled())
{
if (!_loadedInitialSettings)
{
// Load settings if we haven't already
LoadSettings();
}

return _settings.GlobalSettings().MinimizeToNotificationArea();
}
else
if (!_loadedInitialSettings)
{
return false;
// Load settings if we haven't already
LoadSettings();
}

return _settings.GlobalSettings().MinimizeToNotificationArea();
}

bool AppLogic::GetAlwaysShowNotificationIcon()
{
if constexpr (Feature_NotificationIcon::IsEnabled())
{
if (!_loadedInitialSettings)
{
// Load settings if we haven't already
LoadSettings();
}

return _settings.GlobalSettings().AlwaysShowNotificationIcon();
}
else
if (!_loadedInitialSettings)
{
return false;
// Load settings if we haven't already
LoadSettings();
}

return _settings.GlobalSettings().AlwaysShowNotificationIcon();
}

bool AppLogic::GetShowTitleInTitlebar()
Expand Down
4 changes: 0 additions & 4 deletions src/cascadia/TerminalSettingsEditor/GlobalAppearance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,4 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
}

bool GlobalAppearance::FeatureNotificationIconEnabled() const noexcept
{
return Feature_NotificationIcon::IsEnabled();
}
}
2 changes: 0 additions & 2 deletions src/cascadia/TerminalSettingsEditor/GlobalAppearance.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e);

bool FeatureNotificationIconEnabled() const noexcept;

WINRT_PROPERTY(Editor::GlobalAppearancePageNavigationState, State, nullptr);
GETSET_BINDABLE_ENUM_SETTING(Theme, winrt::Windows::UI::Xaml::ElementTheme, State().Globals(), Theme);
GETSET_BINDABLE_ENUM_SETTING(TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, State().Globals(), TabWidthMode);
Expand Down
2 changes: 0 additions & 2 deletions src/cascadia/TerminalSettingsEditor/GlobalAppearance.idl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,5 @@ namespace Microsoft.Terminal.Settings.Editor

IInspectable CurrentTabWidthMode;
Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Editor.EnumEntry> TabWidthModeList { get; };

Boolean FeatureNotificationIconEnabled { get; };
}
}
6 changes: 2 additions & 4 deletions src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,12 @@
</local:SettingContainer>

<!-- Always Show Notification Icon -->
<local:SettingContainer x:Uid="Globals_AlwaysShowNotificationIcon"
Visibility="{x:Bind FeatureNotificationIconEnabled}">
<local:SettingContainer x:Uid="Globals_AlwaysShowNotificationIcon">
<ToggleSwitch IsOn="{x:Bind State.Globals.AlwaysShowNotificationIcon, Mode=TwoWay}" />
</local:SettingContainer>

<!-- Minimize To Notification Area -->
<local:SettingContainer x:Uid="Globals_MinimizeToNotificationArea"
Visibility="{x:Bind FeatureNotificationIconEnabled}">
<local:SettingContainer x:Uid="Globals_MinimizeToNotificationArea">
<ToggleSwitch IsOn="{x:Bind State.Globals.MinimizeToNotificationArea, Mode=TwoWay}" />
</local:SettingContainer>
</StackPanel>
Expand Down
74 changes: 31 additions & 43 deletions src/cascadia/WindowsTerminal/AppHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,17 +1365,14 @@ void AppHost::_SystemMenuChangeRequested(const winrt::Windows::Foundation::IInsp
// - <none>
void AppHost::_CreateNotificationIcon()
{
if constexpr (Feature_NotificationIcon::IsEnabled())
{
_notificationIcon = std::make_unique<NotificationIcon>(_window->GetHandle());

// Hookup the handlers, save the tokens for revoking if settings change.
_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); });
}
_notificationIcon = std::make_unique<NotificationIcon>(_window->GetHandle());

// Hookup the handlers, save the tokens for revoking if settings change.
_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:
Expand All @@ -1386,55 +1383,46 @@ void AppHost::_CreateNotificationIcon()
// - <none>
void AppHost::_DestroyNotificationIcon()
{
if constexpr (Feature_NotificationIcon::IsEnabled())
{
_window->NotifyReAddNotificationIcon(_ReAddNotificationIconToken);
_window->NotifyNotificationIconPressed(_NotificationIconPressedToken);
_window->NotifyShowNotificationIconContextMenu(_ShowNotificationIconContextMenuToken);
_window->NotifyNotificationIconMenuItemSelected(_NotificationIconMenuItemSelectedToken);
_window->NotifyReAddNotificationIcon(_ReAddNotificationIconToken);
_window->NotifyNotificationIconPressed(_NotificationIconPressedToken);
_window->NotifyShowNotificationIconContextMenu(_ShowNotificationIconContextMenuToken);
_window->NotifyNotificationIconMenuItemSelected(_NotificationIconMenuItemSelectedToken);

_notificationIcon->RemoveIconFromNotificationArea();
_notificationIcon = nullptr;
}
_notificationIcon->RemoveIconFromNotificationArea();
_notificationIcon = nullptr;
}

void AppHost::_ShowNotificationIconRequested()
{
if constexpr (Feature_NotificationIcon::IsEnabled())
if (_windowManager.IsMonarch())
{
if (_windowManager.IsMonarch())
if (!_notificationIcon)
{
if (!_notificationIcon)
{
_CreateNotificationIcon();
}
}
else
{
_windowManager.RequestShowNotificationIcon();
_CreateNotificationIcon();
}
}
else
{
_windowManager.RequestShowNotificationIcon();
}
}

void AppHost::_HideNotificationIconRequested()
{
if constexpr (Feature_NotificationIcon::IsEnabled())
if (_windowManager.IsMonarch())
{
if (_windowManager.IsMonarch())
// Destroy it only if our settings allow it
if (_notificationIcon &&
!_logic.GetAlwaysShowNotificationIcon() &&
!_logic.GetMinimizeToNotificationArea())
{
// Destroy it only if our settings allow it
if (_notificationIcon &&
!_logic.GetAlwaysShowNotificationIcon() &&
!_logic.GetMinimizeToNotificationArea())
{
_DestroyNotificationIcon();
}
}
else
{
_windowManager.RequestHideNotificationIcon();
_DestroyNotificationIcon();
}
}
else
{
_windowManager.RequestHideNotificationIcon();
}
}

// Method Description:
Expand Down
7 changes: 0 additions & 7 deletions src/features.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@
</alwaysEnabledBrandingTokens>
</feature>

<feature>
<name>Feature_NotificationIcon</name>
<description>Controls whether the Notification Icon and related settings (aka. MinimizeToNotificationArea and AlwaysShowNotificationIcon) are enabled</description>
<stage>AlwaysEnabled</stage>
<alwaysDisabledReleaseTokens/>
</feature>

<feature>
<name>Feature_PersistedWindowLayout</name>
<description>Whether to allow the user to enable persisted window layout saving and loading</description>
Expand Down