File tree 1 file changed +21
-0
lines changed
arduino-core/src/processing/app/windows
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 35
35
import java .util .LinkedList ;
36
36
import java .util .List ;
37
37
38
+ import com .sun .jna .Native ;
39
+ import com .sun .jna .win32 .StdCallLibrary ;
40
+ import com .sun .jna .win32 .W32APIOptions ;
38
41
39
42
public class Platform extends processing .app .Platform {
40
43
@@ -240,4 +243,22 @@ public void fixSettingsLocation() throws Exception {
240
243
241
244
Files .move (oldSettingsFolder , settingsFolder .toPath ());
242
245
}
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
+ }
243
264
}
You can’t perform that action at this time.
0 commit comments