Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sgothel committed Jun 18, 2013
1 parent 6944d34 commit 893cf0c
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java
Expand Up @@ -94,9 +94,9 @@
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;
Expand All @@ -108,7 +108,7 @@ public void init() {
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;
Expand Down Expand Up @@ -209,13 +209,6 @@ public void init() {
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);
}
Expand All @@ -226,11 +219,19 @@ public void init() {

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);
Expand Down Expand Up @@ -271,12 +272,14 @@ public void destroy() {
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");
}
Expand Down

0 comments on commit 893cf0c

Please sign in to comment.