Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

feature(windows): Add the tray icon when a new taskbar is created. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions tray/src/core/windows/tray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <components/toggle.hpp>

static constexpr auto WM_TRAY = WM_USER + 1;
const static auto WM_TASKBARCREATED = RegisterWindowMessage("TaskbarCreated");
std::map<HWND, std::reference_wrapper<Tray::Tray>> Tray::Tray::trayList;

Tray::Tray::Tray(std::string identifier, Icon icon) : BaseTray(std::move(identifier), icon)
Expand Down Expand Up @@ -205,6 +206,14 @@ LRESULT CALLBACK Tray::Tray::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
}
}
break;
default:
if (msg == WM_TASKBARCREATED)
{
auto &menu = trayList.at(hwnd).get();
if (Shell_NotifyIcon(NIM_ADD, &menu.notifyData) == FALSE)
throw std::runtime_error("Failed to register tray icon on taskbar created");
}
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
Expand Down