terminal/src/cascadia/WindowsTerminal/TrayIcon.h
Leon Liang 424414ec97
Provide the focused tab title in the Tray Icon's context menu (#11043)
This PR adds a bit more information to each item in the Tray Icon's  window selection submenu. 
Currently it only shows the window ID and window name if given one. 
Now each item will instead show`{Window ID} : {Active Tab Title} [{Window Name}]`

![image](https://user-images.githubusercontent.com/57155886/130883675-7a76e674-2429-4b26-b869-2455a9e4b4f6.png)
2021-09-03 18:32:23 +00:00

40 lines
1.2 KiB
C++

// 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<winrt::Microsoft::Terminal::Remoting::PeasantInfo>& peasants);
void TrayMenuItemSelected(const HMENU menu, const UINT menuItemIndex);
WINRT_CALLBACK(SummonWindowRequested, winrt::delegate<void(winrt::Microsoft::Terminal::Remoting::SummonWindowSelectionArgs)>);
private:
void _CreateWindow();
HMENU _CreateTrayContextMenu(const winrt::Windows::Foundation::Collections::IVectorView<winrt::Microsoft::Terminal::Remoting::PeasantInfo>& peasants);
wil::unique_hwnd _trayIconHwnd;
HWND _owningHwnd;
NOTIFYICONDATA _trayIconData;
};