diff --git a/src/dorkbox/systemTray/SystemTray.java b/src/dorkbox/systemTray/SystemTray.java index 73ea99a..83a9c8b 100644 --- a/src/dorkbox/systemTray/SystemTray.java +++ b/src/dorkbox/systemTray/SystemTray.java @@ -45,7 +45,6 @@ import dorkbox.systemTray.nativeUI.NativeUI; import dorkbox.systemTray.nativeUI._AppIndicatorNativeTray; import dorkbox.systemTray.nativeUI._AwtTray; import dorkbox.systemTray.nativeUI._GtkStatusIconNativeTray; -import dorkbox.systemTray.swingUI.SwingUI; import dorkbox.systemTray.swingUI._SwingTray; import dorkbox.systemTray.util.ImageUtils; import dorkbox.systemTray.util.JavaFX; @@ -401,7 +400,7 @@ class SystemTray { logger.error("You might need to grant the AWTPermission `accessSystemTray` to the SecurityManager."); } } - else if ((OS.isLinux() || OS.isUnix()) && FORCE_TRAY_TYPE != TrayType.Swing) { + else if ((OS.isLinux() || OS.isUnix())) { // see: https://askubuntu.com/questions/72549/how-to-determine-which-window-manager-is-running // For funsies, SyncThing did a LOT of work on compatibility (unfortunate for us) in python. @@ -413,6 +412,19 @@ class SystemTray { trayType = selectTypeQuietly(SystemTray.FORCE_TRAY_TYPE); } + if (SystemTray.FORCE_TRAY_TYPE == TrayType.Swing && isSwtLoaded) { + if (AUTO_FIX_INCONSISTENCIES) { + logger.warn("Forcing AWT because SWT cannot load Swing type."); + trayType = selectTypeQuietly(TrayType.AWT); + } else { + logger.error("Cannot initialize Swing type if SWT is loaded."); + + systemTrayMenu = null; + systemTray = null; + return; + } + } + // quick check, because we know that unity uses app-indicator. Maybe REALLY old versions do not. We support 14.04 LTE at least @@ -789,21 +801,6 @@ class SystemTray { systemTrayMenu = reference.get(); - - // verify that we have what we are expecting. - if (OS.isWindows() && systemTrayMenu instanceof SwingUI) { - // this configuration is OK. - } else if (systemTrayMenu instanceof NativeUI) { - // this configuration is OK. - } else { - logger.error("Unable to correctly initialize the System Tray. Please write an issue and include your " + - "OS type and configuration"); - systemTrayMenu = null; - systemTray = null; - return; - } - - // These install a shutdown hook in JavaFX/SWT, so that when the main window is closed -- the system tray is ALSO closed. if (ENABLE_SHUTDOWN_HOOK) { if (isJavaFxLoaded) { diff --git a/src/dorkbox/systemTray/jna/linux/Gtk.java b/src/dorkbox/systemTray/jna/linux/Gtk.java index 22d17f8..0ab1edc 100644 --- a/src/dorkbox/systemTray/jna/linux/Gtk.java +++ b/src/dorkbox/systemTray/jna/linux/Gtk.java @@ -96,9 +96,10 @@ class Gtk { } // we can force the system to use the swing indicator, which WORKS, but doesn't support transparency in the icon. - if (!_isLoaded && SystemTray.FORCE_TRAY_TYPE == SystemTray.TrayType.Swing) { + if (!_isLoaded && + (SystemTray.FORCE_TRAY_TYPE == SystemTray.TrayType.Swing || SystemTray.FORCE_TRAY_TYPE == SystemTray.TrayType.AWT)) { if (SystemTray.DEBUG) { - logger.debug("Forcing Swing tray, not using GTK"); + logger.debug("Not loading GTK for Swing or AWT"); } _isLoaded = true; }