From 48a28909e5a0ff9bdfef9779a9aac534521fd218 Mon Sep 17 00:00:00 2001 From: nathan Date: Sat, 3 Nov 2018 15:19:43 +0100 Subject: [PATCH] Cleaned up KDE plasma type detection. Fixed swing fallback for KDE --- src/dorkbox/systemTray/SystemTray.java | 37 +++++++++++++++++++------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/dorkbox/systemTray/SystemTray.java b/src/dorkbox/systemTray/SystemTray.java index baf8637..297cc08 100644 --- a/src/dorkbox/systemTray/SystemTray.java +++ b/src/dorkbox/systemTray/SystemTray.java @@ -379,16 +379,30 @@ class SystemTray { return selectTypeQuietly(TrayType.GtkStatusIcon); } case KDE: { - if (OSUtil.Linux.isFedora()) { - // Fedora KDE requires GtkStatusIcon - return selectTypeQuietly(TrayType.GtkStatusIcon); - } - else { - // kde (at least, plasma 5.5.6) requires appindicator - return selectTypeQuietly(TrayType.AppIndicator); + // kde 5.8+ is "high DPI", so we need to adjust the scale. Image resize will do that + + double plasmaVersion = DesktopEnv.getPlasmaVersion(); + + if (DEBUG) { + logger.debug("KDE Plasma Version: {}", plasmaVersion); } - // kde 5.8+ is "high DPI", so we need to adjust the scale. Image resize will do that + if (plasmaVersion == 0.0) { + // this shouldn't ever happen! + + logger.error("KDE Plasma detected, but UNDEFINED shell version. This should never happen. Falling back to GtkStatusIcon. " + + "Please create an issue with as many details as possible."); + + return selectTypeQuietly(TrayType.GtkStatusIcon); + } + + if (plasmaVersion <= 5.5) { + // older versions use GtkStatusIcon + return selectTypeQuietly(TrayType.GtkStatusIcon); + } else { + // newer versions use appindicator, but the user MIGHT have to install libappindicator + return selectTypeQuietly(TrayType.AppIndicator); + } } case Unity: { // Ubuntu Unity is a weird combination. It's "Gnome", but it's not "Gnome Shell". @@ -409,6 +423,9 @@ class SystemTray { case LXDE: { return selectTypeQuietly(TrayType.GtkStatusIcon); } + case MATE: { + return selectTypeQuietly(TrayType.GtkStatusIcon); + } case Pantheon: { // elementaryOS. It only supports appindicator (not gtkstatusicon) // http://bazaar.launchpad.net/~wingpanel-devs/wingpanel/trunk/view/head:/sample/SampleIndicator.vala @@ -932,8 +949,8 @@ class SystemTray { if (!AppIndicator.isLoaded) { // YIKES. AppIndicator couldn't load. - // can we fallback to swing? - if (AUTO_FIX_INCONSISTENCIES && java.awt.SystemTray.isSupported()) { + // can we fallback to swing? KDE does not work for this... + if (AUTO_FIX_INCONSISTENCIES && java.awt.SystemTray.isSupported() && !OSUtil.DesktopEnv.isKDE()) { trayType = selectTypeQuietly(TrayType.Swing); logger.warn("Unable to initialize the AppIndicator correctly. Using the Swing Tray type instead.");