aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-06-18 04:06:27 +0200
committerSven Gothel <[email protected]>2013-06-18 04:06:27 +0200
commitde67cde91cb99e3a1a3b8182b119671d112c553b (patch)
tree360877b10966c49b110c6d479fb43cda028a840e
parente3beec5a0b4f696e458e8cc1d653ce9dc628e137 (diff)
Refine 893cf0c8c32edf231dbf418d45d3181532d2402b: Partial revert and issue forceRelayout at end of applet.start(); Cleanup AWTKeyAdapter.
Refine 893cf0c8c32edf231dbf418d45d3181532d2402b: Partial revert and issue forceRelayout at end of applet.start(); - Seems the workaround of OSX CALayer positioning bug is timing dependent, i.e. stopped working when disabled DEBUG output. - Move NewtCanvasAWT creation and attachment back to init() - Issue extra forceRelayout (if OSX) at end of start() .. works 'most of the time'. Cleanup AWTKeyAdapter: Adapt code style of keyPressed() to keyReleased().
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java26
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java9
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java7
3 files changed, 25 insertions, 17 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 529e8c5ab..e8cd71514 100644
--- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java
+++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java
@@ -42,6 +42,7 @@ import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
+import com.jogamp.common.os.Platform;
import com.jogamp.newt.awt.NewtCanvasAWT;
import com.jogamp.newt.opengl.GLWindow;
@@ -99,7 +100,6 @@ public class JOGLNewtApplet1Run extends Applet {
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;
public void init() {
if(DEBUG) {
@@ -147,7 +147,7 @@ public class JOGLNewtApplet1Run extends Applet {
if(null==glEventListenerClazzName) {
throw new RuntimeException("No applet parameter 'gl_event_listener_class'");
}
- glStandalone = Integer.MAX_VALUE>glXd && Integer.MAX_VALUE>glYd && Integer.MAX_VALUE>glWidth && Integer.MAX_VALUE>glHeight;
+ final boolean glStandalone = Integer.MAX_VALUE>glXd && Integer.MAX_VALUE>glYd && Integer.MAX_VALUE>glWidth && Integer.MAX_VALUE>glHeight;
if(DEBUG) {
System.err.println("JOGLNewtApplet1Run Configuration:");
System.err.println("glStandalone: "+glStandalone);
@@ -209,6 +209,11 @@ public class JOGLNewtApplet1Run extends Applet {
addKeyListener((KeyListener)glEventListener);
}
}
+ if( !glStandalone ) {
+ newtCanvasAWT = new NewtCanvasAWT(glWindow);
+ container.add(newtCanvasAWT, BorderLayout.CENTER);
+ container.validate();
+ }
} catch (Throwable t) {
throw new RuntimeException(t);
}
@@ -221,19 +226,13 @@ public class JOGLNewtApplet1Run extends Applet {
if(DEBUG) {
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.setVisible(true);
+ final java.awt.Point p0 = this.getLocationOnScreen();
if( null != newtCanvasAWT ) {
+ newtCanvasAWT.setFocusable(true);
newtCanvasAWT.requestFocus();
} else {
glWindow.requestFocus();
- }
- final java.awt.Point p0 = this.getLocationOnScreen();
- if(glStandalone) {
glWindow.setSize(glWidth, glHeight);
glWindow.setPosition(p0.x+glXd, p0.y+glYd);
}
@@ -252,6 +251,13 @@ public class JOGLNewtApplet1Run extends Applet {
System.err.println("GLWindow: "+glWindow);
}
base.start();
+ if( null != newtCanvasAWT && Platform.OSType.MACOS == Platform.getOSType() && newtCanvasAWT.isOffscreenLayerSurfaceEnabled() ) {
+ // force relayout
+ final int cW = newtCanvasAWT.getWidth();
+ final int cH = newtCanvasAWT.getHeight();
+ newtCanvasAWT.setSize(cW+1, cH+1);
+ newtCanvasAWT.setSize(cW, cH);
+ }
if(DEBUG) {
System.err.println("JOGLNewtApplet1Run.start() END");
}
diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
index 35199dc82..25ddfad48 100644
--- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
+++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
@@ -286,9 +286,8 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
// ***********************************************************************************
// ***********************************************************************************
- public void keyPressed(KeyEvent e) {
- }
- public void keyReleased(KeyEvent e) {
+ @Override
+ public void keyPressed(KeyEvent e) {
if( !e.isPrintableKey() || e.isAutoRepeat() ) {
return;
}
@@ -307,5 +306,9 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
}
}
}
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ }
}
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
index 1edef347b..bef2e5d0f 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
@@ -71,12 +71,11 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe
@Override
public void keyReleased(java.awt.event.KeyEvent e) {
- com.jogamp.newt.event.KeyEvent keyReleaseEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow);
+ final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow);
if(null!=newtListener) {
- final com.jogamp.newt.event.KeyListener newtKeyListener = (com.jogamp.newt.event.KeyListener)newtListener;
- newtKeyListener.keyReleased(keyReleaseEvt);
+ ((com.jogamp.newt.event.KeyListener)newtListener).keyReleased(event);
} else {
- enqueueEvent(false, keyReleaseEvt);
+ enqueueEvent(false, event);
}
}