Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support retina display for OS X #8

Open
liudanking opened this issue Oct 29, 2015 · 12 comments
Open

Feature request: support retina display for OS X #8

liudanking opened this issue Oct 29, 2015 · 12 comments

Comments

@liudanking
Copy link

Systray only uses the same icon for both normal and retina display which makes systray icon looks not smooth for retina display.
To support retina display icon, it may need to update some OC codes. As I am not a OC programmer, hope someone will implement it.

@myleshorton
Copy link
Contributor

@carsonefv or @Derekf5 you guys want to take a look at this?

@xor-gate
Copy link

xor-gate commented Jun 11, 2016

It is far easier than you think you have to create 2 png (imagemagick convert) files with 2x increment in size and then squash them together into a tiff (tiffutil) and then load as normal:

convert -background none img/darwin/$ICON.svg -resize 32x32 -sharpen 1 img/darwin/$ICON.png
convert -background none img/darwin/$ICON.svg -resize 64x64 -sharpen 1 img/darwin/$ICON@2x.png
tiffutil -cathidpicheck img/darwin/$ICON.png img/darwin/$ICON@2x.png -out img/darwin/$ICON.tiff
$GOPATH/bin/2goarray $ICON main < img/darwin/$ICON.tiff |  grep -v package >> "$OUTPUT"

See:
https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Optimizing/Optimizing.html#//apple_ref/doc/uid/TP40012302-CH7-SW13

@liudanking
Copy link
Author

@xor-gate Awesome! It woks like a charm.

@liudanking
Copy link
Author

liudanking commented Jun 12, 2016

@xor-gate I meet another problem:

After I packaged my golang-app into a OSX application, say foo.app, the retina icon is gone.
It seems that OS X add some actions when launching foo.app, but have no idea what did it do.

@xor-gate
Copy link

The icon is gone? You must make sure you load the tiff as byte array and not the png.

@liudanking
Copy link
Author

liudanking commented Jun 12, 2016

I mean the retina icon is not shown, only the default one is shown.
I am pretty sure I load the tiff as byte array, because if I copy foo.app/Contents/MacOS/foo to a normal directory, and launch foo with ./foo, the retina icon is displayed as expected.

@xor-gate
Copy link

xor-gate commented Jun 12, 2016

Probably the application bundle loader is not properly configured to have support for multiimage. Could you paste your Plist.info?

@liudanking
Copy link
Author

liudanking commented Jun 12, 2016

Below is my info.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist
  SYSTEM 'file://localhost/System/Library/DTDs/PropertyList.dtd'>
<plist version="0.9">
    <dict>
        <key>CFBundleExecutable</key>
        <string>foo</string>
        <key>CFBundleGetInfoString</key>
        <string>hi</string>
        <key>CFBundleIconFile</key>
        <string>app.icns</string>
        <key>CFBundleIdentifier</key>
        <string>foo</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleName</key>
        <string>foo</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>0.0.1</string>
        <key>CFBundleSignature</key>
        <string>WRUN</string>
        <key>CFBundleVersion</key>
        <string>0.0.3</string>
        <!-- Set LSUIElement to indicate this is an agent app, meaning that it
             does not get an icon in the dock. -->
        <key>LSUIElement</key>
        <string>1</string>
    </dict>
</plist>

@xor-gate
Copy link

xor-gate commented Jun 12, 2016

Try adding:

    <key>LSMinimumSystemVersion</key>
    <string>10.10</string>

Probably it changes behaviour how the Foundation.framework is loaded and the image load process.

As: https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html

See my Info.plist: https://github.com/xor-gate/syncthing-mac/blob/master/template/Contents/Info.plist

@liudanking
Copy link
Author

liudanking commented Jun 12, 2016

I still can not make it work after adding LSMinimumSystemVersion.
I find your Info.plist have much more items than mine, I will check all these items tomorrow.

@liudanking
Copy link
Author

@xor-gate With some luck, the problem is solved by adding:

        <key>LSMinimumSystemVersion</key>
        <string>10.10</string>
        <key>NSPrincipalClass</key>
        <string>NSApplication</string>

Many thanks for your help.

@fffw fffw self-assigned this Jun 13, 2016
@meskio
Copy link
Contributor

meskio commented Mar 20, 2018

I'm a bit confused reading the code it seems that 16x16 is hardcoded as icon size:
https://github.com/getlantern/systray/blob/master/systray_darwin.m#L162

Is that not true? Does the library support other icon sizes for OS X?

@meskio meskio unassigned fffw Mar 20, 2018
@getlantern getlantern deleted a comment from xor-gate Mar 1, 2021
@getlantern getlantern deleted a comment from fffw Mar 1, 2021
@getlantern getlantern deleted a comment from xor-gate Mar 1, 2021
@getlantern getlantern deleted a comment from joesis Mar 1, 2021
bdwyertech pushed a commit to bdwyertech/systray that referenced this issue Dec 19, 2022
Fix changing properties, scale images and other improvements
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

No branches or pull requests

6 participants
@meskio @xor-gate @myleshorton @liudanking @fffw and others