diff --git a/app/src/processing/app/Theme.java b/app/src/processing/app/Theme.java index cea6e6fe4..bfa393498 100644 --- a/app/src/processing/app/Theme.java +++ b/app/src/processing/app/Theme.java @@ -122,7 +122,7 @@ public class Theme { return scale; } catch (NumberFormatException ignore) { } - return 100; + return BaseNoGui.getPlatform().getSystemDPI() * 100 / 96; } static public int scale(int size) { diff --git a/arduino-core/src/processing/app/Platform.java b/arduino-core/src/processing/app/Platform.java index f829699bd..0f3d59175 100644 --- a/arduino-core/src/processing/app/Platform.java +++ b/arduino-core/src/processing/app/Platform.java @@ -333,4 +333,9 @@ public class Platform { public void fixSettingsLocation() throws Exception { //noop } + + public int getSystemDPI() { + return 96; + } + } diff --git a/arduino-core/src/processing/app/windows/Platform.java b/arduino-core/src/processing/app/windows/Platform.java index c9d6ea615..349415b2b 100644 --- a/arduino-core/src/processing/app/windows/Platform.java +++ b/arduino-core/src/processing/app/windows/Platform.java @@ -35,6 +35,10 @@ import java.nio.file.Paths; import java.util.LinkedList; import java.util.List; +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.win32.StdCallLibrary; +import com.sun.jna.win32.W32APIOptions; public class Platform extends processing.app.Platform { @@ -240,4 +244,54 @@ public class Platform extends processing.app.Platform { Files.move(oldSettingsFolder, settingsFolder.toPath()); } + + // Need to extend com.sun.jna.platform.win32.User32 to access + // Win32 function GetDpiForSystem() + interface ExtUser32 extends StdCallLibrary, com.sun.jna.platform.win32.User32 { + ExtUser32 INSTANCE = (ExtUser32) Native.loadLibrary("user32", ExtUser32.class, W32APIOptions.DEFAULT_OPTIONS); + + public int GetDpiForSystem(); + + public int SetProcessDpiAwareness(int value); + + public final int DPI_AWARENESS_INVALID = -1; + public final int DPI_AWARENESS_UNAWARE = 0; + public final int DPI_AWARENESS_SYSTEM_AWARE = 1; + public final int DPI_AWARENESS_PER_MONITOR_AWARE = 2; + + public Pointer SetThreadDpiAwarenessContext(Pointer dpiContext); + + public final Pointer DPI_AWARENESS_CONTEXT_UNAWARE = new Pointer(-1); + public final Pointer DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = new Pointer(-2); + public final Pointer DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = new Pointer(-3); + } + + private static int detected = detectSystemDPI(); + + @Override + public int getSystemDPI() { + if (detected == -1) + return super.getSystemDPI(); + return detected; + } + + public static int detectSystemDPI() { + try { + ExtUser32.INSTANCE.SetProcessDpiAwareness(ExtUser32.DPI_AWARENESS_SYSTEM_AWARE); + } catch (Throwable e) { + // Ignore error + } + try { + ExtUser32.INSTANCE.SetThreadDpiAwarenessContext(ExtUser32.DPI_AWARENESS_CONTEXT_SYSTEM_AWARE); + } catch (Throwable e) { + // Ignore error (call valid only on Windows 10) + } + try { + return ExtUser32.INSTANCE.GetDpiForSystem(); + } catch (Throwable e) { + // DPI detection failed, fall back with default + System.out.println("DPI detection failed, fallback to 96 dpi"); + return -1; + } + } } diff --git a/build/build.xml b/build/build.xml index d6159610f..312f432f2 100644 --- a/build/build.xml +++ b/build/build.xml @@ -926,8 +926,8 @@ - - + + @@ -935,8 +935,8 @@ - - + + @@ -1026,7 +1026,7 @@ + includes="application.ico, config.xml, config_debug.xml, arduino.l4j.ini, wrapper-manifest.xml"/> diff --git a/build/windows/launch4j-3.8-linux.tgz.sha b/build/windows/launch4j-3.8-linux.tgz.sha deleted file mode 100644 index 3c6125ab7..000000000 --- a/build/windows/launch4j-3.8-linux.tgz.sha +++ /dev/null @@ -1 +0,0 @@ -97a390c10c2c6fce7cc54bee2ef8bcdd790d6dc3 diff --git a/build/windows/launch4j-3.8-win32.zip.sha b/build/windows/launch4j-3.8-win32.zip.sha deleted file mode 100644 index 99cd59c56..000000000 --- a/build/windows/launch4j-3.8-win32.zip.sha +++ /dev/null @@ -1 +0,0 @@ -60bb9fd94177aff5e19d8cba8da84df157ae3200 diff --git a/build/windows/launch4j-3.9-linux.tgz.sha b/build/windows/launch4j-3.9-linux.tgz.sha new file mode 100644 index 000000000..9374fd0f6 --- /dev/null +++ b/build/windows/launch4j-3.9-linux.tgz.sha @@ -0,0 +1 @@ +9d4c377af0149389da9ad3c3f1394fc5a655f540 diff --git a/build/windows/launch4j-3.9-win32.zip.sha b/build/windows/launch4j-3.9-win32.zip.sha new file mode 100644 index 000000000..d6a20f284 --- /dev/null +++ b/build/windows/launch4j-3.9-win32.zip.sha @@ -0,0 +1 @@ +da6645d030137672647f576c8358427bc663282e diff --git a/build/windows/launcher/config.xml b/build/windows/launcher/config.xml index 0ab5a8061..7168db2e0 100644 --- a/build/windows/launcher/config.xml +++ b/build/windows/launcher/config.xml @@ -75,4 +75,5 @@ The registry refers to a nonexistent Java Development Kit installation or the runtime is corrupted. An application instance is already running. + wrapper-manifest.xml diff --git a/build/windows/launcher/config_debug.xml b/build/windows/launcher/config_debug.xml index 4fe7397ef..171013302 100644 --- a/build/windows/launcher/config_debug.xml +++ b/build/windows/launcher/config_debug.xml @@ -75,4 +75,5 @@ The registry refers to a nonexistent Java Development Kit installation or the runtime is corrupted. An application instance is already running. + wrapper-manifest.xml diff --git a/build/windows/launcher/wrapper-manifest.xml b/build/windows/launcher/wrapper-manifest.xml new file mode 100644 index 000000000..615052545 --- /dev/null +++ b/build/windows/launcher/wrapper-manifest.xml @@ -0,0 +1,9 @@ + + + + + true + + + +