File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
arduino-core/src/processing/app/windows Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 3535import java .util .LinkedList ;
3636import java .util .List ;
3737
38+ import com .sun .jna .Native ;
39+ import com .sun .jna .win32 .StdCallLibrary ;
40+ import com .sun .jna .win32 .W32APIOptions ;
3841
3942public class Platform extends processing .app .Platform {
4043
@@ -240,4 +243,22 @@ public void fixSettingsLocation() throws Exception {
240243
241244 Files .move (oldSettingsFolder , settingsFolder .toPath ());
242245 }
246+
247+ // Need to extend com.sun.jna.platform.win32.User32 to access
248+ // Win32 function GetDpiForSystem()
249+ interface ExtUser32 extends StdCallLibrary , com .sun .jna .platform .win32 .User32 {
250+ ExtUser32 INSTANCE = (ExtUser32 ) Native .loadLibrary ("user32" , ExtUser32 .class , W32APIOptions .DEFAULT_OPTIONS );
251+
252+ public int GetDpiForSystem ();
253+ }
254+
255+ @ Override
256+ public int getSystemDPI () {
257+ try {
258+ return ExtUser32 .INSTANCE .GetDpiForSystem ();
259+ } catch (Throwable e ) {
260+ // DPI detection failed, fall back with default
261+ return super .getSystemDPI ();
262+ }
263+ }
243264}
You can’t perform that action at this time.
0 commit comments