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
@@ -228,4 +231,22 @@ public void fixSettingsLocation() throws Exception {
228231
229232 Files .move (oldSettingsFolder , settingsFolder .toPath ());
230233 }
234+
235+ // Need to extend com.sun.jna.platform.win32.User32 to access
236+ // Win32 function GetDpiForSystem()
237+ interface ExtUser32 extends StdCallLibrary , com .sun .jna .platform .win32 .User32 {
238+ ExtUser32 INSTANCE = (ExtUser32 ) Native .loadLibrary ("user32" , ExtUser32 .class , W32APIOptions .DEFAULT_OPTIONS );
239+
240+ public int GetDpiForSystem ();
241+ }
242+
243+ @ Override
244+ public int getSystemDPI () {
245+ try {
246+ return ExtUser32 .INSTANCE .GetDpiForSystem ();
247+ } catch (Throwable e ) {
248+ // DPI detection failed, fall back with default
249+ return super .getSystemDPI ();
250+ }
251+ }
231252}
You can’t perform that action at this time.
0 commit comments