dustinkredmond / FXTrayIcon

Tray Icon implementation for JavaFX applications. Say goodbye to using AWT's SystemTray icon, instead use a JavaFX Tray Icon.
MIT License
324 stars 25 forks source link

Only square icons possible? #69

Closed HanSolo closed 1 year ago

HanSolo commented 1 year ago

It looks like in the latest version only square icons are possible (on macos). In the older version I could also use an rectangular icon but in 4.0.1 it only accepts square icons even if I define the icon like 64x32. Is this on purpose?

EasyG0ing1 commented 1 year ago

@HanSolo - In my experience, MacOS won't even allow icons to be larger than 22 x 22 in the system tray. Though admittedly I haven't tried any rectangular dimensions. Can the system tray even display 64 x 32 without resizing it?

HanSolo commented 1 year ago

I did display the rectangular version in an older version of FXTrayIcon but not in the newer version anymore. And yes it will scale down the image (I’ve choosen a higher resolution to get a sharper result because it is text).

HanSolo commented 1 year ago
FXTrayIcon_3_1_2 FXTrayIcon_4_0_1

The first image is with FXTrayIcon 3.1.2 and the other with 4.0.1, I guess you can see the difference, just changed the version of FXTrayIcon, no code changes.

dustinkredmond commented 1 year ago

@HanSolo thank you for catching this!

Looks like my commit 1f0b55e probably broke this for MacOS users. 😞

Unfortunately I don't have a machine running MacOS, so it's hard for me to test each change on each platform. I will see if there's a way to make this drop back to the old behavior without affecting people that wanted the improvements that 1f0b55e provided. Should be a quick fix.

EasyG0ing1 commented 1 year ago

@HanSolo How are you instantiating FXTrayIcon? When I try that icon with 3.1.2, it looks like this

Screenshot 2022-12-26 at 8 46 45 AM

This is the icon that I'm using

icon

Here is the dependency declaration

        <dependency>
            <groupId>com.dustinredmond.fxtrayicon</groupId>
            <artifactId>FXTrayIcon</artifactId>
            <version>3.1.2</version>
        </dependency>

And this is how I'm instantiating

FXTrayIcon icon = new FXTrayIcon.Builder(stage,iconurl,22,22).addExitMenuItem().show().build();
EasyG0ing1 commented 1 year ago

@HanSolo I even tried making the same icon with proportional dimensions

icon

But I get the same results from 3.1.2 and 4.0.1

Nonetheless, based on What Dustin said about that commit causing the issue, this one here only executes that change if the machine is not running MacOS, so it will not run that code if it's being ran on a mac ... try this and see if it doesn't solve the problem:

FXTrayIcon-4.0.1-SIMS.jar.zip

If it does, I'll submit the PR

HanSolo commented 1 year ago

Sorry, was on vacation and on travel. It looks like the patch from @EasyG0ing1 fixes the issue 👍🏻

dustinkredmond commented 1 year ago

Closing issue as @EasyG0ing1 pushed a commit to fix this issue. Looks like it's another one of those issues specific to MacOS.