A free, open-source alternative to Burp Suite: an intercepting proxy and web app security testing suite with Repeater, Intruder, Collaborator and a built-in OWASP ZAP scanner. Linux, AGPL-3.0.
Java application-securityappsecbug-bountyburp-alternativeburp-suitedasthttp-proxyinfosecintercepting-proxyjavaowaspowasp-zappenetration-testingpentestingsecuritysecurity-toolsvulnerability-scannerweb-application-securityweb-security
Scaling: no scale is guessed from the screen's size; one set by hand always wins
scottsturrockb694c9347c44
diff --git a/package-appimage.sh b/package-appimage.shindex 7eac8b5..9052c48 100755--- a/package-appimage.sh+++ b/package-appimage.sh@@ -105,9 +105,17 @@ if [ -z "${_JAVA_AWT_WM_NONREPARENTING+x}" ]; thenesacdonefi-SCALE="$("$HERE/usr/bin/OpenSuite" --print-scale 2>/dev/null | tr -d '[:space:]')"+# The scale is the one set by hand: OPENSUITE_SCALE, a sun.java2d.uiScale of+# the caller's own in JAVA_TOOL_OPTIONS, or the one chosen in Settings > User+# interface > Display > Scaling. With none of these nothing is set here, and+# the display's own setting applies.+case "${JAVA_TOOL_OPTIONS:-}" in+ *sun.java2d.uiScale*) SCALE="" ;;+ *) SCALE="${OPENSUITE_SCALE:-$("$HERE/usr/bin/OpenSuite" --print-scale 2>/dev/null | tr -d '[:space:]')}" ;;+esaccase "$SCALE" in- 1.25|1.5|2|2.0|3|3.0) export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS:+$JAVA_TOOL_OPTIONS }-Dsun.java2d.uiScale=$SCALE -Dopensuite.scaled=$SCALE" ;;+ ''|*[!0-9.]*) ;;+ *) export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS:+$JAVA_TOOL_OPTIONS }-Dsun.java2d.uiScale=$SCALE -Dopensuite.scaled=$SCALE" ;;esac# Settings > Suite > Performance > Maximum memory usage: a custom limit is left# in this file as a number of megabytes. Without it, half of system memory.diff --git a/run.sh b/run.shindex b815e14..8821b5b 100755--- a/run.sh+++ b/run.sh@@ -11,7 +11,7 @@# OPENSUITE_SCALE=1.5 ./run.sh (or an environment variable)## Set SCALE below if you want a fixed scale on every launch. Leaving it empty-# is recommended: it lets detection and your view menu choice work.+# is recommended: it lets your choice in the settings work.SCALE=""set -udiff --git a/src/opensuite/ui/Main.java b/src/opensuite/ui/Main.javaindex e8b7196..d0b86a2 100644--- a/src/opensuite/ui/Main.java+++ b/src/opensuite/ui/Main.java@@ -48,7 +48,8 @@ public class Main {// would tear down the AppImage mount and kill the app).for (String a : args) {if ("--print-scale".equals(a)) {- System.out.println(UiScale.desired());+ // Nothing when no scale was chosen, so the launcher sets none.+ System.out.println(UiScale.chosen() ? String.valueOf(UiScale.desired()) : "");return;}}@@ -81,7 +82,7 @@ public class Main {if (!UiScale.applied() && !opensuite.core.Os.MAC) {double want = UiScale.desired();Debug.log("scale not yet applied; desired=" + want);- if (Math.abs(want - 1.0) > 0.001) {+ if (UiScale.chosen()) {Debug.log("relaunching JVM with uiScale=" + want);if (UiScale.relaunchWith(want, args)) {Debug.log("relaunched child process; parent exiting");diff --git a/src/opensuite/ui/UiScale.java b/src/opensuite/ui/UiScale.javaindex e8aff21..bd5c629 100644--- a/src/opensuite/ui/UiScale.java+++ b/src/opensuite/ui/UiScale.java@@ -20,8 +20,13 @@ public final class UiScale {public static final double MIN = 0.75, MAX = 3.0;/**- * The scale to use: the launch flag, else the saved preference, else a- * default detected from the screen.+ * The scale to use: the launch flag, else the one chosen in Settings >+ * User interface > Display > Scaling, else 1.0, which sets nothing and+ * leaves the display's own setting to Java.+ *+ * <p>The application does not guess a scale from the size of the screen.+ * It used to, and a wide screen that was not a dense one got an interface+ * twice the size, with no way to say otherwise from outside.*/public static double desired() {String flag = System.getProperty("opensuite.scale");@@ -32,42 +37,11 @@ public final class UiScale {String saved = Preferences.userRoot().node(PREF_NODE).get(PREF_KEY, null);if (saved != null) return clamp(Double.parseDouble(saved));} catch (Exception ignored) {}- return detect();+ return 1.0;}- /**- * A sensible scale for this display, used on first run.- *- * <p>Defaulting to 1.0 made the interface unusably small on a high-density- * screen, which is the common case now. Java cannot be relied on to tell us- * the display is high-density: on a 4K panel under X11 it frequently reports- * 96 DPI and a transform scale of 1.0, so there is nothing to key off except- * the pixel dimensions themselves.- *- * <p>Only the three scales the view menu offers are returned, so the menu- * always shows the current state accurately. A saved preference always- * overrides this, so choosing a scale once makes the choice stick.- */- public static double detect() {- // macOS scales for the display itself (Retina), and takes no fractional scale from Java.- if (opensuite.core.Os.MAC) return 1.0;- try {- java.awt.GraphicsConfiguration gc = java.awt.GraphicsEnvironment- .getLocalGraphicsEnvironment().getDefaultScreenDevice()- .getDefaultConfiguration();- // When the platform already scales for us, do not scale twice.- double already = gc.getDefaultTransform().getScaleX();- if (already >= 1.5) return 1.0;-- java.awt.Rectangle b = gc.getBounds();- int w = b.width, h = b.height;- if (w >= 3200 || h >= 1800) return 2.0; // 4K and above- if (w >= 2400 || h >= 1350) return 1.5; // 2.5K class- return 1.0;- } catch (Exception e) {- return 1.0; // headless or an unusual display: do not guess- }- }+ /** Whether a scale was asked for, by the launch flag or in the settings; 1.0 asked for is still a choice. */+ public static boolean chosen() { return System.getProperty("opensuite.scale") != null || hasSaved(); }/** Whether the JVM is already running with the scale applied. */public static boolean applied() {@@ -77,12 +51,12 @@ public final class UiScale {static double clamp(double v) { return Math.max(MIN, Math.min(MAX, v)); }- /** Whether a scale has been chosen by hand, rather than left to the display. */+ /** Whether a scale has been chosen by hand, rather than left to the system's setting. */public static boolean hasSaved() {try { return Preferences.userRoot().node(PREF_NODE).get(PREF_KEY, null) != null; } catch (Exception e) { return false; }}- /** Forget a scale chosen by hand, so the next start fits the display again. */+ /** Forget a scale chosen by hand, so the next start follows the system's setting again. */public static void clearSaved() {try { Preferences p = Preferences.userRoot().node(PREF_NODE); p.remove(PREF_KEY); p.flush(); } catch (Exception ignored) {}}@@ -133,7 +107,7 @@ public final class UiScale {if (opensuite.core.Os.WINDOWS && info.arguments().isEmpty() && !bareJava && args != null) java.util.Collections.addAll(cmd, args);ProcessBuilder pb = new ProcessBuilder(cmd).inheritIO();// On a Mac the scale is applied to the font size instead (Theme.baseFontSize).- String opts = (Math.abs(s - 1.0) > 0.001 && !opensuite.core.Os.MAC ? "-Dsun.java2d.uiScale=" + s + " " : "")+ String opts = ((Math.abs(s - 1.0) > 0.001 || chosen()) && !opensuite.core.Os.MAC ? "-Dsun.java2d.uiScale=" + s + " " : "")+ "-Dopensuite.scaled=" + s;// The memory limit too, for a launcher that cannot read it itself (the macOS app).int mb = opensuite.core.Launch.memoryFileMb();diff --git a/src/opensuite/ui/settings/InterfacePages.java b/src/opensuite/ui/settings/InterfacePages.javaindex 83775b7..b5307b0 100644--- a/src/opensuite/ui/settings/InterfacePages.java+++ b/src/opensuite/ui/settings/InterfacePages.java@@ -242,7 +242,7 @@ public final class InterfacePages {SettingsPage.line(22, opensuite.ui.Sections.caption("Font size:"), 5, fontSize), themeRow);if (existingDisplay != null) p.addSection(existingDisplay);- // A scale chosen by hand is what "configure" means here; left alone, the scale fits the display.+ // A scale chosen by hand is what "configure" means here; left alone, the system's own setting applies.boolean byHand = opensuite.ui.UiScale.hasSaved();JCheckBox configure = Ui.check("Configure scaling settings", byHand);JCheckBox systemDpi = Ui.check("Use system DPI settings", false);@@ -258,7 +258,7 @@ public final class InterfacePages {};enable.run();configure.addActionListener(e -> {- // Ticked, it starts from the display's own scale; unticked, nothing is chosen by hand any more.+ // Ticked, it starts from the system's setting; unticked, nothing is chosen by hand any more.systemDpi.setSelected(configure.isSelected());opensuite.ui.UiScale.clearSaved();enable.run();