From 91cdbdc12517d0d832aca715542b9d0329739d5d Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Sep 2025 11:53:36 +0800 Subject: [PATCH] fix: Windows tray icon disappearing after sleep/wake cycles --- .../tray_manager/windows/tray_manager_plugin.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/tray_manager/windows/tray_manager_plugin.cpp b/packages/tray_manager/windows/tray_manager_plugin.cpp index e3ff055..d842125 100644 --- a/packages/tray_manager/windows/tray_manager_plugin.cpp +++ b/packages/tray_manager/windows/tray_manager_plugin.cpp @@ -214,6 +214,21 @@ std::optional TrayManagerPlugin::HandleWindowProc(HWND hWnd, tray_icon_setted = false; _ApplyIcon(); } + } else if (message == WM_POWERBROADCAST) { + // Handle power management events (sleep/wake) + switch (wParam) { + case PBT_APMRESUMEAUTOMATIC: + case PBT_APMRESUMESUSPEND: + // System is resuming from sleep/hibernation + if (tray_icon_setted) { + // Restore the tray icon after system wakes up + tray_icon_setted = false; + _ApplyIcon(); + } + break; + default: + break; + } } return result; }