Code polish and fixes for Swing on linux
This commit is contained in:
parent
41b2138815
commit
f73df51a78
|
@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import dorkbox.systemTray.jna.linux.AppIndicator;
|
import dorkbox.systemTray.jna.linux.AppIndicator;
|
||||||
import dorkbox.systemTray.jna.linux.Gtk;
|
import dorkbox.systemTray.jna.linux.Gtk;
|
||||||
|
import dorkbox.systemTray.jna.linux.GtkEventDispatch;
|
||||||
import dorkbox.systemTray.nativeUI._AppIndicatorNativeTray;
|
import dorkbox.systemTray.nativeUI._AppIndicatorNativeTray;
|
||||||
import dorkbox.systemTray.nativeUI._AwtTray;
|
import dorkbox.systemTray.nativeUI._AwtTray;
|
||||||
import dorkbox.systemTray.nativeUI._GtkStatusIconNativeTray;
|
import dorkbox.systemTray.nativeUI._GtkStatusIconNativeTray;
|
||||||
|
@ -739,8 +740,8 @@ class SystemTray {
|
||||||
|
|
||||||
if (isNix) {
|
if (isNix) {
|
||||||
// linux/unix need access to GTK, so load it up before the tray is loaded!
|
// linux/unix need access to GTK, so load it up before the tray is loaded!
|
||||||
Gtk.startGui();
|
GtkEventDispatch.startGui();
|
||||||
Gtk.waitForEventsToComplete();
|
GtkEventDispatch.waitForEventsToComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -753,15 +754,15 @@ class SystemTray {
|
||||||
|
|
||||||
if (AUTO_FIX_INCONSISTENCIES) {
|
if (AUTO_FIX_INCONSISTENCIES) {
|
||||||
// this logic has to be before we create the system Tray, but after GTK is started (if applicable)
|
// this logic has to be before we create the system Tray, but after GTK is started (if applicable)
|
||||||
if (OS.isWindows()) {
|
if (OS.isWindows() && (isTrayType(trayType, TrayType.AWT) || isTrayType(trayType, TrayType.Swing))) {
|
||||||
// windows hard-codes the image size
|
// windows hard-codes the image size
|
||||||
SystemTrayFixes.fixWindows(trayImageSize);
|
SystemTrayFixes.fixWindows(trayImageSize);
|
||||||
}
|
}
|
||||||
else if (OS.isMacOsX()) {
|
else if (OS.isMacOsX() && (isTrayType(trayType, TrayType.AWT) || isTrayType(trayType, TrayType.Swing))) {
|
||||||
// macosx doesn't respond to all buttons (but should)
|
// macosx doesn't respond to all buttons (but should)
|
||||||
SystemTrayFixes.fixMacOS();
|
SystemTrayFixes.fixMacOS();
|
||||||
}
|
}
|
||||||
else if (isNix) {
|
else if (isNix && isTrayType(trayType, TrayType.Swing)) {
|
||||||
// linux/mac doesn't have transparent backgrounds for swing and hard-codes the image size
|
// linux/mac doesn't have transparent backgrounds for swing and hard-codes the image size
|
||||||
SystemTrayFixes.fixLinux(trayImageSize);
|
SystemTrayFixes.fixLinux(trayImageSize);
|
||||||
}
|
}
|
||||||
|
@ -790,7 +791,6 @@ class SystemTray {
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
reference.set((Tray) trayType.getConstructors()[0].newInstance(systemTray));
|
reference.set((Tray) trayType.getConstructors()[0].newInstance(systemTray));
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Unable to create tray type: '" + trayType.getSimpleName() + "'", e);
|
logger.error("Unable to create tray type: '" + trayType.getSimpleName() + "'", e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user