lots of code to handle scaling on Windows; also for #378

This commit is contained in:
Ben Fry
2022-02-13 08:46:16 -05:00
parent c175233ccb
commit fa741e29d0
2 changed files with 78 additions and 34 deletions

View File

@@ -24,7 +24,6 @@ package processing.mode.java.runner;
import processing.app.*;
import processing.app.exec.StreamRedirectThread;
import processing.app.ui.Toolkit;
import processing.core.*;
import processing.data.StringList;
import processing.mode.java.JavaBuild;
@@ -33,6 +32,7 @@ import processing.mode.java.JavaEditor;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Toolkit;
import java.io.*;
import java.net.ConnectException;
import java.net.InetAddress;
@@ -490,9 +490,17 @@ public class Runner implements MessageConsumer {
// removed for 3.0a6 because it would break the args passed to sketches.
params.append(PApplet.ARGS_SKETCH_FOLDER + "=" + build.getSketchPath());
/*
if (Toolkit.zoom(100) >= 200) { // Use 100 to bypass possible rounding in zoom()
params.append(PApplet.ARGS_DENSITY + "=2");
}
*/
if (Platform.isWindows()) {
// Pass the DPI setting to the app to avoid using the helper app.
int dpi = Toolkit.getDefaultToolkit().getScreenResolution();
int uiScale = PApplet.constrain(dpi / 96, 1, 2);
params.append(PApplet.ARGS_UI_SCALE + "=" + uiScale);
}
params.append(build.getSketchClassName());
}