Fix for UbuntuGnome (which has AppIndicators + gnome-shell). Code polish
This commit is contained in:
parent
48cde07ff5
commit
2e55b34ec8
@ -756,7 +756,7 @@ class SystemTray {
|
|||||||
if (isJavaFxLoaded) {
|
if (isJavaFxLoaded) {
|
||||||
if (isTrayType(trayType, TrayType.GtkStatusIcon)) {
|
if (isTrayType(trayType, TrayType.GtkStatusIcon)) {
|
||||||
// set a property so that GTK (if necessary) can set the name of the system tray icon
|
// set a property so that GTK (if necessary) can set the name of the system tray icon
|
||||||
System.setProperty("SystemTray_GTK_SET_NAME", "true");
|
System.setProperty("SystemTray_SET_NAME", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will initialize javaFX dispatch methods
|
// This will initialize javaFX dispatch methods
|
||||||
|
@ -237,7 +237,7 @@ class Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set a property so that GTK (if necessary) can set the name
|
// set a property so that GTK (if necessary) can set the name
|
||||||
System.setProperty("SystemTray_GTK_SET_NAME", "true");
|
System.setProperty("SystemTray_SET_NAME", "true");
|
||||||
|
|
||||||
// have to copy the extension over and enable it.
|
// have to copy the extension over and enable it.
|
||||||
String userHome = System.getProperty("user.home");
|
String userHome = System.getProperty("user.home");
|
||||||
|
@ -239,6 +239,7 @@ class AppIndicator {
|
|||||||
|
|
||||||
public static native AppIndicatorInstanceStruct app_indicator_new(String id, String icon_name, int category);
|
public static native AppIndicatorInstanceStruct app_indicator_new(String id, String icon_name, int category);
|
||||||
|
|
||||||
|
public static native void app_indicator_set_title(AppIndicatorInstanceStruct self, String title);
|
||||||
public static native void app_indicator_set_status(AppIndicatorInstanceStruct self, int status);
|
public static native void app_indicator_set_status(AppIndicatorInstanceStruct self, int status);
|
||||||
public static native void app_indicator_set_menu(AppIndicatorInstanceStruct self, Pointer menu);
|
public static native void app_indicator_set_menu(AppIndicatorInstanceStruct self, Pointer menu);
|
||||||
public static native void app_indicator_set_icon(AppIndicatorInstanceStruct self, String icon_name);
|
public static native void app_indicator_set_icon(AppIndicatorInstanceStruct self, String icon_name);
|
||||||
|
@ -246,6 +246,13 @@ class Gtk {
|
|||||||
if (SystemTray.isJavaFxLoaded) {
|
if (SystemTray.isJavaFxLoaded) {
|
||||||
if (!JavaFX.isEventThread()) {
|
if (!JavaFX.isEventThread()) {
|
||||||
try {
|
try {
|
||||||
|
if (!blockUntilStarted.await(10, TimeUnit.SECONDS)) {
|
||||||
|
if (SystemTray.DEBUG) {
|
||||||
|
SystemTray.logger.error("Something is very wrong. The waitForStartup took longer than expected.",
|
||||||
|
new Exception(""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// we have to WAIT until all events are done processing, OTHERWISE we have initialization issues
|
// we have to WAIT until all events are done processing, OTHERWISE we have initialization issues
|
||||||
while (true) {
|
while (true) {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
@ -256,13 +263,6 @@ class Gtk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!blockUntilStarted.await(10, TimeUnit.SECONDS)) {
|
|
||||||
if (SystemTray.DEBUG) {
|
|
||||||
SystemTray.logger.error("Something is very wrong. The waitForStartup took longer than expected.",
|
|
||||||
new Exception(""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -271,6 +271,13 @@ class Gtk {
|
|||||||
if (!Swt.isEventThread()) {
|
if (!Swt.isEventThread()) {
|
||||||
// we have to WAIT until all events are done processing, OTHERWISE we have initialization issues
|
// we have to WAIT until all events are done processing, OTHERWISE we have initialization issues
|
||||||
try {
|
try {
|
||||||
|
if (!blockUntilStarted.await(10, TimeUnit.SECONDS)) {
|
||||||
|
if (SystemTray.DEBUG) {
|
||||||
|
SystemTray.logger.error("Something is very wrong. The waitForStartup took longer than expected.",
|
||||||
|
new Exception(""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
|
||||||
@ -280,19 +287,19 @@ class Gtk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!blockUntilStarted.await(10, TimeUnit.SECONDS)) {
|
|
||||||
if (SystemTray.DEBUG) {
|
|
||||||
SystemTray.logger.error("Something is very wrong. The waitForStartup took longer than expected.",
|
|
||||||
new Exception(""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
if (!blockUntilStarted.await(10, TimeUnit.SECONDS)) {
|
||||||
|
if (SystemTray.DEBUG) {
|
||||||
|
SystemTray.logger.error("Something is very wrong. The waitForStartup took longer than expected.",
|
||||||
|
new Exception(""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// we have to WAIT until all events are done processing, OTHERWISE we have initialization issues
|
// we have to WAIT until all events are done processing, OTHERWISE we have initialization issues
|
||||||
while (true) {
|
while (true) {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
@ -303,13 +310,6 @@ class Gtk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!blockUntilStarted.await(10, TimeUnit.SECONDS)) {
|
|
||||||
if (SystemTray.DEBUG) {
|
|
||||||
SystemTray.logger.error("Something is very wrong. The waitForStartup took longer than expected.",
|
|
||||||
new Exception(""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -209,6 +209,29 @@ class _AppIndicatorNativeTray extends Tray implements NativeUI {
|
|||||||
|
|
||||||
Gtk.waitForStartup();
|
Gtk.waitForStartup();
|
||||||
|
|
||||||
|
|
||||||
|
if (System.getProperty("SystemTray_SET_NAME", "false").equals("true")) {
|
||||||
|
Gtk.dispatch(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public
|
||||||
|
void run() {
|
||||||
|
// by default, the title/name of the tray icon is "java". We are the only java-based tray icon, so we just use that.
|
||||||
|
// If you change "SystemTray" to something else, make sure to change it in extension.js as well
|
||||||
|
|
||||||
|
// default is to show the indicator
|
||||||
|
AppIndicator.app_indicator_set_status(appIndicator, AppIndicator.STATUS_ACTIVE);
|
||||||
|
|
||||||
|
// can cause
|
||||||
|
// GLib-GIO-CRITICAL **: g_dbus_connection_emit_signal: assertion 'object_path != NULL && g_variant_is_object_path (object_path)' failed
|
||||||
|
// Gdk-CRITICAL **: IA__gdk_window_thaw_toplevel_updates_libgtk_only: assertion 'private->update_and_descendants_freeze_count > 0' failed
|
||||||
|
|
||||||
|
// necessary for gnome icon detection/placement because we move tray icons around by title. This is hardcoded
|
||||||
|
// in extension.js, so don't change it
|
||||||
|
AppIndicator.app_indicator_set_title(appIndicator, "SystemTray");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bind(gtkMenu, null, systemTray);
|
bind(gtkMenu, null, systemTray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ class _GtkStatusIconNativeTray extends Tray implements NativeUI {
|
|||||||
// BUT this is REQUIRED when running JavaFX or Gnome For unknown reasons, the title isn't pushed to GTK, so our
|
// BUT this is REQUIRED when running JavaFX or Gnome For unknown reasons, the title isn't pushed to GTK, so our
|
||||||
// gnome-shell extension cannot see our tray icon -- so naturally, it won't move it to the "top" area and
|
// gnome-shell extension cannot see our tray icon -- so naturally, it won't move it to the "top" area and
|
||||||
// we appear broken.
|
// we appear broken.
|
||||||
if (System.getProperty("SystemTray_GTK_SET_NAME", "false").equals("true")) {
|
if (System.getProperty("SystemTray_SET_NAME", "false").equals("true")) {
|
||||||
Gtk.gtk_status_icon_set_name(trayIcon, "SystemTray");
|
Gtk.gtk_status_icon_set_name(trayIcon, "SystemTray");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,6 +272,30 @@ class _AppIndicatorTray extends Tray implements SwingUI {
|
|||||||
bind(swingMenu, null, systemTray);
|
bind(swingMenu, null, systemTray);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (System.getProperty("SystemTray_SET_NAME", "false").equals("true")) {
|
||||||
|
Gtk.dispatch(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public
|
||||||
|
void run() {
|
||||||
|
// by default, the title/name of the tray icon is "java". We are the only java-based tray icon, so we just use that.
|
||||||
|
// If you change "SystemTray" to something else, make sure to change it in extension.js as well
|
||||||
|
|
||||||
|
// default is to show the indicator
|
||||||
|
AppIndicator.app_indicator_set_status(appIndicator, AppIndicator.STATUS_ACTIVE);
|
||||||
|
|
||||||
|
|
||||||
|
// can cause
|
||||||
|
// GLib-GIO-CRITICAL **: g_dbus_connection_emit_signal: assertion 'object_path != NULL && g_variant_is_object_path (object_path)' failed
|
||||||
|
// Gdk-CRITICAL **: IA__gdk_window_thaw_toplevel_updates_libgtk_only: assertion 'private->update_and_descendants_freeze_count > 0' failed
|
||||||
|
|
||||||
|
// necessary for gnome icon detection/placement because we move tray icons around by title. This is hardcoded
|
||||||
|
// in extension.js, so don't change it
|
||||||
|
AppIndicator.app_indicator_set_title(appIndicator, "SystemTray");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -118,7 +118,7 @@ class _GtkStatusIconTray extends Tray implements SwingUI {
|
|||||||
// BUT this is REQUIRED when running JavaFX or Gnome For unknown reasons, the title isn't pushed to GTK, so our
|
// BUT this is REQUIRED when running JavaFX or Gnome For unknown reasons, the title isn't pushed to GTK, so our
|
||||||
// gnome-shell extension cannot see our tray icon -- so naturally, it won't move it to the "top" area and
|
// gnome-shell extension cannot see our tray icon -- so naturally, it won't move it to the "top" area and
|
||||||
// we appear broken.
|
// we appear broken.
|
||||||
if (System.getProperty("SystemTray_GTK_SET_NAME", "false").equals("true")) {
|
if (System.getProperty("SystemTray_SET_NAME", "false").equals("true")) {
|
||||||
Gtk.gtk_status_icon_set_name(trayIcon, "SystemTray");
|
Gtk.gtk_status_icon_set_name(trayIcon, "SystemTray");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user