Skip to content

Conversation

sratz
Copy link
Member

@sratz sratz commented Oct 14, 2025

Currently, there are three possible sources for the Dock icon on macOS in the order of precedence:

  1. An explicitly set icon via
    -Xdock:icon=/path/to/icon.icns
    which calls
    NSApp setApplicationIconImage

  2. An implicitly set icon via
    org.eclipse.swt.widgets.Decorations.setImage(Image)
    org.eclipse.swt.widgets.Decorations.setImages(Image[])
    which in passed down to the Dock also via
    NSApp setApplicationIconImage

  3. An implicitly set icon in a Bundled.app distrubution via
    CFBundleIconName / CFBundleIconFile in the Info.plist file

1 and 2 use legacy API NSApp setApplicationIconImage which only supports a single fixed NSImage, i.e. there is no support for dark/light mode and or modern look & feel such as Liquid Glass.

Only 3 (app bundle) supports dynamic icons.

The problem is that 2) currently overwrites whatever 3) has set. On top of that, the Decorations are typically cross-platform, so in fact this will prevents using a macOS-specific icon at all.

We want to prefer 3) over 2), i.e. only pass down the decorations whenever we are not an app bundle with a declared image.

Similar coding also exists in the JVM, where the dock icon is only set if we are not in an app bundle that specifies an icon:

https://github.com/openjdk/jdk21u/blob/8c322f5953ae161d793213f92d13a1f53d995883/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m#L280-L290

Resolves #2627

Currently, there are three possible sources for the Dock icon on macOS
in the order of precedence:

1) An explicitly set icon via
   -Xdock:icon=/path/to/icon.icns
   which calls
   NSApp setApplicationIconImage

2) An implicitly set icon via
   org.eclipse.swt.widgets.Decorations.setImage(Image)
   org.eclipse.swt.widgets.Decorations.setImages(Image[])
   which in passed down to the Dock also via
   NSApp setApplicationIconImage

3) An implicitly set icon in a Bundled.app distrubution via
   CFBundleIconName / CFBundleIconFile in the Info.plist file

1) and 2) use legacy API NSApp setApplicationIconImage which only
supports a single fixed NSImage, i.e. there is no support for dark/light
mode and or modern look & feel such as Liquid Glass.

Only 3) (app bundle) supports dynamic icons.

The problem is that 2) currently overwrites whatever 3) has set. On top
of that, the Decorations are typically cross-platform, so in fact this
will prevents using a macOS-specific icon at all.

We want to prefer 3) over 2), i.e. only pass down the decorations
whenever we are *not* an app bundle with a declared image.

Similar coding also exists in the JVM, where the dock icon is only set
if we are *not* in an app bundle that specifies an icon:

https://github.com/openjdk/jdk21u/blob/8c322f5953ae161d793213f92d13a1f53d995883/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m#L280-L290
@sratz sratz requested a review from BeckerWdf October 14, 2025 15:52
@sratz sratz added the macOS happens on macOS label Oct 14, 2025
Copy link
Contributor

github-actions bot commented Oct 14, 2025

Test Results

  115 files  ±0    115 suites  ±0   10m 0s ⏱️ - 2m 34s
4 546 tests ±0  4 531 ✅ ±0  15 💤 ±0  0 ❌ ±0 
  311 runs  ±0    308 ✅ ±0   3 💤 ±0  0 ❌ ±0 

Results for commit 0f31d33. ± Comparison against base commit 79e74c7.

♻️ This comment has been updated with latest results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macOS happens on macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[macOS] Decorations#setImage() overwrites Dock icon specified in App Bundle

1 participant