mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-26 20:54:22 +01:00
Merge branch 'windows-dpi-awareness'
This commit is contained in:
commit
27d1b8d9a1
@ -122,7 +122,7 @@ public class Theme {
|
|||||||
return scale;
|
return scale;
|
||||||
} catch (NumberFormatException ignore) {
|
} catch (NumberFormatException ignore) {
|
||||||
}
|
}
|
||||||
return 100;
|
return BaseNoGui.getPlatform().getSystemDPI() * 100 / 96;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public int scale(int size) {
|
static public int scale(int size) {
|
||||||
|
@ -333,4 +333,9 @@ public class Platform {
|
|||||||
public void fixSettingsLocation() throws Exception {
|
public void fixSettingsLocation() throws Exception {
|
||||||
//noop
|
//noop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSystemDPI() {
|
||||||
|
return 96;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,10 @@ import java.nio.file.Paths;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
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 {
|
public class Platform extends processing.app.Platform {
|
||||||
|
|
||||||
@ -240,4 +244,54 @@ public class Platform extends processing.app.Platform {
|
|||||||
|
|
||||||
Files.move(oldSettingsFolder, settingsFolder.toPath());
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -926,8 +926,8 @@
|
|||||||
|
|
||||||
<target name="download-launch4j-windows">
|
<target name="download-launch4j-windows">
|
||||||
<antcall target="unzip-with-ant-task">
|
<antcall target="unzip-with-ant-task">
|
||||||
<param name="archive_file" value="windows/launch4j-3.8-win32.zip"/>
|
<param name="archive_file" value="windows/launch4j-3.9-win32.zip"/>
|
||||||
<param name="archive_url" value="http://downloads.sourceforge.net/project/launch4j/launch4j-3/3.8/launch4j-3.8-win32.zip"/>
|
<param name="archive_url" value="http://downloads.sourceforge.net/project/launch4j/launch4j-3/3.9/launch4j-3.9-win32.zip"/>
|
||||||
<param name="final_folder" value="windows/launcher/launch4j"/>
|
<param name="final_folder" value="windows/launcher/launch4j"/>
|
||||||
<param name="dest_folder" value="windows/launcher/"/>
|
<param name="dest_folder" value="windows/launcher/"/>
|
||||||
</antcall>
|
</antcall>
|
||||||
@ -935,8 +935,8 @@
|
|||||||
|
|
||||||
<target name="download-launch4j-linux">
|
<target name="download-launch4j-linux">
|
||||||
<antcall target="untar">
|
<antcall target="untar">
|
||||||
<param name="archive_file" value="windows/launch4j-3.8-linux.tgz"/>
|
<param name="archive_file" value="windows/launch4j-3.9-linux.tgz"/>
|
||||||
<param name="archive_url" value="http://downloads.sourceforge.net/project/launch4j/launch4j-3/3.8/launch4j-3.8-linux.tgz"/>
|
<param name="archive_url" value="http://downloads.sourceforge.net/project/launch4j/launch4j-3/3.9/launch4j-3.9-linux.tgz"/>
|
||||||
<param name="final_folder" value="windows/launcher/launch4j"/>
|
<param name="final_folder" value="windows/launcher/launch4j"/>
|
||||||
<param name="dest_folder" value="windows/launcher/"/>
|
<param name="dest_folder" value="windows/launcher/"/>
|
||||||
</antcall>
|
</antcall>
|
||||||
@ -1026,7 +1026,7 @@
|
|||||||
|
|
||||||
<copy todir="windows/work">
|
<copy todir="windows/work">
|
||||||
<fileset dir="windows/launcher"
|
<fileset dir="windows/launcher"
|
||||||
includes="application.ico, config.xml, config_debug.xml, arduino.l4j.ini"/>
|
includes="application.ico, config.xml, config_debug.xml, arduino.l4j.ini, wrapper-manifest.xml"/>
|
||||||
</copy>
|
</copy>
|
||||||
<launch4j configFile="windows/work/config.xml" fileVersion="${revision}.0" txtFileVersion="${revision}" productVersion="${revision}.0" txtProductVersion="${revision}"/>
|
<launch4j configFile="windows/work/config.xml" fileVersion="${revision}.0" txtFileVersion="${revision}" productVersion="${revision}.0" txtProductVersion="${revision}"/>
|
||||||
<launch4j configFile="windows/work/config_debug.xml" fileVersion="${revision}.0" txtFileVersion="${revision}" productVersion="${revision}.0" txtProductVersion="${revision}"/>
|
<launch4j configFile="windows/work/config_debug.xml" fileVersion="${revision}.0" txtFileVersion="${revision}" productVersion="${revision}.0" txtProductVersion="${revision}"/>
|
||||||
|
@ -1 +0,0 @@
|
|||||||
97a390c10c2c6fce7cc54bee2ef8bcdd790d6dc3
|
|
@ -1 +0,0 @@
|
|||||||
60bb9fd94177aff5e19d8cba8da84df157ae3200
|
|
1
build/windows/launch4j-3.9-linux.tgz.sha
Normal file
1
build/windows/launch4j-3.9-linux.tgz.sha
Normal file
@ -0,0 +1 @@
|
|||||||
|
9d4c377af0149389da9ad3c3f1394fc5a655f540
|
1
build/windows/launch4j-3.9-win32.zip.sha
Normal file
1
build/windows/launch4j-3.9-win32.zip.sha
Normal file
@ -0,0 +1 @@
|
|||||||
|
da6645d030137672647f576c8358427bc663282e
|
@ -75,4 +75,5 @@
|
|||||||
<launcherErr>The registry refers to a nonexistent Java Development Kit installation or the runtime is corrupted.</launcherErr>
|
<launcherErr>The registry refers to a nonexistent Java Development Kit installation or the runtime is corrupted.</launcherErr>
|
||||||
<instanceAlreadyExistsMsg>An application instance is already running.</instanceAlreadyExistsMsg>
|
<instanceAlreadyExistsMsg>An application instance is already running.</instanceAlreadyExistsMsg>
|
||||||
</messages>
|
</messages>
|
||||||
|
<manifest>wrapper-manifest.xml</manifest>
|
||||||
</launch4jConfig>
|
</launch4jConfig>
|
||||||
|
@ -75,4 +75,5 @@
|
|||||||
<launcherErr>The registry refers to a nonexistent Java Development Kit installation or the runtime is corrupted.</launcherErr>
|
<launcherErr>The registry refers to a nonexistent Java Development Kit installation or the runtime is corrupted.</launcherErr>
|
||||||
<instanceAlreadyExistsMsg>An application instance is already running.</instanceAlreadyExistsMsg>
|
<instanceAlreadyExistsMsg>An application instance is already running.</instanceAlreadyExistsMsg>
|
||||||
</messages>
|
</messages>
|
||||||
|
<manifest>wrapper-manifest.xml</manifest>
|
||||||
</launch4jConfig>
|
</launch4jConfig>
|
||||||
|
9
build/windows/launcher/wrapper-manifest.xml
Normal file
9
build/windows/launcher/wrapper-manifest.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
|
||||||
|
<asmv3:application>
|
||||||
|
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
|
||||||
|
<dpiAware>true</dpiAware>
|
||||||
|
</asmv3:windowsSettings>
|
||||||
|
</asmv3:application>
|
||||||
|
|
||||||
|
</assembly>
|
Loading…
x
Reference in New Issue
Block a user