summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/scripts/tests.sh4
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java51
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java4
4 files changed, 37 insertions, 24 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index aab20980d..9510734a3 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -608,9 +608,9 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $*
-#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $*
+testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $*
-testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $*
+#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $*
#
# Misc Utils
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index b8de1f596..f9f869781 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -101,9 +101,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
private boolean newtChildAttached = false;
private boolean isOnscreen = true;
private WindowClosingMode newtChildCloseOp;
- private AWTParentWindowAdapter awtAdapter = null;
- private AWTAdapter awtMouseAdapter = null;
- private AWTAdapter awtKeyAdapter = null;
+ private final AWTParentWindowAdapter awtAdapter;
+ private final AWTAdapter awtMouseAdapter;
+ private final AWTAdapter awtKeyAdapter;
private final AWTWindowClosingProtocol awtWindowClosingProtocol =
new AWTWindowClosingProtocol(this, new Runnable() {
@@ -125,6 +125,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
*/
public NewtCanvasAWT() {
super();
+ awtMouseAdapter = new AWTMouseAdapter().addTo(this);
+ awtKeyAdapter = new AWTKeyAdapter().addTo(this);
+ awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this);
+ awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction!
}
/**
@@ -132,6 +136,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
*/
public NewtCanvasAWT(GraphicsConfiguration gc) {
super(gc);
+ awtMouseAdapter = new AWTMouseAdapter().addTo(this);
+ awtKeyAdapter = new AWTKeyAdapter().addTo(this);
+ awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this);
+ awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction!
}
/**
@@ -139,6 +147,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
*/
public NewtCanvasAWT(Window child) {
super();
+ awtMouseAdapter = new AWTMouseAdapter().addTo(this);
+ awtKeyAdapter = new AWTKeyAdapter().addTo(this);
+ awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this);
+ awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction!
setNEWTChild(child);
}
@@ -147,6 +159,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
*/
public NewtCanvasAWT(GraphicsConfiguration gc, Window child) {
super(gc);
+ awtMouseAdapter = new AWTMouseAdapter().addTo(this);
+ awtKeyAdapter = new AWTKeyAdapter().addTo(this);
+ awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this);
+ awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction!
setNEWTChild(child);
}
@@ -671,18 +687,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
}
private final void configureNewtChild(boolean attach) {
- if(null!=awtAdapter) {
- awtAdapter.removeFrom(this);
- awtAdapter=null;
- }
- if(null!=awtMouseAdapter) {
- awtMouseAdapter.removeFrom(this);
- awtMouseAdapter = null;
- }
- if(null!=awtKeyAdapter) {
- awtKeyAdapter.removeFrom(this);
- awtKeyAdapter = null;
- }
+ awtAdapter.clear();
+ awtMouseAdapter.clear();
+ awtKeyAdapter.setConsumeAWTEvent(false);
+ awtMouseAdapter.clear();
+ awtKeyAdapter.setConsumeAWTEvent(false);
+
if(null != keyboardFocusManager) {
keyboardFocusManager.removePropertyChangeListener("focusOwner", focusPropertyChangeListener);
keyboardFocusManager = null;
@@ -695,8 +705,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
throw new InternalError("XXX");
}
isOnscreen = jawtWindow.getGraphicsConfiguration().getChosenCapabilities().isOnscreen();
- awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter(jawtWindow, newtChild).addTo(this);
- awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction!
+ awtAdapter.setDownstream(jawtWindow, newtChild);
newtChild.addWindowListener(clearAWTMenusOnNewtFocus);
newtChild.setFocusAction(focusAction); // enable AWT focus traversal
newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE);
@@ -710,8 +719,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
newtChild.setKeyboardFocusHandler(newtFocusTraversalKeyListener);
} else {
// offscreen newt child requires AWT to fwd AWT key/mouse event
- awtMouseAdapter = new AWTMouseAdapter(newtChild).addTo(this);
- awtKeyAdapter = new AWTKeyAdapter(newtChild).addTo(this);
+ awtMouseAdapter.setDownstream(newtChild);
+ // We cannot consume AWT mouse click, since it would disable focus via mouse click!
+ // awtMouseAdapter.setConsumeAWTEvent(true);
+ awtKeyAdapter.setDownstream(newtChild);
+ // We manually transfer the focus via NEWT KeyListener, hence we can mark AWT keys as consumed!
+ awtKeyAdapter.setConsumeAWTEvent(true);
}
} else {
newtChild.removeWindowListener(clearAWTMenusOnNewtFocus);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java
index 29c3279aa..54842cd6e 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java
@@ -193,7 +193,7 @@ public class TestParentingFocus01SwingAWTRobot extends UITestCase {
}
System.err.println("FOCUS NEWT Canvas/GLWindow sync");
AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA);
- Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount());
+ Assert.assertEquals("AWT parent canvas received non consumed keyboard events", newtCanvasAWTKA.getConsumedCount(), newtCanvasAWTKA.getCount());
// Remove listeners to avoid logging during dispose/destroy.
glWindow1.removeKeyListener(glWindow1KA);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java
index aa02e096b..3aa952e30 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java
@@ -215,7 +215,7 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase {
Assert.assertEquals(false, buttonNorthInnerFA.focusGained());
System.err.println("FOCUS NEWT Canvas/GLWindow sync");
AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA);
- Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount());
+ Assert.assertEquals("AWT parent canvas received non consumed keyboard events", newtCanvasAWTKA.getConsumedCount(), newtCanvasAWTKA.getCount());
AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
glWindow1, glWindow1MA);
AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
@@ -253,7 +253,7 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase {
Assert.assertEquals(false, buttonNorthOuterFA.focusGained());
System.err.println("FOCUS NEWT Canvas/GLWindow sync");
AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA);
- Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount());
+ Assert.assertEquals("AWT parent canvas received non consumed keyboard events", newtCanvasAWTKA.getConsumedCount(), newtCanvasAWTKA.getCount());
AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1,
glWindow1, glWindow1MA);
AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,