From: Ben Soares Date: Fri, 15 May 2020 20:04:39 +0000 (+0100) Subject: JAL-3609 HiDPI scale setting done via system prop in getdown or halview.bin.Launcher X-Git-Tag: Develop-2_11_2_0-d20201215~24^2~10 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=1e26a902b2a53081ab6035d43c2bdf13f1a7ee4e;p=jalview.git JAL-3609 HiDPI scale setting done via system prop in getdown or halview.bin.Launcher --- diff --git a/getdown/lib/FJVL_VERSION b/getdown/lib/FJVL_VERSION index e7a1de7..afcaa01 100644 --- a/getdown/lib/FJVL_VERSION +++ b/getdown/lib/FJVL_VERSION @@ -1 +1 @@ -1.8.3-1.2.4_FJVL +1.8.3-1.2.5_FJVL diff --git a/getdown/lib/JVL_VERSION b/getdown/lib/JVL_VERSION index 756f4bd..61aa33c 100644 --- a/getdown/lib/JVL_VERSION +++ b/getdown/lib/JVL_VERSION @@ -1 +1 @@ -1.8.3-1.2.4_JVL +1.8.3-1.2.5_JVL diff --git a/getdown/lib/getdown-core.jar b/getdown/lib/getdown-core.jar index 9c0f96e..b7239d9 100644 Binary files a/getdown/lib/getdown-core.jar and b/getdown/lib/getdown-core.jar differ diff --git a/getdown/lib/getdown-launcher-local.jar b/getdown/lib/getdown-launcher-local.jar index cfa96f3..3c3c602 100644 Binary files a/getdown/lib/getdown-launcher-local.jar and b/getdown/lib/getdown-launcher-local.jar differ diff --git a/getdown/lib/getdown-launcher.jar b/getdown/lib/getdown-launcher.jar index 2f8baa7..836e745 100644 Binary files a/getdown/lib/getdown-launcher.jar and b/getdown/lib/getdown-launcher.jar differ diff --git a/getdown/src/getdown/ant/pom.xml b/getdown/src/getdown/ant/pom.xml index 8dcef42..9af441d 100644 --- a/getdown/src/getdown/ant/pom.xml +++ b/getdown/src/getdown/ant/pom.xml @@ -4,7 +4,7 @@ com.threerings.getdown getdown - 1.8.3-1.2.4_FJVL + 1.8.3-1.2.5_FJVL getdown-ant diff --git a/getdown/src/getdown/core/pom.xml b/getdown/src/getdown/core/pom.xml index 2d0e89a..1563c23 100644 --- a/getdown/src/getdown/core/pom.xml +++ b/getdown/src/getdown/core/pom.xml @@ -4,7 +4,7 @@ com.threerings.getdown getdown - 1.8.3-1.2.4_FJVL + 1.8.3-1.2.5_FJVL getdown-core diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java index fd53c79..b11a380 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java @@ -27,6 +27,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; +import jalview.bin.HiDPISetting; import jalview.bin.MemorySetting; //import com.install4j.api.launcher.Variables; @@ -1071,6 +1072,13 @@ public class Application args.add("-Dinstaller_template_version=" + System.getProperty("installer_template_version")); args.add("-Dlauncher_version=" + Build.version()); + // set HiDPI property if wanted + String scalePropertyArg = HiDPISetting.getScalePropertyArg(); + if (scalePropertyArg != null) + { + args.add(scalePropertyArg); + } + // set the native library path if we have native resources // @TODO optional getdown.txt parameter to set addCurrentLibraryPath to true or false? ClassPath javaLibPath = PathBuilder.buildLibsPath(this, true); diff --git a/getdown/src/getdown/core/src/main/java/jalview/bin/HiDPISetting.java b/getdown/src/getdown/core/src/main/java/jalview/bin/HiDPISetting.java new file mode 100644 index 0000000..5e20d76 --- /dev/null +++ b/getdown/src/getdown/core/src/main/java/jalview/bin/HiDPISetting.java @@ -0,0 +1,48 @@ +package jalview.bin; + +import java.awt.Toolkit; + +public class HiDPISetting +{ + public static final int dpi; + + public static final int scale; + + private static final int hidpi = 110; + + private static final String scaleProperty = "sun.java2d.uiScale"; + + private static final boolean isAMac = System.getProperty("os.name") + .indexOf("Mac") > -1; + + private static final boolean isLinux = System.getProperty("os.name") + .toLowerCase().indexOf("linux") > -1; + + private static final boolean isWindows = System.getProperty("os.name") + .toLowerCase().indexOf("windows") > -1; + + static + { + dpi = Toolkit.getDefaultToolkit().getScreenResolution(); + scale = dpi / hidpi + 1; + if (scale > 1 && isLinux) + { + System.out.println("DPI detected as " + dpi + + ". Scaling factor set to " + scale + "."); + } + } + + public static String getScalePropertyArg() + { + // HiDPI setting. Just looking at Linux to start with. Test with Windows. + if (!isLinux) + { + return null; + } + if (scale > 1) + { + return "-D" + scaleProperty + "=" + scale; + } + return null; + } +} diff --git a/getdown/src/getdown/launcher/pom.xml b/getdown/src/getdown/launcher/pom.xml index ad87541..e8eb824 100644 --- a/getdown/src/getdown/launcher/pom.xml +++ b/getdown/src/getdown/launcher/pom.xml @@ -4,7 +4,7 @@ com.threerings.getdown getdown - 1.8.3-1.2.4_FJVL + 1.8.3-1.2.5_FJVL getdown-launcher diff --git a/getdown/src/getdown/mvn_cmd b/getdown/src/getdown/mvn_cmd index 3f9b4a2..d10f7a8 100755 --- a/getdown/src/getdown/mvn_cmd +++ b/getdown/src/getdown/mvn_cmd @@ -3,7 +3,7 @@ if [ x$JVLVERSION != x ]; then export VERSION=$JVLVERSION else - export VERSION=1.8.3-1.2.4_JVL + export VERSION=1.8.3-1.2.5_JVL fi if [ x${VERSION%_JVL} = x$VERSION ]; then diff --git a/getdown/src/getdown/pom.xml b/getdown/src/getdown/pom.xml index 2ca4aa1..1109505 100644 --- a/getdown/src/getdown/pom.xml +++ b/getdown/src/getdown/pom.xml @@ -10,7 +10,7 @@ com.threerings.getdown getdown pom - 1.8.3-1.2.4_FJVL + 1.8.3-1.2.5_FJVL getdown An application installer and updater. diff --git a/j11lib/getdown-core.jar b/j11lib/getdown-core.jar index 9c0f96e..b7239d9 100644 Binary files a/j11lib/getdown-core.jar and b/j11lib/getdown-core.jar differ diff --git a/j8lib/getdown-core.jar b/j8lib/getdown-core.jar index 9c0f96e..b7239d9 100644 Binary files a/j8lib/getdown-core.jar and b/j8lib/getdown-core.jar differ diff --git a/src/jalview/bin/HiDPISetting.java b/src/jalview/bin/HiDPISetting.java new file mode 100644 index 0000000..5e20d76 --- /dev/null +++ b/src/jalview/bin/HiDPISetting.java @@ -0,0 +1,48 @@ +package jalview.bin; + +import java.awt.Toolkit; + +public class HiDPISetting +{ + public static final int dpi; + + public static final int scale; + + private static final int hidpi = 110; + + private static final String scaleProperty = "sun.java2d.uiScale"; + + private static final boolean isAMac = System.getProperty("os.name") + .indexOf("Mac") > -1; + + private static final boolean isLinux = System.getProperty("os.name") + .toLowerCase().indexOf("linux") > -1; + + private static final boolean isWindows = System.getProperty("os.name") + .toLowerCase().indexOf("windows") > -1; + + static + { + dpi = Toolkit.getDefaultToolkit().getScreenResolution(); + scale = dpi / hidpi + 1; + if (scale > 1 && isLinux) + { + System.out.println("DPI detected as " + dpi + + ". Scaling factor set to " + scale + "."); + } + } + + public static String getScalePropertyArg() + { + // HiDPI setting. Just looking at Linux to start with. Test with Windows. + if (!isLinux) + { + return null; + } + if (scale > 1) + { + return "-D" + scaleProperty + "=" + scale; + } + return null; + } +} diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index f5b7009..e130277 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -465,6 +465,7 @@ public class Jalview if (!headless) { + desktop = new Desktop(); desktop.setInBatchMode(true); // indicate we are starting up diff --git a/src/jalview/bin/Launcher.java b/src/jalview/bin/Launcher.java index fb1c5cd..5e6e48c 100644 --- a/src/jalview/bin/Launcher.java +++ b/src/jalview/bin/Launcher.java @@ -49,8 +49,8 @@ public class Launcher /** * main method for jalview.bin.Launcher. This restarts the same JRE's JVM with - * the same arguments but with memory adjusted based on extracted -jvmmempc and - * -jvmmemmax application arguments. If on a Mac then extra dock:icon and + * the same arguments but with memory adjusted based on extracted -jvmmempc + * and -jvmmemmax application arguments. If on a Mac then extra dock:icon and * dock:name arguments are also set. * * @param args @@ -130,7 +130,7 @@ public class Launcher if (!memSet) { long maxMemLong = MemorySetting.getMemorySetting(jvmmemmax, jvmmempc); - + if (maxMemLong > 0) { memSetting = "-Xmx" + Long.toString(maxMemLong); @@ -153,6 +153,12 @@ public class Launcher } } + String scalePropertyArg = HiDPISetting.getScalePropertyArg(); + if (scalePropertyArg != null) + { + command.add(scalePropertyArg); + } + command.add(startClass); command.addAll(arguments); @@ -176,7 +182,8 @@ public class Launcher if (e.getMessage().toLowerCase().contains("memory")) { System.out.println("Caught a memory exception: " + e.getMessage()); - // Probably the "Cannot allocate memory" error, try without the memory setting + // Probably the "Cannot allocate memory" error, try without the memory + // setting ArrayList commandNoMem = new ArrayList<>(); for (int i = 0; i < command.size(); i++) {