Skip to content

Fix tray icon: no blink on startup, instant vanish on hide and exit#505

Merged
mgth merged 1 commit into
mgth:masterfrom
funnything1:fix/tray-icon-improvements
Jul 18, 2026
Merged

Fix tray icon: no blink on startup, instant vanish on hide and exit#505
mgth merged 1 commit into
mgth:masterfrom
funnything1:fix/tray-icon-improvements

Conversation

@funnything1

Copy link
Copy Markdown

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

  • Moves _notify.Visible = !_options.HideTrayIcon before SetIconAsync in MainService.StartNotifierAsync. Without this ordering, SetIconAsync queues a show-lambda on the dispatcher before the Visible=false flag is set, causing a brief blink even when "Hide Tray Icon" is enabled

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.
@mgth
mgth merged commit 19f4b75 into mgth:master Jul 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants