Skip to content

Commit 93ef064

Browse files
committed
change to uiScale when getting display bounds
1 parent 0882da0 commit 93ef064

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

core/src/processing/opengl/PSurfaceJOGL.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,13 @@ static protected Rectangle getDisplayBounds(int displayNum) {
200200
awtDisplayDevice = ge.getDefaultScreenDevice();
201201
}
202202

203-
return awtDisplayDevice.getDefaultConfiguration().getBounds();
203+
//return awtDisplayDevice.getDefaultConfiguration().getBounds();
204+
Rectangle bounds = awtDisplayDevice.getDefaultConfiguration().getBounds();
205+
float uiScale = Float.parseFloat(System.getProperty("sun.java2d.uiScale", "1.0"));
206+
return new Rectangle((int) (uiScale * bounds.getX()),
207+
(int) (uiScale * bounds.getY()),
208+
(int) (uiScale * bounds.getWidth()),
209+
(int) (uiScale * bounds.getHeight()));
204210
}
205211

206212

@@ -302,19 +308,21 @@ protected void initWindow() {
302308
windowScaleFactor =
303309
(PApplet.platform == PConstants.MACOS) ? 1 : sketch.pixelDensity;
304310

305-
float uiScale =
306-
Float.parseFloat(System.getProperty("sun.java2d.uiScale", "1.0"));
307-
308311
boolean spanDisplays = sketch.sketchDisplay() == PConstants.SPAN;
309312

310313
screenRect = spanDisplays ?
311314
// TODO probably need to apply this to the spanning version [fry 230218]
312315
new Rectangle(screen.getX(), screen.getY(),
313316
screen.getWidth(), screen.getHeight()) :
314-
new Rectangle((int) (uiScale * displayRect.getX()),
315-
(int) (uiScale * displayRect.getY()),
316-
(int) (uiScale * displayRect.getWidth()),
317-
(int) (uiScale * displayRect.getHeight()));
317+
new Rectangle((int) displayRect.getX(),
318+
(int) displayRect.getY(),
319+
(int) displayRect.getWidth(),
320+
(int) displayRect.getHeight());
321+
322+
// new Rectangle((int) (uiScale * displayRect.getX()),
323+
// (int) (uiScale * displayRect.getY()),
324+
// (int) (uiScale * displayRect.getWidth()),
325+
// (int) (uiScale * displayRect.getHeight()));
318326

319327
// Set the displayWidth/Height variables inside PApplet, so that they're
320328
// usable and can even be returned by the sketchWidth()/Height() methods.
@@ -338,8 +346,10 @@ protected void initWindow() {
338346
// https://github.com/processing/processing/issues/3545
339347

340348
if (fullScreen || spanDisplays) {
341-
sketchWidth = (int) (uiScale * screenRect.width / windowScaleFactor);
342-
sketchHeight = (int) (uiScale * screenRect.height / windowScaleFactor);
349+
// sketchWidth = (int) (uiScale * screenRect.width / windowScaleFactor);
350+
// sketchHeight = (int) (uiScale * screenRect.height / windowScaleFactor);
351+
sketchWidth = screenRect.width / windowScaleFactor;
352+
sketchHeight = screenRect.height / windowScaleFactor;
343353
}
344354

345355
sketch.setSize(sketchWidth, sketchHeight);
@@ -483,7 +493,6 @@ protected void initIcons() {
483493
}
484494

485495

486-
@SuppressWarnings("resource")
487496
private String resourceFilename(String filename) {
488497
// The code below comes from PApplet.createInputRaw() with a few adaptations
489498
InputStream stream;

0 commit comments

Comments
 (0)