Why is the HSHELL_WINDOWDESTROYED notification raised when a window is hidden, even if it hasn’t been destroyed?

Raymond Chen

The shell notification HSHELL_WINDOW­CREATED means that there is a new top-level unowned visible window. Conversely, HSHELL_WINDOW­DESTROYED means that a window is no longer a top-level unowned visible window. But these state changes can occur for reasons other than a window being created and destroyed. For example, if a top-level window hides itself, then that will generate a HSHELL_WINDOW­DESTROYED notification, even though no window was destroyed.

Why don’t the names align with what they mean?

These notifications were named while wearing taskbar-colored glasses.

These notifications were created to assist the taskbar in keeping track of the windows in the system. The taskbar shows top-level unowned visible windows, so that’s what the notifications pay attention to. If you hide a top-level unowned window, it hasn’t been destroyed, but it may as well have been destroyed as far as the taskbar is concerned: The window disappears from the taskbar.

Conversely, when the window becomes visible again, it gains a taskbar button. As far as the taskbar is concerned, it may as well have been newly-created.


Discussion is closed. Login to edit/delete existing comments.

Feedback usabilla icon