From 0aab9d8db65a7c3c41c454336b96f5edac125e52 Mon Sep 17 00:00:00 2001 From: Mikhail Yenuchenko Date: Wed, 5 Aug 2026 23:02:52 +0300 Subject: [PATCH] Register Windows notification icon via metadata after NewWindow. Fyne toasts read App.Icon without SetIcon, preserving the PE multi-size window and taskbar icon while giving failure notifications app artwork. Co-authored-by: Cursor --- assets/assets.go | 2 ++ docs/CHANGELOG.md | 6 ++++++ src/ui/run.go | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/assets/assets.go b/assets/assets.go index 82e1951..095c2ea 100644 --- a/assets/assets.go +++ b/assets/assets.go @@ -44,6 +44,8 @@ import ( // - Tray: SetSystemTrayIcon(IconSmallICO()). The notification area is ICO-native // and renders at 16-24px; a single-frame 16x16 .ico pins the hand-tuned glyph // (a multi-size .ico made the tray pick and downscale a larger frame). +// - Desktop toasts: AppMetadata.Icon (set after NewWindow in run.go) feeds +// SendNotification without calling SetIcon, which would override GLFW_ICON. // // Linux / other non-Windows (no PE icon resource exists): // - Window titlebar: a.SetIcon(IconSmall()) in run.go feeds the resource to diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 5e0d7c8..52a48ea 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,6 +4,12 @@ All notable GoSentry changes are recorded in this file. ## 1.0.1 - 2026-08-04 +**Windows failure notifications can show the app icon (experimental).** + +- **`ui.run`** — after `NewWindow`, register `AppMetadata.Icon` on Windows so + Fyne toasts pick up artwork without calling `SetIcon`, which would override + the PE multi-size window/taskbar icon. + **Sample jobs include a disabled failure test for desktop notifications.** - **`storage.defaultJobs`** — new disabled example *Failure notification test* diff --git a/src/ui/run.go b/src/ui/run.go index fe899c9..0d0885b 100644 --- a/src/ui/run.go +++ b/src/ui/run.go @@ -59,6 +59,7 @@ func Run(startInTray bool) { } w := a.NewWindow("GoSentry " + app.Version) + setWindowsNotificationIcon() prefs := a.Preferences() winW := float32(prefs.FloatWithFallback("window.width", defaultWindowWidth)) winH := float32(prefs.FloatWithFallback("window.height", defaultWindowHeight)) @@ -94,3 +95,20 @@ func Run(startInTray bool) { recordStartup(time.Since(started), true) a.Run() } + +// setWindowsNotificationIcon supplies App.Icon for Fyne desktop notifications +// without touching the window or taskbar icon. On Windows those come from the PE +// gosentry.ico resource, so run.go must not call SetIcon. Fyne's NewWindow ends +// with SetIcon(nil), which adopts App.Icon when it is already set — metadata +// must therefore be registered only after the window is created. The tray icon +// is set separately in tray.go via SetSystemTrayIcon. +func setWindowsNotificationIcon() { + if runtime.GOOS != "windows" { + return + } + fyneapp.SetMetadata(fyne.AppMetadata{ + ID: appID, + Name: "GoSentry", + Icon: assets.Icon(), + }) +}