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

Add tray icon when quake window is minimized #10179

Merged
merged 17 commits into from
Jul 8, 2021
2 changes: 1 addition & 1 deletion src/cascadia/WinRTUtils/WinRTUtils.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<!-- ========================= Headers ======================== -->
<ItemGroup>
<ClInclude Include="pch.h" />
<ClInclude Include="ScopedResourceLoader.h" />
<ClInclude Include="inc\ScopedResourceLoader.h" />
<ClInclude Include="inc\LibraryResources.h" />
<ClInclude Include="inc\ThrottledFunc.h" />
<ClInclude Include="inc\Utils.h" />
Expand Down
6 changes: 5 additions & 1 deletion src/cascadia/WindowsTerminal/AppHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "VirtualDesktopUtils.h"
#include "icon.h"

#include <ScopedResourceLoader.h>

using namespace winrt::Windows::UI;
using namespace winrt::Windows::UI::Composition;
using namespace winrt::Windows::UI::Xaml;
Expand Down Expand Up @@ -996,8 +998,10 @@ void AppHost::_UpdateTrayIcon()

nid.uCallbackMessage = CM_NOTIFY_FROM_TRAY;

ScopedResourceLoader cascadiaLoader{ L"Resources" };

nid.hIcon = static_cast<HICON>(GetActiveAppIconHandle(ICON_SMALL));
StringCchCopy(nid.szTip, ARRAYSIZE(nid.szTip), L"Windows Terminal");
StringCchCopy(nid.szTip, ARRAYSIZE(nid.szTip), cascadiaLoader.GetLocalizedString(L"AppName").c_str());
nid.uFlags = NIF_MESSAGE | NIF_SHOWTIP | NIF_TIP | NIF_ICON;
Shell_NotifyIcon(NIM_ADD, &nid);
leonMSFT marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
8 changes: 8 additions & 0 deletions src/cascadia/WindowsTerminal/CustomWindowMessages.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

#pragma once

// Custom window messages
#define CM_UPDATE_TITLE (WM_USER)
#define CM_NOTIFY_FROM_TRAY (WM_APP + 1)
leonMSFT marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions src/cascadia/WindowsTerminal/WindowsTerminal.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
<ProjectReference Include="$(OpenConsoleDir)src\cascadia\TerminalSettingsEditor\Microsoft.Terminal.Settings.Editor.vcxproj" />

<ProjectReference Include="$(OpenConsoleDir)src\types\lib\types.vcxproj" />
<ProjectReference Include="$(OpenConsoleDir)src\cascadia\WinRTUtils\WinRTUtils.vcxproj">
<Project>{CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>

<!-- Manually add a reference to Core here. We need this so MDMERGE will know
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/WindowsTerminal/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Module Name:
#include <winrt/Windows.UI.Xaml.Controls.h>
#include <winrt/Windows.ui.xaml.media.h>
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.ApplicationModel.Resources.Core.h>

#include <winrt/TerminalApp.h>
#include <winrt/Microsoft.Terminal.Settings.Model.h>
Expand Down