Merge pull request #2467 from devinbileck/bugfix-1996

Fix Windows system tray icon resolution
This commit is contained in:
Manfred Karrer 2019-02-26 09:30:49 -05:00 committed by GitHub
commit 341b718026
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,11 +106,16 @@ public class SystemTray {
try {
BufferedImage trayIconImage = ImageIO.read(getClass().getResource(path));
TrayIcon trayIcon = new TrayIcon(trayIconImage);
// On Windows and Linux the icon needs to be scaled
// On Windows and Linux the icon needs to be resized
// On macOS we get the correct size from the provided image
if (!Utilities.isOSX()) {
int trayIconWidth = trayIcon.getSize().width;
trayIcon = new TrayIcon(trayIconImage.getScaledInstance(trayIconWidth, -1, Image.SCALE_SMOOTH));
if (ImageUtil.isRetina()) {
// Using auto sizing provides better results with high resolution
trayIcon.setImageAutoSize(true);
} else {
// Using scaling provides better results with low resolution
trayIcon = new TrayIcon(trayIconImage.getScaledInstance(trayIcon.getSize().width, -1, Image.SCALE_SMOOTH));
}
}
trayIcon.setPopupMenu(popupMenu);