Fix tray icon: no blink on startup, instant vanish on hide and exit#505
Merged
Conversation
Fixes three notification-area bugs on Windows: 1. Transparent-slot blink on startup TrayIcon.IsVisible defaults to true, so its constructor calls NIM_ADD with an empty transparent icon before any bitmap is ready. A HiddenByDefaultTrayIcon subclass overrides the default to false via Avalonia's OverrideDefaultValue API; the first NIM_ADD only fires when we have a real bitmap. 2. Leftmost-position blink on first show NIM_ADD places the icon at the leftmost position on first call. Setting IsVisible=true before assigning the bitmap triggers NIM_ADD with the transparent placeholder (invisible); the bitmap assignment becomes NIM_MODIFY at the correct slot position with no visible jump. 3. Ghost icon lingers after hide or exit until hover Windows does not repaint the notification area after NIM_DELETE. PostMessage(WM_SIZE) to TrayNotifyWnd forces an immediate redraw, called on the Visible=false path and on ShutdownStarted. Also fixes a race in MainService.StartNotifierAsync: apply Visible=!HideTrayIcon before SetIconAsync so the queued show-lambda sees _visible=false and skips NIM_ADD entirely when the option is on. Bump HLab.Avalonia to 29781c1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes several notification-area bugs on Windows:
Depends on mgth/HLab.Avalonia#3
Changes:
Bumps HLab.Avalonia submodule to the commit from the companion PR