aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes
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 /src/newt/classes
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.
Diffstat (limited to 'src/newt/classes')
-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
5 files changed, 188 insertions, 90 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);
}
}});
}