diff options
author | Sven Gothel <[email protected]> | 2013-06-18 03:10:16 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-06-18 03:10:16 +0200 |
commit | 893cf0c8c32edf231dbf418d45d3181532d2402b (patch) | |
tree | 7ab742034fc6148e9b6576c3379e3fd79ccbf328 /src/newt/classes | |
parent | 6944d3485ad005c6cd69a3122479f1fbaef26dfc (diff) |
JOGLNewtApplet1Run: Defer 'newtCanvasAWT' creation and attachment to applet.start() (only once), working around 'OS X' CALayer positioning bug.
The NewtCanvasAWT workaround for the 'OS X' CALayer positioning bug(*)
may only work if parent is not only dislayable, but also visible.
(*): Workaround resizes the component 2x, forcing a relayout.
++
RequestFocus after setVisibile(true).
+++
Clear references to glWindow, newtCanvasAWT @ destroy.
Diffstat (limited to 'src/newt/classes')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java index d06aca039..529e8c5ab 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java @@ -94,9 +94,9 @@ import com.jogamp.newt.opengl.GLWindow; public class JOGLNewtApplet1Run extends Applet { public static final boolean DEBUG = JOGLNewtAppletBase.DEBUG; - GLWindow glWindow; - NewtCanvasAWT newtCanvasAWT; - JOGLNewtAppletBase base; + GLWindow glWindow = null; + NewtCanvasAWT newtCanvasAWT = null; + JOGLNewtAppletBase base = null; /** if valid glStandalone:=true (own window) ! */ int glXd=Integer.MAX_VALUE, glYd=Integer.MAX_VALUE, glWidth=Integer.MAX_VALUE, glHeight=Integer.MAX_VALUE; boolean glStandalone = false; @@ -108,7 +108,7 @@ public class JOGLNewtApplet1Run extends Applet { if(!(this instanceof Container)) { throw new RuntimeException("This Applet is not a AWT Container"); } - Container container = (Container) this; + final Container container = (Container) this; String glEventListenerClazzName=null; String glProfileName=null; @@ -209,13 +209,6 @@ public class JOGLNewtApplet1Run extends Applet { addKeyListener((KeyListener)glEventListener); } } - if(glStandalone) { - newtCanvasAWT = null; - } else { - newtCanvasAWT = new NewtCanvasAWT(glWindow); - container.add(newtCanvasAWT, BorderLayout.CENTER); - container.validate(); - } } catch (Throwable t) { throw new RuntimeException(t); } @@ -226,11 +219,19 @@ public class JOGLNewtApplet1Run extends Applet { public void start() { if(DEBUG) { - System.err.println("JOGLNewtApplet1Run.start() START"); + System.err.println("JOGLNewtApplet1Run.start() START (isVisible "+isVisible()+", isDisplayable "+isDisplayable()+")"); + } + if( null == newtCanvasAWT && !glStandalone) { + newtCanvasAWT = new NewtCanvasAWT(glWindow); + this.add(newtCanvasAWT, BorderLayout.CENTER); + this.validate(); } - this.validate(); this.setVisible(true); - + if( null != newtCanvasAWT ) { + newtCanvasAWT.requestFocus(); + } else { + glWindow.requestFocus(); + } final java.awt.Point p0 = this.getLocationOnScreen(); if(glStandalone) { glWindow.setSize(glWidth, glHeight); @@ -271,12 +272,14 @@ public class JOGLNewtApplet1Run extends Applet { System.err.println("JOGLNewtApplet1Run.destroy() START"); } glWindow.setVisible(false); // hide 1st - if(!glStandalone) { + if( null != newtCanvasAWT ) { glWindow.reparentWindow(null); // get out of newtCanvasAWT this.remove(newtCanvasAWT); // remove newtCanvasAWT } base.destroy(); // destroy glWindow unrecoverable base=null; + glWindow=null; + newtCanvasAWT=null; if(DEBUG) { System.err.println("JOGLNewtApplet1Run.destroy() END"); } |