Tray Icon PR followup (#10938)
Some followups to #10368: - Accidentally reverted a defapp change where the Monarch should not by default register itself as a handoff server. - Destroy the tray icon if we're a monarch otherwise if we're a quake window we request the monarch to hide the icon.
This commit is contained in:
parent
46fd7caf5a
commit
482dcec60a
|
@ -532,8 +532,9 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
|
|||
// - <none>
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void WindowManager::RequestShowTrayIcon()
|
||||
winrt::fire_and_forget WindowManager::RequestShowTrayIcon()
|
||||
{
|
||||
co_await winrt::resume_background();
|
||||
_peasant.RequestShowTrayIcon();
|
||||
}
|
||||
|
||||
|
@ -543,8 +544,10 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
|
|||
// - <none>
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void WindowManager::RequestHideTrayIcon()
|
||||
winrt::fire_and_forget WindowManager::RequestHideTrayIcon()
|
||||
{
|
||||
auto strongThis{ get_strong() };
|
||||
co_await winrt::resume_background();
|
||||
_peasant.RequestHideTrayIcon();
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
|
|||
void SummonAllWindows();
|
||||
Windows::Foundation::Collections::IMapView<uint64_t, winrt::hstring> GetPeasantNames();
|
||||
|
||||
void RequestShowTrayIcon();
|
||||
void RequestHideTrayIcon();
|
||||
winrt::fire_and_forget RequestShowTrayIcon();
|
||||
winrt::fire_and_forget RequestHideTrayIcon();
|
||||
bool DoesQuakeWindowExist();
|
||||
|
||||
TYPED_EVENT(FindTargetWindowRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::FindTargetWindowArgs);
|
||||
|
|
|
@ -93,11 +93,6 @@ AppHost::AppHost() noexcept :
|
|||
|
||||
AppHost::~AppHost()
|
||||
{
|
||||
if (_window->IsQuakeWindow())
|
||||
{
|
||||
_windowManager.RequestHideTrayIcon();
|
||||
}
|
||||
|
||||
// destruction order is important for proper teardown here
|
||||
_window = nullptr;
|
||||
_app.Close();
|
||||
|
@ -325,6 +320,15 @@ void AppHost::AppTitleChanged(const winrt::Windows::Foundation::IInspectable& /*
|
|||
// - <none>
|
||||
void AppHost::LastTabClosed(const winrt::Windows::Foundation::IInspectable& /*sender*/, const winrt::TerminalApp::LastTabClosedEventArgs& /*args*/)
|
||||
{
|
||||
if (_windowManager.IsMonarch() && _trayIcon)
|
||||
{
|
||||
_DestroyTrayIcon();
|
||||
}
|
||||
else if (_window->IsQuakeWindow())
|
||||
{
|
||||
_HideTrayIconRequested();
|
||||
}
|
||||
|
||||
_window->Close();
|
||||
}
|
||||
|
||||
|
@ -657,9 +661,6 @@ void AppHost::_BecomeMonarch(const winrt::Windows::Foundation::IInspectable& /*s
|
|||
{
|
||||
_setupGlobalHotkeys();
|
||||
|
||||
// The monarch is just going to be THE listener for inbound connections.
|
||||
_listenForInboundConnections();
|
||||
|
||||
if (_windowManager.DoesQuakeWindowExist() ||
|
||||
_window->IsQuakeWindow() ||
|
||||
(_logic.GetAlwaysShowTrayIcon() || _logic.GetMinimizeToTray()))
|
||||
|
@ -1056,11 +1057,10 @@ void AppHost::_DestroyTrayIcon()
|
|||
}
|
||||
}
|
||||
|
||||
winrt::fire_and_forget AppHost::_ShowTrayIconRequested()
|
||||
void AppHost::_ShowTrayIconRequested()
|
||||
{
|
||||
if constexpr (Feature_TrayIcon::IsEnabled())
|
||||
{
|
||||
co_await winrt::resume_background();
|
||||
if (_windowManager.IsMonarch())
|
||||
{
|
||||
if (!_trayIcon)
|
||||
|
@ -1075,11 +1075,10 @@ winrt::fire_and_forget AppHost::_ShowTrayIconRequested()
|
|||
}
|
||||
}
|
||||
|
||||
winrt::fire_and_forget AppHost::_HideTrayIconRequested()
|
||||
void AppHost::_HideTrayIconRequested()
|
||||
{
|
||||
if constexpr (Feature_TrayIcon::IsEnabled())
|
||||
{
|
||||
co_await winrt::resume_background();
|
||||
if (_windowManager.IsMonarch())
|
||||
{
|
||||
// Destroy it only if our settings allow it
|
||||
|
|
|
@ -87,8 +87,8 @@ private:
|
|||
|
||||
void _CreateTrayIcon();
|
||||
void _DestroyTrayIcon();
|
||||
winrt::fire_and_forget _ShowTrayIconRequested();
|
||||
winrt::fire_and_forget _HideTrayIconRequested();
|
||||
void _ShowTrayIconRequested();
|
||||
void _HideTrayIconRequested();
|
||||
std::unique_ptr<TrayIcon> _trayIcon;
|
||||
winrt::event_token _ReAddTrayIconToken;
|
||||
winrt::event_token _TrayIconPressedToken;
|
||||
|
|
Loading…
Reference in a new issue