aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-11-18 13:01:12 +0100
committerSven Gothel <[email protected]>2013-11-18 13:01:12 +0100
commit5c6c11abf643013976ecbc0df463a923a1f52696 (patch)
tree574f107b305e4790c34fd7dbf3ca7a04b57a9a23
parent23697c7921039e9655a5760e21d7029598b679d7 (diff)
NEWT AWTAdapter: Add notion of consuming the AWT InputEvent (will be used for key events); Allow AWTAdapter to be lazily setup w/ downstream object.
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java42
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java23
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java48
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java63
-rw-r--r--src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java102
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java35
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java35
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java15
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java39
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java33
10 files changed, 285 insertions, 150 deletions
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java
index e3bf18448..977b38dd0 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java
@@ -117,17 +117,19 @@ public abstract class AWTAdapter implements java.util.EventListener
com.jogamp.newt.event.NEWTEventListener newtListener;
com.jogamp.newt.Window newtWindow;
+ boolean consumeAWTEvent;
/**
* Simply wrap aroung a NEWT EventListener, exposed as an AWT EventListener.<br>
* The NEWT EventListener will be called when an event happens.<br>
*/
- public AWTAdapter(com.jogamp.newt.event.NEWTEventListener newtListener) {
+ protected AWTAdapter(com.jogamp.newt.event.NEWTEventListener newtListener) {
if(null==newtListener) {
throw new RuntimeException("Argument newtListener is null");
}
this.newtListener = newtListener;
this.newtWindow = null;
+ this.consumeAWTEvent = false;
}
/**
@@ -135,7 +137,7 @@ public abstract class AWTAdapter implements java.util.EventListener
* where the given NEWT Window impersonates as the event's source.
* The NEWT EventListener will be called when an event happens.<br>
*/
- public AWTAdapter(com.jogamp.newt.event.NEWTEventListener newtListener, com.jogamp.newt.Window newtProxy) {
+ protected AWTAdapter(com.jogamp.newt.event.NEWTEventListener newtListener, com.jogamp.newt.Window newtProxy) {
if(null==newtListener) {
throw new RuntimeException("Argument newtListener is null");
}
@@ -144,6 +146,7 @@ public abstract class AWTAdapter implements java.util.EventListener
}
this.newtListener = newtListener;
this.newtWindow = newtProxy;
+ this.consumeAWTEvent = false;
}
/**
@@ -151,22 +154,51 @@ public abstract class AWTAdapter implements java.util.EventListener
* Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream window.<br>
* This is only supported with EDT enabled!
*/
- public AWTAdapter(com.jogamp.newt.Window downstream) {
+ protected AWTAdapter(com.jogamp.newt.Window downstream) {
+ this();
+ setDownstream(downstream);
+ }
+
+ public AWTAdapter() {
+ this.newtListener = null;
+ this.newtWindow = null;
+ this.consumeAWTEvent = false;
+ }
+
+ /**
+ * Setup a pipeline adapter, AWT EventListener.<br>
+ * Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream window.<br>
+ * This is only supported with EDT enabled!
+ */
+ public synchronized AWTAdapter setDownstream(com.jogamp.newt.Window downstream) {
if(null==downstream) {
throw new RuntimeException("Argument downstream is null");
}
this.newtListener = null;
this.newtWindow = downstream;
+ this.consumeAWTEvent = false;
if( null == newtWindow.getScreen().getDisplay().getEDTUtil() ) {
throw new RuntimeException("EDT not enabled");
}
+ return this;
+ }
+
+ /** Removes all references, downstream and NEWT-EventListener. */
+ public synchronized AWTAdapter clear() {
+ this.newtListener = null;
+ this.newtWindow = null;
+ return this;
+ }
+
+ public final synchronized void setConsumeAWTEvent(boolean v) {
+ this.consumeAWTEvent = v;
}
- public final com.jogamp.newt.Window getNewtWindow() {
+ public final synchronized com.jogamp.newt.Window getNewtWindow() {
return newtWindow;
}
- public final com.jogamp.newt.event.NEWTEventListener getNewtEventListener() {
+ public final synchronized com.jogamp.newt.event.NEWTEventListener getNewtEventListener() {
return newtListener;
}
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 f6f11b81f..e8545aa52 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
@@ -49,21 +49,28 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe
super(downstream);
}
+ public AWTKeyAdapter() {
+ super();
+ }
+
@Override
- public AWTAdapter addTo(java.awt.Component awtComponent) {
+ public synchronized AWTAdapter addTo(java.awt.Component awtComponent) {
awtComponent.addKeyListener(this);
return this;
}
@Override
- public AWTAdapter removeFrom(java.awt.Component awtComponent) {
+ public synchronized AWTAdapter removeFrom(java.awt.Component awtComponent) {
awtComponent.removeKeyListener(this);
return this;
}
@Override
- public void keyPressed(java.awt.event.KeyEvent e) {
+ public synchronized void keyPressed(java.awt.event.KeyEvent e) {
final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, e, newtWindow);
+ if( consumeAWTEvent ) {
+ e.consume();
+ }
if(null!=newtListener) {
((com.jogamp.newt.event.KeyListener)newtListener).keyPressed(event);
} else {
@@ -72,8 +79,11 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe
}
@Override
- public void keyReleased(java.awt.event.KeyEvent e) {
+ public synchronized void keyReleased(java.awt.event.KeyEvent e) {
final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow);
+ if( consumeAWTEvent ) {
+ e.consume();
+ }
if(null!=newtListener) {
((com.jogamp.newt.event.KeyListener)newtListener).keyReleased(event);
} else {
@@ -82,7 +92,10 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe
}
@Override
- public void keyTyped(java.awt.event.KeyEvent e) {
+ public synchronized void keyTyped(java.awt.event.KeyEvent e) {
+ if( consumeAWTEvent ) {
+ e.consume();
+ }
}
}
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java
index 73a02c9fc..365bc4e2a 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java
@@ -46,8 +46,12 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
super(downstream);
}
+ public AWTMouseAdapter() {
+ super();
+ }
+
@Override
- public AWTAdapter addTo(java.awt.Component awtComponent) {
+ public synchronized AWTAdapter addTo(java.awt.Component awtComponent) {
awtComponent.addMouseListener(this);
awtComponent.addMouseMotionListener(this);
awtComponent.addMouseWheelListener(this);
@@ -55,7 +59,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
}
@Override
- public AWTAdapter removeFrom(java.awt.Component awtComponent) {
+ public synchronized AWTAdapter removeFrom(java.awt.Component awtComponent) {
awtComponent.removeMouseListener(this);
awtComponent.removeMouseMotionListener(this);
awtComponent.removeMouseWheelListener(this);
@@ -63,8 +67,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
}
@Override
- public void mouseClicked(java.awt.event.MouseEvent e) {
+ public synchronized void mouseClicked(java.awt.event.MouseEvent e) {
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if( consumeAWTEvent ) {
+ e.consume();
+ }
if(null!=newtListener) {
((com.jogamp.newt.event.MouseListener)newtListener).mouseClicked(event);
} else {
@@ -73,8 +80,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
}
@Override
- public void mouseEntered(java.awt.event.MouseEvent e) {
+ public synchronized void mouseEntered(java.awt.event.MouseEvent e) {
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if( consumeAWTEvent ) {
+ e.consume();
+ }
if(null!=newtListener) {
((com.jogamp.newt.event.MouseListener)newtListener).mouseEntered(event);
} else {
@@ -83,8 +93,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
}
@Override
- public void mouseExited(java.awt.event.MouseEvent e) {
+ public synchronized void mouseExited(java.awt.event.MouseEvent e) {
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if( consumeAWTEvent ) {
+ e.consume();
+ }
if(null!=newtListener) {
((com.jogamp.newt.event.MouseListener)newtListener).mouseExited(event);
} else {
@@ -93,8 +106,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
}
@Override
- public void mousePressed(java.awt.event.MouseEvent e) {
+ public synchronized void mousePressed(java.awt.event.MouseEvent e) {
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if( consumeAWTEvent ) {
+ e.consume();
+ }
if(null!=newtListener) {
((com.jogamp.newt.event.MouseListener)newtListener).mousePressed(event);
} else {
@@ -103,8 +119,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
}
@Override
- public void mouseReleased(java.awt.event.MouseEvent e) {
+ public synchronized void mouseReleased(java.awt.event.MouseEvent e) {
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if( consumeAWTEvent ) {
+ e.consume();
+ }
if(null!=newtListener) {
((com.jogamp.newt.event.MouseListener)newtListener).mouseReleased(event);
} else {
@@ -113,8 +132,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
}
@Override
- public void mouseDragged(java.awt.event.MouseEvent e) {
+ public synchronized void mouseDragged(java.awt.event.MouseEvent e) {
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if( consumeAWTEvent ) {
+ e.consume();
+ }
if(null!=newtListener) {
((com.jogamp.newt.event.MouseListener)newtListener).mouseDragged(event);
} else {
@@ -123,8 +145,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
}
@Override
- public void mouseMoved(java.awt.event.MouseEvent e) {
+ public synchronized void mouseMoved(java.awt.event.MouseEvent e) {
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if( consumeAWTEvent ) {
+ e.consume();
+ }
if(null!=newtListener) {
((com.jogamp.newt.event.MouseListener)newtListener).mouseMoved(event);
} else {
@@ -133,8 +158,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
}
@Override
- public void mouseWheelMoved(java.awt.event.MouseWheelEvent e) {
+ public synchronized void mouseWheelMoved(java.awt.event.MouseWheelEvent e) {
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
+ if( consumeAWTEvent ) {
+ e.consume();
+ }
if(null!=newtListener) {
((com.jogamp.newt.event.MouseListener)newtListener).mouseWheelMoved(event);
} else {
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
index 8a9a2a49f..57821fcb1 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
@@ -49,16 +49,17 @@ public class AWTWindowAdapter
public AWTWindowAdapter(com.jogamp.newt.Window downstream) {
super(downstream);
}
+ public AWTWindowAdapter() {
+ super();
+ }
@Override
- public AWTAdapter addTo(java.awt.Component awtComponent) {
+ public synchronized AWTAdapter addTo(java.awt.Component awtComponent) {
java.awt.Window win = getWindow(awtComponent);
awtComponent.addComponentListener(this);
awtComponent.addFocusListener(this);
- if( null == windowClosingListener ) {
+ if( null != win && null == windowClosingListener ) {
windowClosingListener = new WindowClosingListener();
- }
- if( null != win ) {
win.addWindowListener(windowClosingListener);
}
if(awtComponent instanceof java.awt.Window) {
@@ -67,7 +68,7 @@ public class AWTWindowAdapter
return this;
}
- public AWTAdapter removeWindowClosingFrom(java.awt.Component awtComponent) {
+ public synchronized AWTAdapter removeWindowClosingFrom(java.awt.Component awtComponent) {
java.awt.Window win = getWindow(awtComponent);
if( null != win && null != windowClosingListener ) {
win.removeWindowListener(windowClosingListener);
@@ -76,7 +77,7 @@ public class AWTWindowAdapter
}
@Override
- public AWTAdapter removeFrom(java.awt.Component awtComponent) {
+ public synchronized AWTAdapter removeFrom(java.awt.Component awtComponent) {
awtComponent.removeFocusListener(this);
awtComponent.removeComponentListener(this);
removeWindowClosingFrom(awtComponent);
@@ -97,7 +98,7 @@ public class AWTWindowAdapter
}
@Override
- public void focusGained(java.awt.event.FocusEvent e) {
+ public synchronized void focusGained(java.awt.event.FocusEvent e) {
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: focusGained: "+e+" -> "+event);
@@ -110,7 +111,7 @@ public class AWTWindowAdapter
}
@Override
- public void focusLost(java.awt.event.FocusEvent e) {
+ public synchronized void focusLost(java.awt.event.FocusEvent e) {
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: focusLost: "+e+" -> "+event);
@@ -123,7 +124,7 @@ public class AWTWindowAdapter
}
@Override
- public void componentResized(java.awt.event.ComponentEvent e) {
+ public synchronized void componentResized(java.awt.event.ComponentEvent e) {
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(DEBUG_IMPLEMENTATION) {
final java.awt.Component c = e.getComponent();
@@ -148,7 +149,7 @@ public class AWTWindowAdapter
}
@Override
- public void componentMoved(java.awt.event.ComponentEvent e) {
+ public synchronized void componentMoved(java.awt.event.ComponentEvent e) {
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: componentMoved: "+e+" -> "+event);
@@ -161,7 +162,7 @@ public class AWTWindowAdapter
}
@Override
- public void componentShown(java.awt.event.ComponentEvent e) {
+ public synchronized void componentShown(java.awt.event.ComponentEvent e) {
final java.awt.Component comp = e.getComponent();
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: componentShown: "+comp);
@@ -179,7 +180,7 @@ public class AWTWindowAdapter
}
@Override
- public void componentHidden(java.awt.event.ComponentEvent e) {
+ public synchronized void componentHidden(java.awt.event.ComponentEvent e) {
final java.awt.Component comp = e.getComponent();
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: componentHidden: "+comp);
@@ -197,7 +198,7 @@ public class AWTWindowAdapter
}
@Override
- public void windowActivated(java.awt.event.WindowEvent e) {
+ public synchronized void windowActivated(java.awt.event.WindowEvent e) {
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(null!=newtListener) {
((com.jogamp.newt.event.WindowListener)newtListener).windowGainedFocus(event);
@@ -207,13 +208,13 @@ public class AWTWindowAdapter
}
@Override
- public void windowClosed(java.awt.event.WindowEvent e) { }
+ public synchronized void windowClosed(java.awt.event.WindowEvent e) { }
@Override
- public void windowClosing(java.awt.event.WindowEvent e) { }
+ public synchronized void windowClosing(java.awt.event.WindowEvent e) { }
@Override
- public void windowDeactivated(java.awt.event.WindowEvent e) {
+ public synchronized void windowDeactivated(java.awt.event.WindowEvent e) {
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(null!=newtListener) {
((com.jogamp.newt.event.WindowListener)newtListener).windowLostFocus(event);
@@ -223,31 +224,35 @@ public class AWTWindowAdapter
}
@Override
- public void windowDeiconified(java.awt.event.WindowEvent e) { }
+ public synchronized void windowDeiconified(java.awt.event.WindowEvent e) { }
@Override
- public void windowIconified(java.awt.event.WindowEvent e) { }
+ public synchronized void windowIconified(java.awt.event.WindowEvent e) { }
@Override
- public void windowOpened(java.awt.event.WindowEvent e) { }
+ public synchronized void windowOpened(java.awt.event.WindowEvent e) { }
class WindowClosingListener implements java.awt.event.WindowListener {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
- com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
- if(null!=newtListener) {
- ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyNotify(event);
- } else {
- enqueueEvent(true, event);
+ synchronized( AWTWindowAdapter.this ) {
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyNotify(event);
+ } else {
+ enqueueEvent(true, event);
+ }
}
}
@Override
public void windowClosed(java.awt.event.WindowEvent e) {
- com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
- if(null!=newtListener) {
- ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyed(event);
- } else {
- enqueueEvent(true, event);
+ synchronized( AWTWindowAdapter.this ) {
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyed(event);
+ } else {
+ enqueueEvent(true, event);
+ }
}
}
diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
index 4bcb0fc82..add2f291e 100644
--- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
+++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
@@ -50,95 +50,115 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt
super(downstream);
this.downstreamParent = downstreamParent;
}
+ public AWTParentWindowAdapter() {
+ super();
+ }
+ public AWTParentWindowAdapter setDownstream(NativeWindow downstreamParent, com.jogamp.newt.Window downstream) {
+ setDownstream(downstream);
+ this.downstreamParent = downstreamParent;
+ return this;
+ }
@Override
- public AWTAdapter addTo(java.awt.Component awtComponent) {
+ public synchronized AWTAdapter clear() {
+ super.clear();
+ this.downstreamParent = null;
+ return this;
+ }
+
+ @Override
+ public synchronized AWTAdapter addTo(java.awt.Component awtComponent) {
awtComponent.addHierarchyListener(this);
return super.addTo(awtComponent);
}
@Override
- public AWTAdapter removeFrom(java.awt.Component awtComponent) {
+ public synchronized AWTAdapter removeFrom(java.awt.Component awtComponent) {
awtComponent.removeHierarchyListener(this);
return super.removeFrom(awtComponent);
}
@Override
- public void focusGained(java.awt.event.FocusEvent e) {
+ public synchronized void focusGained(java.awt.event.FocusEvent e) {
// forward focus to NEWT child
final com.jogamp.newt.Window newtChild = getNewtWindow();
- final boolean isOnscreen = newtChild.isNativeValid() && newtChild.getGraphicsConfiguration().getChosenCapabilities().isOnscreen();
- final boolean isParent = downstreamParent == newtChild.getParent();
- final boolean isFullscreen = newtChild.isFullscreen();
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("AWT: focusGained: onscreen "+ isOnscreen+", "+e+", isParent: "+isParent+", isFS "+isFullscreen);
- }
- if(isParent) {
- if(isOnscreen && !isFullscreen) {
- KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
+ if( null != newtChild ) {
+ final boolean isOnscreen = newtChild.isNativeValid() && newtChild.getGraphicsConfiguration().getChosenCapabilities().isOnscreen();
+ final boolean isParent = downstreamParent == newtChild.getParent();
+ final boolean isFullscreen = newtChild.isFullscreen();
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("AWT: focusGained: onscreen "+ isOnscreen+", "+e+", isParent: "+isParent+", isFS "+isFullscreen);
+ }
+ if(isParent) {
+ if(isOnscreen && !isFullscreen) {
+ KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
+ }
+ newtChild.requestFocus(false);
}
- newtChild.requestFocus(false);
}
}
@Override
- public void focusLost(java.awt.event.FocusEvent e) {
+ public synchronized void focusLost(java.awt.event.FocusEvent e) {
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: focusLost: "+ e);
}
}
@Override
- public void componentResized(java.awt.event.ComponentEvent e) {
+ public synchronized void componentResized(java.awt.event.ComponentEvent e) {
// Need to resize the NEWT child window
// the resized event will be send via the native window feedback.
final java.awt.Component comp = e.getComponent();
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: componentResized: "+comp);
}
- final Window newtWindow = getNewtWindow();
- newtWindow.runOnEDTIfAvail(false, new Runnable() {
- @Override
- public void run() {
- int cw = comp.getWidth();
- int ch = comp.getHeight();
- if( 0 < cw && 0 < ch ) {
- if( newtWindow.getWidth() != cw || newtWindow.getHeight() != ch ) {
- newtWindow.setSize(cw, ch);
- if(comp.isVisible() != newtWindow.isVisible()) {
- newtWindow.setVisible(comp.isVisible());
+ final Window newtChild = getNewtWindow();
+ if( null != newtChild ) {
+ newtChild.runOnEDTIfAvail(false, new Runnable() {
+ @Override
+ public void run() {
+ int cw = comp.getWidth();
+ int ch = comp.getHeight();
+ if( 0 < cw && 0 < ch ) {
+ if( newtChild.getWidth() != cw || newtChild.getHeight() != ch ) {
+ newtChild.setSize(cw, ch);
+ if(comp.isVisible() != newtChild.isVisible()) {
+ newtChild.setVisible(comp.isVisible());
+ }
}
+ } else if(newtChild.isVisible()) {
+ newtChild.setVisible(false);
}
- } else if(newtWindow.isVisible()) {
- newtWindow.setVisible(false);
- }
- }});
+ }});
+ }
}
@Override
- public void componentMoved(java.awt.event.ComponentEvent e) {
+ public synchronized void componentMoved(java.awt.event.ComponentEvent e) {
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: componentMoved: "+e);
}
- final Window newtWindow = getNewtWindow();
- if(newtWindow.getDelegatedWindow() instanceof DriverUpdatePosition) {
- ((DriverUpdatePosition)newtWindow.getDelegatedWindow()).updatePosition(0, 0);
+ final Window newtChild = getNewtWindow();
+ if( null != newtChild && ( newtChild.getDelegatedWindow() instanceof DriverUpdatePosition ) ) {
+ ((DriverUpdatePosition)newtChild.getDelegatedWindow()).updatePosition(0, 0);
}
}
@Override
- public void windowActivated(java.awt.event.WindowEvent e) {
+ public synchronized void windowActivated(java.awt.event.WindowEvent e) {
// no propagation to NEWT child window
}
@Override
- public void windowDeactivated(java.awt.event.WindowEvent e) {
+ public synchronized void windowDeactivated(java.awt.event.WindowEvent e) {
// no propagation to NEWT child window
}
@Override
- public void hierarchyChanged(java.awt.event.HierarchyEvent e) {
- if( null == getNewtEventListener() ) {
+ public synchronized void hierarchyChanged(java.awt.event.HierarchyEvent e) {
+ final Window newtChild = getNewtWindow();
+ if( null != newtChild && null == getNewtEventListener() ) {
long bits = e.getChangeFlags();
final java.awt.Component changed = e.getChanged();
if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) {
@@ -146,11 +166,11 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: hierarchyChanged SHOWING_CHANGED: showing "+showing+", "+changed+", source "+e.getComponent());
}
- getNewtWindow().runOnEDTIfAvail(false, new Runnable() {
+ newtChild.runOnEDTIfAvail(false, new Runnable() {
@Override
public void run() {
- if(getNewtWindow().isVisible() != showing) {
- getNewtWindow().setVisible(showing);
+ if(newtChild.isVisible() != showing) {
+ newtChild.setVisible(showing);
}
}});
}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java
index 776c3c7eb..5ae473e18 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.util;
import java.awt.event.KeyEvent;
@@ -37,6 +37,7 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent
String prefix;
int keyPressed, keyReleased;
+ int consumed;
boolean pressed;
List<EventObject> queue = new ArrayList<EventObject>();
boolean verbose = true;
@@ -51,30 +52,35 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent
public synchronized boolean isPressed() {
return pressed;
}
-
+
public synchronized int getCount() {
return keyReleased;
}
+ public synchronized int getConsumedCount() {
+ return consumed;
+ }
+
public synchronized int getKeyPressedCount(boolean autoRepeatOnly) {
- return keyPressed;
+ return keyPressed;
}
-
+
public synchronized int getKeyReleasedCount(boolean autoRepeatOnly) {
- return keyReleased;
+ return keyReleased;
}
-
+
public synchronized List<EventObject> getQueued() {
return queue;
}
-
+
public synchronized int getQueueSize() {
return queue.size();
}
-
+
public synchronized void reset() {
keyPressed = 0;
keyReleased = 0;
+ consumed = 0;
pressed = false;
queue.clear();
}
@@ -91,12 +97,15 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent
public synchronized void keyReleased(KeyEvent e) {
pressed = false;
keyReleased++;
+ if(e.isConsumed()) {
+ consumed++;
+ }
queue.add(e);
if( verbose ) {
System.err.println("KEY AWT RELEASED ["+pressed+"]: "+prefix+", "+e);
}
}
- public String toString() { return prefix+"[pressed "+pressed+", keyReleased "+keyReleased+"]"; }
+ public String toString() { return prefix+"[pressed "+pressed+", keyReleased "+keyReleased+", consumed "+consumed+"]"; }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java
index 31362bfa1..f6cbd0a04 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.util;
import java.awt.event.MouseEvent;
@@ -36,6 +36,7 @@ import java.util.List;
public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements InputEventCountAdapter {
String prefix;
int mouseClicked;
+ int consumed;
boolean pressed;
List<EventObject> queue = new ArrayList<EventObject>();
boolean verbose = true;
@@ -46,25 +47,30 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu
}
public synchronized void setVerbose(boolean v) { verbose = false; }
-
+
public synchronized boolean isPressed() {
return pressed;
}
-
+
public synchronized int getCount() {
return mouseClicked;
}
-
+
+ public synchronized int getConsumedCount() {
+ return consumed;
+ }
+
public synchronized List<EventObject> getQueued() {
return queue;
}
-
+
public synchronized int getQueueSize() {
return queue.size();
}
public synchronized void reset() {
mouseClicked = 0;
+ consumed = 0;
pressed = false;
queue.clear();
}
@@ -84,15 +90,18 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu
System.err.println("MOUSE AWT RELEASED ["+pressed+"]: "+prefix+", "+e);
}
}
-
+
public synchronized void mouseClicked(java.awt.event.MouseEvent e) {
mouseClicked+=e.getClickCount();
+ if(e.isConsumed()) {
+ consumed++;
+ }
queue.add(e);
if( verbose ) {
System.err.println("MOUSE AWT CLICKED ["+mouseClicked+"]: "+prefix+", "+e);
}
- }
-
- public String toString() { return prefix+"[pressed "+pressed+", clicked "+mouseClicked+"]"; }
+ }
+
+ public String toString() { return prefix+"[pressed "+pressed+", clicked "+mouseClicked+", consumed "+consumed+"]"; }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java
index c4078436f..1804b9cb6 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,22 +20,23 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.util;
import java.util.EventObject;
import java.util.List;
public interface InputEventCountAdapter extends EventCountAdapter {
+ int getConsumedCount();
int getCount();
boolean isPressed();
-
- public List<EventObject> getQueued();
+
+ public List<EventObject> getQueued();
public int getQueueSize();
}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java
index d143b3ca1..5242da637 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.util;
import java.util.ArrayList;
@@ -41,6 +41,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter {
String prefix;
int keyPressed, keyReleased;
int keyPressedAR, keyReleasedAR;
+ int consumed;
boolean pressed;
List<EventObject> queue = new ArrayList<EventObject>();
boolean verbose = true;
@@ -49,29 +50,33 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter {
this.prefix = prefix;
reset();
}
-
+
public synchronized void setVerbose(boolean v) { verbose = false; }
public synchronized boolean isPressed() {
return pressed;
}
-
+
public synchronized int getCount() {
return keyReleased;
}
+ public synchronized int getConsumedCount() {
+ return consumed;
+ }
+
public synchronized int getKeyPressedCount(boolean autoRepeatOnly) {
- return autoRepeatOnly ? keyPressedAR: keyPressed;
+ return autoRepeatOnly ? keyPressedAR: keyPressed;
}
-
+
public synchronized int getKeyReleasedCount(boolean autoRepeatOnly) {
- return autoRepeatOnly ? keyReleasedAR: keyReleased;
+ return autoRepeatOnly ? keyReleasedAR: keyReleased;
}
-
+
public synchronized List<EventObject> getQueued() {
return queue;
}
-
+
public synchronized int getQueueSize() {
return queue.size();
}
@@ -79,6 +84,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter {
public synchronized void reset() {
keyPressed = 0;
keyReleased = 0;
+ consumed = 0;
keyPressedAR = 0;
keyReleasedAR = 0;
pressed = false;
@@ -96,10 +102,13 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter {
System.err.println("KEY NEWT PRESSED ["+pressed+"]: "+prefix+", "+e);
}
}
-
+
public synchronized void keyReleased(KeyEvent e) {
pressed = false;
keyReleased++;
+ if(e.isConsumed()) {
+ consumed++;
+ }
if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) {
keyReleasedAR++;
}
@@ -108,7 +117,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter {
System.err.println("KEY NEWT RELEASED ["+pressed+"]: "+prefix+", "+e);
}
}
-
- public String toString() { return prefix+"[pressed "+pressed+", keyReleased "+keyReleased+"]"; }
+
+ public String toString() { return prefix+"[pressed "+pressed+", keyReleased "+keyReleased+", consumed "+consumed+"]"; }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java
index 644523782..6850fcf47 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.test.junit.util;
import java.util.ArrayList;
@@ -39,6 +39,7 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda
String prefix;
int mouseClicked;
+ int consumed;
boolean pressed;
List<EventObject> queue = new ArrayList<EventObject>();
boolean verbose = true;
@@ -49,25 +50,30 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda
}
public synchronized void setVerbose(boolean v) { verbose = false; }
-
+
public synchronized boolean isPressed() {
return pressed;
}
-
+
public synchronized int getCount() {
return mouseClicked;
}
+ public synchronized int getConsumedCount() {
+ return consumed;
+ }
+
public synchronized List<EventObject> getQueued() {
return queue;
}
-
+
public synchronized int getQueueSize() {
return queue.size();
}
public synchronized void reset() {
mouseClicked = 0;
+ consumed = 0;
pressed = false;
queue.clear();
}
@@ -79,7 +85,7 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda
System.err.println("MOUSE NEWT PRESSED ["+pressed+"]: "+prefix+", "+e);
}
}
-
+
public synchronized void mouseReleased(MouseEvent e) {
pressed = false;
queue.add(e);
@@ -87,15 +93,18 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda
System.err.println("MOUSE NEWT RELEASED ["+pressed+"]: "+prefix+", "+e);
}
}
-
+
public synchronized void mouseClicked(MouseEvent e) {
mouseClicked+=e.getClickCount();
+ if(e.isConsumed()) {
+ consumed++;
+ }
queue.add(e);
if( verbose ) {
System.err.println("MOUSE NEWT CLICKED ["+mouseClicked+"]: "+prefix+", "+e);
}
}
-
- public String toString() { return prefix+"[pressed "+pressed+", clicked "+mouseClicked+"]"; }
+
+ public String toString() { return prefix+"[pressed "+pressed+", clicked "+mouseClicked+", consumed "+consumed+"]"; }
}