From 4ef73a0c071cfa85b662a041ced852863c83fa70 Mon Sep 17 00:00:00 2001 From: metaprime Date: Thu, 12 Oct 2017 01:59:31 -0700 Subject: [PATCH] Do not manually position window on Windows to work around javaw.exe not closing. (Closes 4pr0n/ripme#412, Closes RipMeApp/ripme#70) --- .../java/com/rarchives/ripme/ui/MainWindow.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/rarchives/ripme/ui/MainWindow.java b/src/main/java/com/rarchives/ripme/ui/MainWindow.java index 71a93276..8b54e180 100644 --- a/src/main/java/com/rarchives/ripme/ui/MainWindow.java +++ b/src/main/java/com/rarchives/ripme/ui/MainWindow.java @@ -1333,11 +1333,26 @@ public final class MainWindow implements Runnable, RipStatusHandler { logger.debug("Saved window position (x=" + x + ", y=" + y + ", w=" + w + ", h=" + h + ")"); } + public static boolean hasWindowPositionBug() { + String osName = System.getProperty("os.name"); + if (osName != null) { + // Java on Windows has a bug where if we try to manually set the position of the Window, + // javaw.exe will not close itself down when the application is closed. + // Therefore, even if isWindowPositioningEnabled, if we are on Windows, we ignore it. + return osName.startsWith("Windows"); + } else { + // If we're unsure, since we know there might be a bug, + // better be safe and report that the bug exists. + return true; + } + } + public static void restoreWindowPosition(Frame frame) { - if (!isWindowPositioningEnabled()) { + if (!isWindowPositioningEnabled() || hasWindowPositionBug()) { mainFrame.setLocationRelativeTo(null); // default to middle of screen return; } + try { int x = Utils.getConfigInteger("window.x", -1); int y = Utils.getConfigInteger("window.y", -1);