From fae290caa38aedbea3a2d093419e5ade4e62d620 Mon Sep 17 00:00:00 2001 From: "Bartosz J. Kaczkowski" Date: Sat, 7 Oct 2017 15:47:05 +0200 Subject: [PATCH 1/2] Terminate JavaFX thread when running with "nogui" option (#3274) * Terminate JavaFX thread when running with "nogui" option * Add entry to the changelog --- CHANGELOG.md | 3 ++- src/main/java/org/jabref/JabRefMain.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00dc869ff73..bdc02215b0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ### Fixed - We fixed an issue where JabRef would not terminated after asking to collect anonymous statistics [#2955 comment](https://github.com/JabRef/jabref/issues/2955#issuecomment-334591123) + - We fixed an issue where JabRef would not shut down when started with the '-n' (No GUI) option. ### Removed @@ -82,7 +83,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We added drag and drop support for adding files directly in the `General`-Tab. The dragged files are currently only linked from their existing directory. For more advanced features use the `Add files` dialog. [#koppor#244](https://github.com/koppor/jabref/issues/244) - We added the file description filed back to the list of files in the `General`-Tab [#2930, comment](https://github.com/JabRef/jabref/issues/2930#issuecomment-328328172) - Added an error dialog if the file is open in another process and cannot be renamed. [#3229] -- On Windows, the `JabRef.exe` executable can now be used to start JabRef from the command line. By default, no output is shown unless the new "-console" option is specified. +- On Windows, the `JabRef.exe` executable can now be used to start JabRef from the command line. By default, no output is shown unless the new "-console" option is specified. ### Fixed diff --git a/src/main/java/org/jabref/JabRefMain.java b/src/main/java/org/jabref/JabRefMain.java index b278ecd94a8..e57f22c69b6 100644 --- a/src/main/java/org/jabref/JabRefMain.java +++ b/src/main/java/org/jabref/JabRefMain.java @@ -138,6 +138,7 @@ private static void start(String[] args) { // See if we should shut down now if (argumentProcessor.shouldShutDown()) { Globals.shutdownThreadPools(); + Platform.exit(); return; } From 1b030b45910b96c1dc4d37f4278cffa6e2b7e006 Mon Sep 17 00:00:00 2001 From: Michael Lass Date: Mon, 9 Oct 2017 02:52:40 +0200 Subject: [PATCH 2/2] Set WM_CLASS to org-jabref-JabRefMain (#3273) WM_CLASS is used by certain Un*x window managers, such as GNOME, to map windows to the corresponding application. Currently WM_CLASS is set to java-lang-Thread which is very generic and not unique to JabRef. Instead, use reflection to set it to org-jabref-JabRefMain which resembles the main class name. --- CHANGELOG.md | 1 + src/main/java/org/jabref/gui/GUIGlobals.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdc02215b0b..6eab689c030 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - Updated French translation - We added support for pasting entries in different formats [#3143](https://github.com/JabRef/jabref/issues/3143) - Crossreferenced entries are now used when a BibTex key is generated for an entry with empty fields. [#2811](https://github.com/JabRef/jabref/issues/2811) +- We now set the WM_CLASS of the UI to org-jabref-JabRefMain to allow certain Un*x window managers to properly identify its windows ### Fixed - We fixed an issue where JabRef would not terminated after asking to collect anonymous statistics [#2955 comment](https://github.com/JabRef/jabref/issues/2955#issuecomment-334591123) diff --git a/src/main/java/org/jabref/gui/GUIGlobals.java b/src/main/java/org/jabref/gui/GUIGlobals.java index a7cd28c72a2..61e3d4364ec 100644 --- a/src/main/java/org/jabref/gui/GUIGlobals.java +++ b/src/main/java/org/jabref/gui/GUIGlobals.java @@ -2,6 +2,7 @@ import java.awt.Color; import java.awt.Font; +import java.awt.Toolkit; import java.util.HashMap; import java.util.Map; @@ -13,6 +14,7 @@ import org.jabref.gui.keyboard.EmacsKeyBindings; import org.jabref.gui.specialfields.SpecialFieldViewModel; import org.jabref.logic.l10n.Localization; +import org.jabref.logic.util.OS; import org.jabref.model.entry.FieldName; import org.jabref.model.entry.specialfields.SpecialField; import org.jabref.preferences.JabRefPreferences; @@ -156,6 +158,18 @@ public static void init() { GUIGlobals.currentFont = new Font(Globals.prefs.get(JabRefPreferences.FONT_FAMILY), Globals.prefs.getInt(JabRefPreferences.FONT_STYLE), Globals.prefs.getInt(JabRefPreferences.FONT_SIZE)); + // Set WM_CLASS using reflection for certain Un*x window managers + if (!OS.WINDOWS && !OS.OS_X) { + try { + Toolkit xToolkit = Toolkit.getDefaultToolkit(); + java.lang.reflect.Field awtAppClassNameField = xToolkit.getClass().getDeclaredField("awtAppClassName"); + awtAppClassNameField.setAccessible(true); + awtAppClassNameField.set(xToolkit, "org-jabref-JabRefMain"); + } catch (Exception e) { + // ignore any error since this code only works for certain toolkits + } + } + } public static void setFont(int size) {