7 min readPost 33
Selecting a whole day at once, and why double-clicking the Windows tray icon couldn't open the window
Two seemingly tiny desktop UX requests—clicking a calendar day header to batch-act on all items and double-clicking the Windows tray icon to open Obituary—exposed subtle mode-downgrade hazards and a Win32 modal menu message-loop trap. Here is how a 3-state mode guard and a lock-free GWLP_WNDPROC subclass solved both cleanly.

On this page
Obituary's desktop experience pairs a lightweight resident tray daemon (obitd) with a Wails v2 + React calendar window (obit-gui). Late in November, two everyday usability requests came up:
- When a single day in the calendar holds a dozen expiring files, clicking them one by one gets tedious—let users click the day column header to select the entire day and batch-extend, bury, resurrect, or purge.
- On Windows, users instinctively double-click a tray icon (like Steam, WeChat, or Clash) to bring up the main panel instead of right-clicking a menu every time.
Both sounded like minor UI tweaks. Once implemented and put through independent code review, both uncovered surprisingly deep safety and Win32 systems problems.

1. Calendar day multiselect: protecting batch burials from silent downgrades and lost Undo
Day-header multiselect and a floating squircle capsule action bar landed in draft on 26 November (151ef2c) and went through two review rounds with 12 targeted fixes (d780e06, de29f9a). Four safety invariants mattered far more than the checkboxes themselves:

Three-state effective mode: disable instead of silently recycling
Obituary runs in either graveyard mode or recycle (OS Recycle Bin) mode. Previously the frontend read mode from Summary(), which re-read config.toml from disk—meaning a corrupt .obitrules trust file breaking Summary(), or an unsynced disk edit, could leave the UI thinking it was in graveyard mode while the backend actually recycled plain files without showing the Recycle Bin confirmation!
We collapsed the truth to one source:
- Go's
(*API).effectiveMode()reads solely from liveService.Mode(the exact fieldBuryexecutes against), returned by bothSummary()andUpcoming(). - The frontend tracks
"graveyard" | "recycle" | "unknown". Whenever mode resolves tounknownand the selection contains plain files, Bury now disables in the UI and double-checks inside the executor, never silently degrading to unconfirmed recycling; inrecyclemode, both single and mixed confirmations explicitly state when plain files go to the OS Recycle Bin.
Splitting warningCount from failedCount so Undo never disappears
During batch burial, a file can commit cleanly into the graveyard (action === "buried" with a valid grave ID) yet attach a non-fatal cleanup warning (for instance, an Explorer label sync hiccup). Early code treated any non-empty error string as failedCount and dropped the entry from buriedIds—telling the user burial "failed" while stripping that grave from one-click Undo. Splitting out warningCount keeps every committed burial inside buriedIds so Undo stays intact.
Three more batch and layout invariants
- Resolve each ref once inside
ExtendGraves:prepareExtendGravescallsfindBurialonce per reference insidegraveyard.lockand cleans v1 manifests beforeapplyExtendGravescommits, preventing a transientLongPatherror from bypassing manifest checks. - Distinguishing manual vs. expired container burial: batch-burying an unexpired Docker container now persists
Reason: "bury"onContainerIntent(separate from"expired"), preserved cleanly across disconnect recovery and wired into graveyard FIFO quota enforcement. - Short-viewport capsule docking: under
@media (max-height: 460px)(such as600×400), the floating squircle capsule switches toposition: staticbelow the columns so it never obscures the bottom card's checkbox.
2. Why double-clicking the Windows tray icon couldn't open the window
Next came GitHub Issue #27: double-clicking the Windows tray icon to open Obituary (4b583c4).
We expected a one-line callback registration on fyne.io/systray v1.12.2. Reading systray_windows.go line by line revealed two stacked blockers:
- No double-click handling at all: handling
WM_USER + 1 (0x0401),systray_windows.go'swndProcswitched only onWM_LBUTTONUP (0x0202)andWM_RBUTTONUP (0x0205), completely ignoringWM_LBUTTONDBLCLK (0x0203). - The first click's popup menu swallowed the second click: on a double-click, Windows Explorer posts four messages in sequence:
WM_LBUTTONDOWN (0x0201)→WM_LBUTTONUP (0x0202)→WM_LBUTTONDBLCLK (0x0203)→WM_LBUTTONUP (0x0202). On the very firstWM_LBUTTONUP,systraycalled synchronousTrackPopupMenu(...), dropping straight into Win32's modal menu message loop—consuming click #2 just to dismiss the menu soWM_LBUTTONDBLCLKnever even arrived!
A zero-dependency fix: lock-free GWLP_WNDPROC subclassing
Forking the tray library was overkill, and our Windows visibility and notification code already depends on systray's hidden SystrayClass window. Instead, internal/tray/click_windows.go solves it in under 150 lines of zero-CGO Go:
- Race-free subclass install: inside
systray.Run'sonReadycallback, locate our own process'sSystrayClasshandle viadesktop.OwnWindow("SystrayClass"), read the originalprevproc, publish*trayWindowHookatomically viaatomic.Pointer, and only then swapGWLP_WNDPROCwithSetWindowLongPtrW(SetWindowLongWon 386). - Lock-free dispatch and single callback slot: allocate
windows.NewCallbackonce viasync.Once; keeptraySubclassProccompletely lock-free to avoid reentrancy deadlocks duringTrackPopupMenu, cleaning up cleanly onWM_NCDESTROY. - Exact message routing:
WM_LBUTTONUP (0x0202): swallowed (return 0), preventing the blocking popup menu so click #2 generatesWM_LBUTTONDBLCLK.WM_LBUTTONDBLCLK (0x0203): non-blocking send to a capacity-1m.activatechannel (coalescing rapid clicks off the Win32 UI thread) feedingm.openGUI.open()—reusingOBIT_HOMEsingle-instance window focus and missing-GUI notifications without touching our 1.6.1 ghost-click guards or zero-idle-wakeup guarantee.WM_RBUTTONUP (0x0205),WM_COMMAND,TaskbarCreated, and all other messages: forwarded untouched viaCallWindowProcW, keeping right-click menus and Explorer-restart recovery intact.
We verified the subclass against a real isolated Win32 HWND_MESSAGE window replaying LBUTTONDOWN → LBUTTONUP → LBUTTONDBLCLK → LBUTTONUP → RBUTTONUP and clean teardown (TestSubclassWindowDispatchesTrayMessages).
Respecting native platform conventions across all three OSes
| Platform | Mechanism | Left click | Right click |
|---|---|---|---|
| Windows | Win32 Shell_NotifyIconW + GWLP_WNDPROC | Double-click opens/focuses window | Right-click opens full tray menu |
| Linux (desktop) | D-Bus StatusNotifierItem + dbusmenu | Calling systray.SetOnTapped before systray.Run exports ItemIsMenu=false race-free; left-click (Activate) opens window on KDE/AppIndicator | Right-click opens full DBusMenu |
| macOS (desktop) | Cocoa NSStatusItem | Single-click opens native menu bar menu ("Open Obituary" at top) | Single-click opens menu |
Each OS keeps its native desktop feel instead of forcing Windows double-clicks onto macOS or breaking Linux right-click menus.