aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-11-18 13:36:54 +0100
committerSven Gothel <[email protected]>2013-11-18 13:36:54 +0100
commitead9d65722ac8c647ac1dde654fd4e8250e4d572 (patch)
treedbb4e705d43cec0d63e1a14f8f8f954e52bc73c5
parent97c8e627068af729d9ea0f7992b2bc5981655296 (diff)
NewtCanvasAWT: Add method of 'isAWTEventPassThrough()', used in unit tests to fix event validation for offscreen mode (OSX/CALayer)
-rw-r--r--make/scripts/tests.sh4
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java10
4 files changed, 27 insertions, 4 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 9510734a3..311bfd0a1 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -608,8 +608,8 @@ 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.TestParentingFocus02SwingAWTRobot $*
+#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 $*
#
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index f9f869781..5780f2540 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -735,6 +735,20 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
}
}
+ /**
+ * Returns <code>true</code> if Key and Mouse input events will be passed through AWT,
+ * otherwise only the {@link #getNEWTChild() NEWT child} will receive them.
+ * <p>
+ * Normally only the {@link #getNEWTChild() NEWT child} will receive Key and Mouse input events.
+ * In offscreen mode, e.g. OSX/CALayer, the AWT events will be received and translated into NEWT events
+ * and delivered to the NEWT child window.<br/>
+ * Note: AWT key events will {@link java.awt.event.InputEvent#consume() consumed} in pass-through mode.
+ * </p>
+ */
+ public final boolean isAWTEventPassThrough() {
+ return !isOnscreen;
+ }
+
private final void attachNewtChild() {
if( null == newtChild || null == jawtWindow || newtChildAttached ) {
return; // nop
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 54842cd6e..f45a48759 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
@@ -194,6 +194,9 @@ 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 non consumed keyboard events", newtCanvasAWTKA.getConsumedCount(), newtCanvasAWTKA.getCount());
+ if( !newtCanvasAWT.isAWTEventPassThrough() ) {
+ Assert.assertEquals("AWT parent canvas received consumed keyboard events", 0, newtCanvasAWTKA.getConsumedCount());
+ }
// 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 3aa952e30..909fadda7 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
@@ -220,7 +220,10 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase {
glWindow1, glWindow1MA);
AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
glWindow1, glWindow1MA);
- Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount());
+ if( !newtCanvasAWT.isAWTEventPassThrough() ) {
+ Assert.assertEquals("AWT parent canvas received consumed keyboard events", 0, newtCanvasAWTKA.getConsumedCount());
+ Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount());
+ }
// Button Inner Focus
Thread.sleep(100); // allow event sync
@@ -258,7 +261,10 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase {
glWindow1, glWindow1MA);
AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2,
glWindow1, glWindow1MA);
- Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount());
+ if( !newtCanvasAWT.isAWTEventPassThrough() ) {
+ Assert.assertEquals("AWT parent canvas received consumed keyboard events", 0, newtCanvasAWTKA.getConsumedCount());
+ Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount());
+ }
animator1.stop();
Assert.assertEquals(false, animator1.isAnimating());