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

Tray icon is non-transparent on some Linux desktop environments #82

Open
crschnick opened this issue Aug 7, 2023 · 4 comments
Open

Comments

@crschnick
Copy link

crschnick commented Aug 7, 2023

I have tested my application xpipe on various Linux distros and noticed that the tray icon it looks off on some of them. Here is for example how it looks on manjaro with Plasma and KWin (the default Manjaro ones):

image

On any other operating system or DEs like gnome it looks fine.

For reference, this is the code I use to call FXTrayIcon: https://github.com/xpipe-io/xpipex/blob/d2ac3383ac0b6202f567f42b963819f10b0c98c8/app/src/main/java/io/xpipe/app/core/AppTray.java

@EasyG0ing1
Copy link
Contributor

EasyG0ing1 commented Aug 9, 2023

@crschnick I'm curious as to how you got a TrayIcon to work in Linux at all. The last time I looked into it, Gnome didn't even have a system tray which necessitated adding a third-party system tray and that's as far as I got.

Could you share how you got FXTrayIcon working on the various Linux desktops?

Also, FXTrayIcon is a wrapper for AWT (JavaFX doesn't support system tray icons). The rendering of the icon image itself happens outside of FXTrayIcon's control. We have noticed that different desktops like different image sizes for the icon. For example, Windows likes a 16x16 icon image while MacOS likes a 22x22 icon image. Going larger than 22x22 in MacOS (for example) changes nothing while going larger in Windows distorts the icon. You might try playing with different icon sizes in the various desktop environments to see if you can find their "sweet spot" icon size so that your icon doesn't look like the odd man out.

@crschnick
Copy link
Author

It works out of the box for me on Manjaro and EndeavourOS but not on something like Ubuntu. I didn't do anything special here, it just worked.

I guess the issue lies with a bad AWT implementation: https://stackoverflow.com/questions/331407/java-trayicon-using-image-with-transparent-background?rq=4 . Judging from the age of that issue, it's probably not going to get fixed.

@crschnick
Copy link
Author

@EasyG0ing1
Copy link
Contributor

@crschnick There has been an open issue with implementing Tray Icons in the official JavaFX developers issue tracker for close to 8 years now. It looked like it was gaining some traction, and then stopped dead in its tracks. They apparently were looking for someone who could basically back-engineer the AWT code and adapt it to total native FX ... but no one had taken it on the last time I checked.

Glad you found a fix for this.

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

2 participants