diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index b282933ea..3780b1efd 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -26,7 +26,6 @@ package processing.core; // used by link() import java.awt.Desktop; - import java.awt.DisplayMode; import java.awt.EventQueue; import java.awt.FileDialog; @@ -40,6 +39,7 @@ import java.awt.Toolkit; import java.awt.color.ColorSpace; import java.awt.image.BufferedImage; + // used by loadImage() functions import javax.imageio.ImageIO; // allows us to remove our own MediaTracker code @@ -53,6 +53,7 @@ import javax.swing.filechooser.FileSystemView; // loadXML() error handling import javax.xml.parsers.ParserConfigurationException; + import org.xml.sax.SAXException; import java.io.*; @@ -1964,7 +1965,7 @@ public class PApplet implements PConstants { if (width != this.width || height != this.height || !renderer.equals(this.renderer)) { - println(width, height, renderer, this.width, this.height, this.renderer); + //println(width, height, renderer, this.width, this.height, this.renderer); if (insideSettings("size", width, height, renderer)) { this.width = width; this.height = height; @@ -10144,6 +10145,12 @@ public class PApplet implements PConstants { } else { surface.placeWindow(location, editorLocation); } + + // checking with Andres about this one +// if (sketch.getGraphics().displayable()) { +// surface.setVisible(true); +// } + // not always running externally when in present mode if (external) { surface.setupExternalMessages(); @@ -10183,11 +10190,14 @@ public class PApplet implements PConstants { "use fullScreen() to get an undecorated full screen frame"); } + // Can't override this one because it's called by Window's constructor + /* @Override public void setLocation(int x, int y) { deprecationWarning("setLocation"); surface.setLocation(x, y); } + */ @Override public void setSize(int w, int h) { @@ -10198,6 +10208,7 @@ public class PApplet implements PConstants { private void deprecationWarning(String method) { PGraphics.showWarning("Use surface." + method + "() instead of " + "frame." + method + " in Processing 3"); + //new Exception(method).printStackTrace(System.out); } }; diff --git a/core/src/processing/core/PSurfaceAWT.java b/core/src/processing/core/PSurfaceAWT.java index 423814807..bd4822c36 100644 --- a/core/src/processing/core/PSurfaceAWT.java +++ b/core/src/processing/core/PSurfaceAWT.java @@ -55,8 +55,8 @@ public class PSurfaceAWT extends PSurfaceNone { // 3.0a5 didn't use strategy, and active was shut off during init() w/ retina // boolean useStrategy = true; -// Canvas canvas; - Component canvas; + Canvas canvas; +// Component canvas; // PGraphics graphics; // moved to PSurfaceNone @@ -283,7 +283,8 @@ public class PSurfaceAWT extends PSurfaceNone { return; } - Canvas c = (Canvas) canvas; + Canvas c = canvas; +// Frame c = frame; // System.out.println("render(), canvas bounds are " + canvas.getBounds()); if (c.getBufferStrategy() == null) { // whole block [121222] // System.out.println("creating a strategy"); @@ -480,6 +481,7 @@ public class PSurfaceAWT extends PSurfaceNone { // OS X. It's time for a turnaround: Redmond is thinking different too! // https://github.com/processing/processing/issues/1955 frame = new JFrame(displayDevice.getDefaultConfiguration()); +// frame = new Frame(displayDevice.getDefaultConfiguration()); // // Default Processing gray, which will be replaced below if another // // color is specified on the command line (i.e. in the prefs). // ((JFrame) frame).getContentPane().setBackground(WINDOW_BGCOLOR); @@ -511,6 +513,7 @@ public class PSurfaceAWT extends PSurfaceNone { frame.add(canvas); setSize(sketchWidth, sketchHeight); + /* if (fullScreen) { // Called here because the graphics device is needed before we can // determine whether the sketch wants size(displayWidth, displayHeight), @@ -533,6 +536,7 @@ public class PSurfaceAWT extends PSurfaceNone { // will be set visible in placeWindow() [3.0a10] //frame.setVisible(true); // re-add native resources } + */ frame.setLayout(null); //frame.add(applet); @@ -596,6 +600,12 @@ public class PSurfaceAWT extends PSurfaceNone { public void setVisible(boolean visible) { frame.setVisible(visible); + // Generally useful whenever setting the frame visible + if (canvas != null) { + //canvas.requestFocusInWindow(); + canvas.requestFocus(); + } + // removing per https://github.com/processing/processing/pull/3162 // can remove the code below once 3.0a6 is tested and behaving /* @@ -618,8 +628,10 @@ public class PSurfaceAWT extends PSurfaceNone { //public void placeFullScreen(boolean hideStop) { @Override public void placePresent(int stopColor) { + setFullFrame(); + // After the pack(), the screen bounds are gonna be 0s - frame.setBounds(screenRect); +// frame.setBounds(screenRect); // already called in setFullFrame() canvas.setBounds((screenRect.width - sketchWidth) / 2, (screenRect.height - sketchHeight) / 2, sketchWidth, sketchHeight); @@ -647,6 +659,10 @@ public class PSurfaceAWT extends PSurfaceNone { label.setSize(labelSize); label.setLocation(20, screenRect.height - labelSize.height - 20); } + + if (sketch.getGraphics().displayable()) { + setVisible(true); + } } @@ -734,6 +750,28 @@ public class PSurfaceAWT extends PSurfaceNone { } + /** Hide the menu bar, make the Frame undecorated, set it to screenRect. */ + private void setFullFrame() { + // Called here because the graphics device is needed before we can + // determine whether the sketch wants size(displayWidth, displayHeight), + // and getting the graphics device will be PSurface-specific. + PApplet.hideMenuBar(); + + // Tried to use this to fix the 'present' mode issue. + // Did not help, and the screenRect setup seems to work fine. + //frame.setExtendedState(Frame.MAXIMIZED_BOTH); + + // https://github.com/processing/processing/pull/3162 + frame.dispose(); // release native resources, allows setUndecorated() + frame.setUndecorated(true); + + // this may be the bounds of all screens + frame.setBounds(screenRect); + // will be set visible in placeWindow() [3.0a10] + //frame.setVisible(true); // re-add native resources + } + + @Override public void placeWindow(int[] location, int[] editorLocation) { //Dimension window = setFrameSize(sketchWidth, sketchHeight); @@ -742,6 +780,10 @@ public class PSurfaceAWT extends PSurfaceNone { int contentW = Math.max(sketchWidth, MIN_WINDOW_WIDTH); int contentH = Math.max(sketchHeight, MIN_WINDOW_HEIGHT); + if (sketch.sketchFullScreen()) { + setFullFrame(); + } + // Ignore placement of previous window and editor when full screen if (!sketch.sketchFullScreen()) { if (location != null) { @@ -790,15 +832,20 @@ public class PSurfaceAWT extends PSurfaceNone { // handle frame resizing events setupFrameResizeListener(); + /* // If displayable() is false, then PSurfaceNone should be used, but... if (sketch.getGraphics().displayable()) { frame.setVisible(true); // System.out.println("setting visible on EDT? " + EventQueue.isDispatchThread()); //requestFocus(); - if (canvas != null) { - //canvas.requestFocusInWindow(); - canvas.requestFocus(); - } +// if (canvas != null) { +// //canvas.requestFocusInWindow(); +// canvas.requestFocus(); +// } + } + */ + if (sketch.getGraphics().displayable()) { + setVisible(true); } } diff --git a/core/todo.txt b/core/todo.txt index 8c36c71b2..cc31b8917 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -53,6 +53,7 @@ X sketch sometimes doesn't show with noLoop() on Linux X https://github.com/processing/processing/issues/3316 X Window never shows with exported application on 64-bit Linux X https://github.com/processing/processing/issues/3303 +X present mode is now broken cleaning o possible addition for 'implementation' variable @@ -112,6 +113,10 @@ _ still some spinning when sketches break _ settings() is probably not showing exceptions since we're back to the EDT _ can't call handleSettings() on the anim thread since it sets the surface _ so maybe the first part is on the EDT, but other threads run this stuff +_ try using Frame instead of JFrame +_ default sketch location using insets incorrectly +_ use the BufferStrategy directly from the Frame object? +_ might fix performance issues w/ Presentation mode javafx @@ -126,7 +131,8 @@ _ https://github.com/processing/processing/issues/3290 _ what's the way to do this after the deprecation? _ if this is going to be the default renderer, has to be ironed out _ displayWidth, displayHeight, full screen, display number -_ present mode (stage in the center, clear the rest of the screen) +_ present mode not working at all +_ stage in the center, clear the rest of the screen _ createGraphics() should probably create PGraphicsJava2D _ or is Canvas specific to the PGraphics, and we get another Context2D? _ http://docs.oracle.com/javafx/2/api/javafx/scene/canvas/Canvas.html