diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 4cbe2de3c..90f78a4fd 100755 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -914,6 +914,11 @@ public class PApplet extends Applet } } catch (Exception e) { } // may be a security problem + // Figure out the available display width and height. + // No major problem if this fails, we have to try again anyway in + // handleDraw() on the first (== 0) frame. + checkDisplaySize(); + Dimension size = getSize(); if ((size.width != 0) && (size.height != 0)) { // When this PApplet is embedded inside a Java application with other @@ -967,6 +972,21 @@ public class PApplet extends Applet } + private void checkDisplaySize() { + if (getGraphicsConfiguration() != null) { + GraphicsDevice displayDevice = getGraphicsConfiguration().getDevice(); + + if (displayDevice != null) { + Rectangle screenRect = + displayDevice.getDefaultConfiguration().getBounds(); + + displayWidth = screenRect.width; + displayHeight = screenRect.height; + } + } + } + + private boolean checkRetina() { if (platform == MACOSX) { // This should probably be reset each time there's a display change. @@ -2278,17 +2298,18 @@ public class PApplet extends Applet long now = System.nanoTime(); if (frameCount == 0) { - GraphicsConfiguration gc = getGraphicsConfiguration(); - if (gc == null) return; - GraphicsDevice displayDevice = - getGraphicsConfiguration().getDevice(); - if (displayDevice == null) return; - Rectangle screenRect = - displayDevice.getDefaultConfiguration().getBounds(); -// screenX = screenRect.x; -// screenY = screenRect.y; - displayWidth = screenRect.width; - displayHeight = screenRect.height; +// GraphicsConfiguration gc = getGraphicsConfiguration(); +// if (gc == null) return; +// GraphicsDevice displayDevice = +// getGraphicsConfiguration().getDevice(); +// if (displayDevice == null) return; +// Rectangle screenRect = +// displayDevice.getDefaultConfiguration().getBounds(); +//// screenX = screenRect.x; +//// screenY = screenRect.y; +// displayWidth = screenRect.width; +// displayHeight = screenRect.height; + checkDisplaySize(); try { //println("Calling setup()");