Fixed issues with windows/mac

This commit is contained in:
nathan 2016-10-04 16:59:22 +02:00
parent 62c73e8f32
commit 42d053398f
7 changed files with 25 additions and 27 deletions

View File

@ -66,7 +66,7 @@ class AppIndicatorTray extends GtkTypeSystemTray {
throw new IllegalArgumentException("Unable to start AppIndicator if 'SystemTray.FORCE_TRAY_TYPE' is set to GtkStatusIcon");
}
ImageUtils.determineIconSize(SystemTray.TYPE_APP_INDICATOR);
ImageUtils.determineIconSize();
Gtk.startGui();
dispatch(new Runnable() {

View File

@ -58,7 +58,7 @@ class GtkSystemTray extends GtkTypeSystemTray {
throw new IllegalArgumentException("Unable to start GtkStatusIcon if 'SystemTray.FORCE_TRAY_TYPE' is set to AppIndicator");
}
ImageUtils.determineIconSize(SystemTray.TYPE_GTK_STATUSICON);
ImageUtils.determineIconSize();
Gtk.startGui();
dispatch(new Runnable() {

View File

@ -24,9 +24,9 @@ import javax.swing.border.EmptyBorder;
class AdjustedJMenu extends JMenu {
// only necessary in linux
private final SwingSystemTrayLinuxMenuPopup mainPopup;
private final SwingSystemTrayMenuPopup mainPopup;
AdjustedJMenu(final SwingSystemTrayLinuxMenuPopup mainPopup) {
AdjustedJMenu(final SwingSystemTrayMenuPopup mainPopup) {
this.mainPopup = mainPopup;
}

View File

@ -59,20 +59,20 @@ class SwingMenu extends Menu implements MenuEntry {
public
void run() {
if (parent != null) {
if (OS.isLinux()) {
_native = new AdjustedJMenu((SwingSystemTrayLinuxMenuPopup)((SwingMenu) systemTray.getMenu())._native);
if (OS.isWindows()) {
_native = new AdjustedJMenu(null);
}
else {
_native = new AdjustedJMenu(null);
_native = new AdjustedJMenu((SwingSystemTrayMenuPopup)((SwingMenu) systemTray.getMenu())._native);
}
((SwingMenu) parent)._native.add(_native);
} else {
// when we are the system tray
if (OS.isLinux()) {
_native = new SwingSystemTrayLinuxMenuPopup();
} else {
if (OS.isWindows()) {
_native = new SwingSystemTrayMenuWindowsPopup();
} else {
_native = new SwingSystemTrayMenuPopup();
}
}
}
@ -324,8 +324,8 @@ class SwingMenu extends Menu implements MenuEntry {
if (_native instanceof SwingSystemTrayMenuWindowsPopup) {
((SwingSystemTrayMenuWindowsPopup) _native).close();
}
else if (_native instanceof SwingSystemTrayLinuxMenuPopup) {
((SwingSystemTrayLinuxMenuPopup) _native).close();
else if (_native instanceof SwingSystemTrayMenuPopup) {
((SwingSystemTrayMenuPopup) _native).close();
}
SwingMenu parent = (SwingMenu) getParent();

View File

@ -54,7 +54,7 @@ class SwingSystemTray extends SwingMenu {
SwingSystemTray(final dorkbox.systemTray.SystemTray systemTray) {
super(systemTray, null);
ImageUtils.determineIconSize(dorkbox.systemTray.SystemTray.TYPE_SWING);
ImageUtils.determineIconSize();
dispatchAndWait(new Runnable() {
@Override

View File

@ -35,7 +35,7 @@ import dorkbox.util.SwingUtil;
* work, so we must implement an "auto-hide" feature that checks if our mouse is still inside a menu every POPUP_HIDE_DELAY seconds
*/
public
class SwingSystemTrayLinuxMenuPopup extends JPopupMenu {
class SwingSystemTrayMenuPopup extends JPopupMenu {
private static final long serialVersionUID = 1L;
@Property
@ -56,7 +56,7 @@ class SwingSystemTrayLinuxMenuPopup extends JPopupMenu {
// NOTE: we can use the "hidden dialog" focus window trick... only on windows and mac
// private JDialog hiddenDialog;
SwingSystemTrayLinuxMenuPopup() {
SwingSystemTrayMenuPopup() {
super();
setFocusable(true);
// setBorder(new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0)); // borderUI resource border type will get changed!
@ -89,7 +89,7 @@ class SwingSystemTrayLinuxMenuPopup extends JPopupMenu {
) {
// restart the timer
SwingSystemTrayLinuxMenuPopup.this.timer.delay(POPUP_HIDE_DELAY);
SwingSystemTrayMenuPopup.this.timer.delay(POPUP_HIDE_DELAY);
return;
}
}
@ -103,7 +103,7 @@ class SwingSystemTrayLinuxMenuPopup extends JPopupMenu {
) {
// restart the timer
SwingSystemTrayLinuxMenuPopup.this.timer.delay(POPUP_HIDE_DELAY);
SwingSystemTrayMenuPopup.this.timer.delay(POPUP_HIDE_DELAY);
return;
}
@ -119,7 +119,7 @@ class SwingSystemTrayLinuxMenuPopup extends JPopupMenu {
public
void mouseExited(MouseEvent event) {
// wait before checking if mouse is still on the menu
SwingSystemTrayLinuxMenuPopup.this.timer.delay(SwingSystemTrayLinuxMenuPopup.this.timer.getDelay());
SwingSystemTrayMenuPopup.this.timer.delay(SwingSystemTrayMenuPopup.this.timer.getDelay());
}
});
}
@ -154,7 +154,7 @@ class SwingSystemTrayLinuxMenuPopup extends JPopupMenu {
}
// restart the timer
SwingSystemTrayLinuxMenuPopup.this.timer.delay(POPUP_HIDE_DELAY);
SwingSystemTrayMenuPopup.this.timer.delay(POPUP_HIDE_DELAY);
}
public

View File

@ -51,14 +51,8 @@ class ImageUtils {
public static volatile int TRAY_SIZE = 0;
public static volatile int ENTRY_SIZE = 0;
/**
* @param trayType
* LINUX_GTK = 1;
* LINUX_APP_INDICATOR = 2;
* SWING_INDICATOR = 3;
*/
public static
void determineIconSize(int trayType) {
void determineIconSize() {
int scalingFactor = 0;
if (SystemTray.AUTO_TRAY_SIZE) {
@ -142,7 +136,7 @@ class ImageUtils {
if (SystemTray.DEBUG) {
SystemTray.logger.error("Windows version (partial): '{}'", windowsVersion);
}
} else {
} else if (OS.isLinux()) {
// GtkStatusIcon will USUALLY automatically scale the icon
// AppIndicator MIGHT scale the icon (depends on the OS)
try {
@ -187,6 +181,10 @@ class ImageUtils {
SystemTray.logger.error("Cannot check scaling factor", e);
}
}
} else if (OS.isMacOsX()) {
// don't know how exactly to determine this, but we are going to assume HiDPI for this...
// the OS should go up/down as needed.
scalingFactor = 8;
}
}