aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java8
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java3
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java8
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java10
-rw-r--r--src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java5
5 files changed, 32 insertions, 2 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 977b38dd0..864db1f7b 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java
@@ -118,6 +118,7 @@ public abstract class AWTAdapter implements java.util.EventListener
com.jogamp.newt.event.NEWTEventListener newtListener;
com.jogamp.newt.Window newtWindow;
boolean consumeAWTEvent;
+ protected boolean isSetup;
/**
* Simply wrap aroung a NEWT EventListener, exposed as an AWT EventListener.<br>
@@ -130,6 +131,7 @@ public abstract class AWTAdapter implements java.util.EventListener
this.newtListener = newtListener;
this.newtWindow = null;
this.consumeAWTEvent = false;
+ this.isSetup = true;
}
/**
@@ -147,6 +149,7 @@ public abstract class AWTAdapter implements java.util.EventListener
this.newtListener = newtListener;
this.newtWindow = newtProxy;
this.consumeAWTEvent = false;
+ this.isSetup = true;
}
/**
@@ -160,8 +163,7 @@ public abstract class AWTAdapter implements java.util.EventListener
}
public AWTAdapter() {
- this.newtListener = null;
- this.newtWindow = null;
+ clear();
this.consumeAWTEvent = false;
}
@@ -180,6 +182,7 @@ public abstract class AWTAdapter implements java.util.EventListener
if( null == newtWindow.getScreen().getDisplay().getEDTUtil() ) {
throw new RuntimeException("EDT not enabled");
}
+ this.isSetup = true;
return this;
}
@@ -187,6 +190,7 @@ public abstract class AWTAdapter implements java.util.EventListener
public synchronized AWTAdapter clear() {
this.newtListener = null;
this.newtWindow = null;
+ this.isSetup = false;
return this;
}
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 e8545aa52..d4226f53e 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
@@ -67,6 +67,7 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe
@Override
public synchronized void keyPressed(java.awt.event.KeyEvent e) {
+ if( !isSetup ) { return; }
final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, e, newtWindow);
if( consumeAWTEvent ) {
e.consume();
@@ -80,6 +81,7 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe
@Override
public synchronized void keyReleased(java.awt.event.KeyEvent e) {
+ if( !isSetup ) { return; }
final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow);
if( consumeAWTEvent ) {
e.consume();
@@ -93,6 +95,7 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe
@Override
public synchronized void keyTyped(java.awt.event.KeyEvent e) {
+ if( !isSetup ) { return; }
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 365bc4e2a..8ad1fa6ab 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java
@@ -68,6 +68,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
@Override
public synchronized void mouseClicked(java.awt.event.MouseEvent e) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
if( consumeAWTEvent ) {
e.consume();
@@ -81,6 +82,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
@Override
public synchronized void mouseEntered(java.awt.event.MouseEvent e) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
if( consumeAWTEvent ) {
e.consume();
@@ -94,6 +96,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
@Override
public synchronized void mouseExited(java.awt.event.MouseEvent e) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
if( consumeAWTEvent ) {
e.consume();
@@ -107,6 +110,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
@Override
public synchronized void mousePressed(java.awt.event.MouseEvent e) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
if( consumeAWTEvent ) {
e.consume();
@@ -120,6 +124,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
@Override
public synchronized void mouseReleased(java.awt.event.MouseEvent e) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
if( consumeAWTEvent ) {
e.consume();
@@ -133,6 +138,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
@Override
public synchronized void mouseDragged(java.awt.event.MouseEvent e) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
if( consumeAWTEvent ) {
e.consume();
@@ -146,6 +152,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
@Override
public synchronized void mouseMoved(java.awt.event.MouseEvent e) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
if( consumeAWTEvent ) {
e.consume();
@@ -159,6 +166,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL
@Override
public synchronized void mouseWheelMoved(java.awt.event.MouseWheelEvent e) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow);
if( consumeAWTEvent ) {
e.consume();
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 57821fcb1..2e5527ee1 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
@@ -99,6 +99,7 @@ public class AWTWindowAdapter
@Override
public synchronized void focusGained(java.awt.event.FocusEvent e) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: focusGained: "+e+" -> "+event);
@@ -112,6 +113,7 @@ public class AWTWindowAdapter
@Override
public synchronized void focusLost(java.awt.event.FocusEvent e) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: focusLost: "+e+" -> "+event);
@@ -125,6 +127,7 @@ public class AWTWindowAdapter
@Override
public synchronized void componentResized(java.awt.event.ComponentEvent e) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(DEBUG_IMPLEMENTATION) {
final java.awt.Component c = e.getComponent();
@@ -150,6 +153,7 @@ public class AWTWindowAdapter
@Override
public synchronized void componentMoved(java.awt.event.ComponentEvent e) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: componentMoved: "+e+" -> "+event);
@@ -163,6 +167,7 @@ public class AWTWindowAdapter
@Override
public synchronized void componentShown(java.awt.event.ComponentEvent e) {
+ if( !isSetup ) { return; }
final java.awt.Component comp = e.getComponent();
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: componentShown: "+comp);
@@ -181,6 +186,7 @@ public class AWTWindowAdapter
@Override
public synchronized void componentHidden(java.awt.event.ComponentEvent e) {
+ if( !isSetup ) { return; }
final java.awt.Component comp = e.getComponent();
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: componentHidden: "+comp);
@@ -199,6 +205,7 @@ public class AWTWindowAdapter
@Override
public synchronized void windowActivated(java.awt.event.WindowEvent e) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(null!=newtListener) {
((com.jogamp.newt.event.WindowListener)newtListener).windowGainedFocus(event);
@@ -215,6 +222,7 @@ public class AWTWindowAdapter
@Override
public synchronized void windowDeactivated(java.awt.event.WindowEvent e) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(null!=newtListener) {
((com.jogamp.newt.event.WindowListener)newtListener).windowLostFocus(event);
@@ -236,6 +244,7 @@ public class AWTWindowAdapter
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
synchronized( AWTWindowAdapter.this ) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(null!=newtListener) {
((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyNotify(event);
@@ -247,6 +256,7 @@ public class AWTWindowAdapter
@Override
public void windowClosed(java.awt.event.WindowEvent e) {
synchronized( AWTWindowAdapter.this ) {
+ if( !isSetup ) { return; }
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(null!=newtListener) {
((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyed(event);
diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
index add2f291e..e152d96d5 100644
--- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
+++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
@@ -80,6 +80,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt
@Override
public synchronized void focusGained(java.awt.event.FocusEvent e) {
+ if( !isSetup ) { return; }
// forward focus to NEWT child
final com.jogamp.newt.Window newtChild = getNewtWindow();
if( null != newtChild ) {
@@ -100,6 +101,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt
@Override
public synchronized void focusLost(java.awt.event.FocusEvent e) {
+ if( !isSetup ) { return; }
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: focusLost: "+ e);
}
@@ -107,6 +109,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt
@Override
public synchronized void componentResized(java.awt.event.ComponentEvent e) {
+ if( !isSetup ) { return; }
// 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();
@@ -136,6 +139,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt
@Override
public synchronized void componentMoved(java.awt.event.ComponentEvent e) {
+ if( !isSetup ) { return; }
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: componentMoved: "+e);
}
@@ -157,6 +161,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt
@Override
public synchronized void hierarchyChanged(java.awt.event.HierarchyEvent e) {
+ if( !isSetup ) { return; }
final Window newtChild = getNewtWindow();
if( null != newtChild && null == getNewtEventListener() ) {
long bits = e.getChangeFlags();