Skip to content

cocoa: re-assert applicationIconImage when switching to Regular - #116

Merged
tannevaled merged 1 commit into
mainfrom
dockicon-refresh-on-regular
Sep 9, 2026
Merged

tannevaled merged 1 commit into
mainfrom
dockicon-refresh-on-regular

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Summary

A menu-bar (accessory-policy) process that sets its Dock icon once at startup — before it ever has a Dock tile to update — found that icon silently absent once a real window later switched it to Regular. The icon property itself stayed correctly set throughout (-applicationIconImage kept reporting the right image at every step, verified), but the Dock tile showed a generic icon regardless.

Apple's own DTS guidance on this exact Accessory↔Regular pattern (a Qt developer hit the same thing on the developer forums) says plainly that the Dock's reaction to a runtime icon change is not instant and can revert unexpectedly across a policy transition.

NewWithOptions now re-sends whatever applicationIconImage is already set (a no-op if none is) right when it switches to Regular. Live human-verified on a real Dock tile: absent before this change, present after, using the exact same go-macos/objc.SetApplicationIconImage call this fix does nothing to alter.

Also bumps go-macos/objc to v0.10.1: SetApplicationIconImage itself had a separate load-order bug (fixed upstream, go-macos/objc#18) that made it a no-op as the first-ever AppKit call in a process — exactly a menu-bar app's own startup — so this repo needed that fix before the re-assert above had anything correct to re-assert in the first place.

Test plan

  • go build ./..., go vet ./..., gofmt -l . clean
  • go test ./... (non-integration) green across every package
  • New on-device integration test TestApplicationIconSurvivesAccessoryToRegular passes
  • Live human confirmation on a real Dock tile (screenshotted, compared against the reference logo)
  • Full -tags=integration on-device suite otherwise green; two unrelated failures observed locally (TestLiveCocoaDragDrop, flaky — passed on retry; several screen-list tests) were caused by the local display going to sleep mid-run (Display Asleep: Yes, CGGetActiveDisplayList counted 0 displays), not by this change — deferring to CI's dedicated on-device runner for the authoritative signal

🤖 Generated with Claude Code

…olicy

A menu-bar (accessory-policy) process that sets its Dock icon once at
startup — before it has ever had a Dock tile to update — found that
icon silently absent once a real window later switched it to Regular:
the icon property itself stayed correctly set throughout (confirmed:
-applicationIconImage kept reporting the right image), but the Dock
tile itself showed a generic icon regardless. Apple's own DTS guidance
on this exact Accessory<->Regular pattern (a Qt developer hit the same
thing) says plainly that the Dock's reaction to a runtime icon change
is not instant and can revert unexpectedly across a policy transition.

NewWithOptions now re-sends whatever applicationIconImage is already
set (a no-op if none is) right when it switches to Regular — live
human-verified on a real Dock tile: absent before this change, present
after, using the exact same go-macos/objc.SetApplicationIconImage call
this fix does nothing to alter.

Also bumps go-macos/objc to v0.10.1: SetApplicationIconImage itself had
a separate load-order bug (fixed upstream) that made it a no-op as the
first-ever AppKit call in a process — exactly a menu-bar app's own
startup — so this repo needed that fix before the re-assert above had
anything correct to re-assert in the first place.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit c3fc7ff into main Sep 9, 2026
28 checks passed
@tannevaled
tannevaled deleted the dockicon-refresh-on-regular branch September 9, 2026 14:58
tannevaled added a commit to go-aiquota/tray that referenced this pull request Sep 9, 2026
No code change needed — window.Open now re-asserts applicationIconImage
when switching to Regular activation policy (go-widgets/window#116),
which is what actually makes the branded Dock icon (#22) show up: the
image was always set correctly internally, but the Dock tile itself
needed the re-assert at the policy transition to pick it up (a known
AppKit quirk per Apple's own DTS guidance on this exact pattern).

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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.

1 participant