dmikushin / tray

Cross-platform, super tiny C99 implementation of a system tray icon with a popup menu.
MIT License
87 stars 16 forks source link

Re-add the tray icon if Explorer restarts #11

Closed cgutman closed 1 year ago

cgutman commented 1 year ago

When Explorer restarts, it's the application's responsibility to re-add any notification icons that were present. To trigger this, Explorer will send a global TaskbarCreated message. Details on this process are available on MSDN here: https://learn.microsoft.com/en-us/windows/win32/shell/taskbar#taskbar-creation-notification

This PR introduces handling of this message in _tray_wnd_proc() to prevent the tray icon from disappearing after an Explorer crash/restart.

The existing bug can be reproduced as follows:

  1. Create a tray icon using tray_init() and confirm presence in the notification area.
  2. Open Task Manager, right click "Windows Explorer" on the Processes tab, and select Restart.
  3. After Explorer starts up again, check for the presence of the tray icon again.

Prior to this PR, the tray icon will not reappear. With this change, it reappears properly.

dmikushin commented 1 year ago

Hi @cgutman , great catch, thank you for working on this!