@@ -38,6 +38,42 @@ extern BOOL PREVIOUS_TOPMOST_STATE;
3838
3939#define OPACITY_FULL 255
4040
41+ /* ============================================================================
42+ * Power Management Handler
43+ * ============================================================================ */
44+
45+ static LRESULT HandlePowerBroadcast (HWND hwnd , WPARAM wp , LPARAM lp ) {
46+ (void )lp ;
47+ static volatile LONG s_handling = 0 ;
48+
49+ /* Handle system resume from sleep/hibernate */
50+ if (wp == PBT_APMRESUMEAUTOMATIC || wp == PBT_APMRESUMESUSPEND ) {
51+ /* Prevent re-entry if called multiple times in quick succession */
52+ if (InterlockedCompareExchange (& s_handling , 1 , 0 ) != 0 ) {
53+ return TRUE;
54+ }
55+
56+ LOG_INFO ("System resumed from sleep/hibernate, reinitializing tray icon animation" );
57+
58+ /* Step 1: Clear animation name to force reload
59+ * This bypasses the "same name" check in ApplyAnimationPathValueNoPersist */
60+ extern void TrayAnimation_ClearCurrentName (void );
61+ TrayAnimation_ClearCurrentName ();
62+
63+ /* Step 2: Reload animation from config */
64+ extern LRESULT HandleAppAnimPathChanged (HWND );
65+ HandleAppAnimPathChanged (hwnd );
66+
67+ /* Step 3: Recreate tray icon with newly loaded animation */
68+ extern void RecreateTaskbarIcon (HWND , HINSTANCE );
69+ RecreateTaskbarIcon (hwnd , GetModuleHandle (NULL ));
70+
71+ InterlockedExchange (& s_handling , 0 );
72+ }
73+
74+ return TRUE;
75+ }
76+
4177/* ============================================================================
4278 * Application Message Dispatch Table
4379 * ============================================================================ */
@@ -117,6 +153,7 @@ static const MessageDispatchEntry MESSAGE_DISPATCH_TABLE[] = {
117153 {WM_KEYDOWN , HandleKeyDown , "Key down" },
118154 {WM_HOTKEY , HandleHotkey , "Global hotkey" },
119155 {WM_COPYDATA , HandleCopyData , "Inter-process communication" },
156+ {WM_POWERBROADCAST , HandlePowerBroadcast , "Power management events" },
120157 {WM_APP_QUICK_COUNTDOWN_INDEX , HandleQuickCountdownIndex , "Quick countdown by index" },
121158 {WM_APP_SHOW_CLI_HELP , HandleShowCliHelp , "Show CLI help" },
122159 {WM_USER + 100 , HandleTrayUpdateIcon , "Tray icon update" },
0 commit comments