From ebe980ad6ac40148bc84913d1ba1f7adf6200490 Mon Sep 17 00:00:00 2001
From: Sven Gothel
+ * Returns the underlying {@link NativeSurface} which {@link NativeSurface#getSurfaceHandle() native handle}
* represents this OpenGL drawable's native resource.
+ *
+ * Returns this instance, which is-a {@link NativeSurface}. + *
+ */ + @Override + public NativeSurface getNativeSurface(); /** * Destroys this window incl. releasing all related resources. diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java index b93cbe7f5..403ec83c0 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java @@ -2,6 +2,7 @@ package jogamp.nativewindow; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.UpstreamSurfaceHook; @@ -65,6 +66,9 @@ public class WrappedWindow extends WrappedSurface implements NativeWindow { destroyNotify(); } + @Override + public final NativeSurface getNativeSurface() { return this; } + @Override public NativeWindow getParent() { return null; diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index f6b2bab1f..37e9f9813 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -104,7 +104,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private boolean newtChildAttached = false; private boolean isOnscreen = true; private WindowClosingMode newtChildCloseOp; - private final AWTParentWindowAdapter awtAdapter; + private final AWTParentWindowAdapter awtWinAdapter; private final AWTAdapter awtMouseAdapter; private final AWTAdapter awtKeyAdapter; @@ -140,8 +140,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto 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! + awtWinAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtWinAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! } /** @@ -151,8 +151,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto 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! + awtWinAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtWinAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! } /** @@ -162,8 +162,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto 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! + awtWinAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtWinAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! setNEWTChild(child); } @@ -174,8 +174,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto 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! + awtWinAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtWinAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! setNEWTChild(child); } @@ -779,11 +779,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } private final void configureNewtChild(boolean attach) { - awtAdapter.clear(); + awtWinAdapter.clear(); + awtKeyAdapter.clear(); awtMouseAdapter.clear(); - awtKeyAdapter.setConsumeAWTEvent(false); - awtMouseAdapter.clear(); - awtKeyAdapter.setConsumeAWTEvent(false); if(null != keyboardFocusManager) { keyboardFocusManager.removePropertyChangeListener("focusOwner", focusPropertyChangeListener); @@ -797,7 +795,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto throw new InternalError("XXX"); } isOnscreen = jawtWindow.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); - awtAdapter.setDownstream(jawtWindow, newtChild); + awtWinAdapter.setDownstream(jawtWindow, newtChild); newtChild.addWindowListener(clearAWTMenusOnNewtFocus); newtChild.setFocusAction(focusAction); // enable AWT focus traversal newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); 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 cf533eb9e..9b1348288 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java @@ -28,6 +28,8 @@ package com.jogamp.newt.event.awt; +import javax.media.nativewindow.NativeSurfaceHolder; + import jogamp.newt.Debug; /** @@ -117,37 +119,44 @@ public abstract class AWTAdapter implements java.util.EventListener com.jogamp.newt.event.NEWTEventListener newtListener; com.jogamp.newt.Window newtWindow; + NativeSurfaceHolder nsHolder; boolean consumeAWTEvent; protected boolean isSetup; /** - * Simply wrap aroung a NEWT EventListener, exposed as an AWT EventListener.
+ * Also sets the internal setup
flag and {@link #setConsumeAWTEvent(boolean)} to false
.
+ *
+ * Returned value is never null. + *
+ */ + public final synchronized NativeSurfaceHolder getNativeSurfaceHolder() { + return nsHolder; + } + + /** + * Returns the {@link com.jogamp.newt.Window NEWT Window} acting {@link #AWTAdapter(com.jogamp.newt.Window) as downstream} + * or as a {@link #AWTAdapter(com.jogamp.newt.event.NEWTEventListener, com.jogamp.newt.Window) NEWT window proxy}. + *+ * Returned value maybe null if instance is used to be a + * {@link #AWTAdapter(com.jogamp.newt.event.NEWTEventListener, NativeSurfaceHolder) NativeSurfaceHolder proxy}. + *
+ */ public final synchronized com.jogamp.newt.Window getNewtWindow() { return newtWindow; } + /** + * Returns the {@link com.jogamp.newt.event.NEWTEventListener NEWT event-listener} if instance + * is used as an {@link #AWTAdapter(com.jogamp.newt.event.NEWTEventListener, NativeSurfaceHolder) NativeSurfaceHolder proxy} + * or {@link #AWTAdapter(com.jogamp.newt.event.NEWTEventListener, com.jogamp.newt.Window) NEWT window proxy}, + * otherwise method returnsnull
.
+ */
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 ddbeb6e42..5ea36bac8 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
@@ -28,6 +28,8 @@
package com.jogamp.newt.event.awt;
+import javax.media.nativewindow.NativeSurfaceHolder;
+
import jogamp.newt.awt.event.AWTNewtEventFactory;
/**
@@ -37,8 +39,8 @@ import jogamp.newt.awt.event.AWTNewtEventFactory;
*/
public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListener
{
- public AWTKeyAdapter(com.jogamp.newt.event.KeyListener newtListener) {
- super(newtListener);
+ public AWTKeyAdapter(com.jogamp.newt.event.KeyListener newtListener, NativeSurfaceHolder nsProxy) {
+ super(newtListener, nsProxy);
}
public AWTKeyAdapter(com.jogamp.newt.event.KeyListener newtListener, com.jogamp.newt.Window newtProxy) {
@@ -68,7 +70,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);
+ final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, e, nsHolder);
if( consumeAWTEvent ) {
e.consume();
}
@@ -80,7 +82,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);
+ final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, nsHolder);
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 d0f73ef33..53fe70bf7 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java
@@ -28,14 +28,16 @@
package com.jogamp.newt.event.awt;
+import javax.media.nativewindow.NativeSurfaceHolder;
+
import jogamp.newt.awt.event.AWTNewtEventFactory;
public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseListener,
java.awt.event.MouseMotionListener,
java.awt.event.MouseWheelListener
{
- public AWTMouseAdapter(com.jogamp.newt.event.MouseListener newtListener) {
- super(newtListener);
+ public AWTMouseAdapter(com.jogamp.newt.event.MouseListener newtListener, NativeSurfaceHolder nsProxy) {
+ super(newtListener, nsProxy);
}
public AWTMouseAdapter(com.jogamp.newt.event.MouseListener newtListener, com.jogamp.newt.Window newtProxy) {
@@ -69,7 +71,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);
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
if( consumeAWTEvent ) {
e.consume();
}
@@ -81,7 +83,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);
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
if( consumeAWTEvent ) {
e.consume();
}
@@ -93,7 +95,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);
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
if( consumeAWTEvent ) {
e.consume();
}
@@ -105,7 +107,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);
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
if( consumeAWTEvent ) {
e.consume();
}
@@ -117,7 +119,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);
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
if( consumeAWTEvent ) {
e.consume();
}
@@ -129,7 +131,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);
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
if( consumeAWTEvent ) {
e.consume();
}
@@ -141,7 +143,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);
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
if( consumeAWTEvent ) {
e.consume();
}
@@ -153,7 +155,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);
+ com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, nsHolder);
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 43a28b3b3..698fe86f4 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
@@ -30,6 +30,8 @@ package com.jogamp.newt.event.awt;
import java.awt.Dimension;
+import javax.media.nativewindow.NativeSurfaceHolder;
+
import jogamp.newt.awt.event.AWTNewtEventFactory;
public class AWTWindowAdapter
@@ -38,8 +40,8 @@ public class AWTWindowAdapter
{
WindowClosingListener windowClosingListener;
- public AWTWindowAdapter(com.jogamp.newt.event.WindowListener newtListener) {
- super(newtListener);
+ public AWTWindowAdapter(com.jogamp.newt.event.WindowListener newtListener, NativeSurfaceHolder nsProxy) {
+ super(newtListener, nsProxy);
}
public AWTWindowAdapter(com.jogamp.newt.event.WindowListener newtListener, com.jogamp.newt.Window newtProxy) {
@@ -49,6 +51,7 @@ public class AWTWindowAdapter
public AWTWindowAdapter(com.jogamp.newt.Window downstream) {
super(downstream);
}
+
public AWTWindowAdapter() {
super();
}
@@ -100,7 +103,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);
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder);
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: focusGained: "+e+" -> "+event);
}
@@ -112,7 +115,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);
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder);
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: focusLost: "+e+" -> "+event);
}
@@ -124,7 +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);
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder);
if(DEBUG_IMPLEMENTATION) {
final java.awt.Component c = e.getComponent();
final java.awt.Dimension sz = c.getSize();
@@ -148,7 +151,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);
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder);
if(DEBUG_IMPLEMENTATION) {
System.err.println("AWT: componentMoved: "+e+" -> "+event);
}
@@ -198,7 +201,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);
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder);
if( EventProcRes.DISPATCH == processEvent(false, event) ) {
((com.jogamp.newt.event.WindowListener)newtListener).windowGainedFocus(event);
}
@@ -213,7 +216,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);
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder);
if( EventProcRes.DISPATCH == processEvent(false, event) ) {
((com.jogamp.newt.event.WindowListener)newtListener).windowLostFocus(event);
}
@@ -233,7 +236,7 @@ public class AWTWindowAdapter
public void windowClosing(java.awt.event.WindowEvent e) {
synchronized( AWTWindowAdapter.this ) {
if( !isSetup ) { return; }
- com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder);
if( EventProcRes.DISPATCH == processEvent(true, event) ) {
((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyNotify(event);
}
@@ -243,7 +246,7 @@ public class AWTWindowAdapter
public void windowClosed(java.awt.event.WindowEvent e) {
synchronized( AWTWindowAdapter.this ) {
if( !isSetup ) { return; }
- com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, nsHolder);
if( EventProcRes.DISPATCH == processEvent(true, event) ) {
((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyed(event);
}
diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
index 93ecc8bb2..674d467f9 100644
--- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
+++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
@@ -547,6 +547,9 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol {
return clientArea.height;
}
+ @Override
+ public final NativeSurface getNativeSurface() { return this; }
+
@Override
public AbstractGraphicsConfiguration getGraphicsConfiguration() {
return config;
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 2411f6595..5288bfcc5 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -853,6 +853,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// public final void destroy() - see below
+ @Override
+ public final NativeSurface getNativeSurface() { return this; }
+
@Override
public final NativeWindow getParent() {
return parentWindow;
diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
index 709143b82..b04fd98f4 100644
--- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
@@ -28,6 +28,9 @@
package jogamp.newt.awt.event;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeSurfaceHolder;
+
import com.jogamp.newt.event.MouseEvent;
/**
@@ -590,31 +593,31 @@ public class AWTNewtEventFactory {
return defAwtKeyCode;
}
- public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.WindowEvent event, com.jogamp.newt.Window newtSource) {
+ public static final com.jogamp.newt.event.WindowEvent createWindowEvent(final java.awt.event.WindowEvent event, final NativeSurfaceHolder sourceHolder) {
final short newtType = eventTypeAWT2NEWT(event.getID());
if( (short)0 != newtType ) {
- return new com.jogamp.newt.event.WindowEvent(newtType, ((null==newtSource)?(Object)event.getComponent():(Object)newtSource), System.currentTimeMillis());
+ return new com.jogamp.newt.event.WindowEvent(newtType, sourceHolder, System.currentTimeMillis());
}
return null; // no mapping ..
}
- public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.ComponentEvent event, com.jogamp.newt.Window newtSource) {
+ public static final com.jogamp.newt.event.WindowEvent createWindowEvent(final java.awt.event.ComponentEvent event, final NativeSurfaceHolder sourceHolder) {
final short newtType = eventTypeAWT2NEWT(event.getID());
if( (short)0 != newtType ) {
- return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis());
+ return new com.jogamp.newt.event.WindowEvent(newtType, sourceHolder, System.currentTimeMillis());
}
return null; // no mapping ..
}
- public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.FocusEvent event, com.jogamp.newt.Window newtSource) {
+ public static final com.jogamp.newt.event.WindowEvent createWindowEvent(final java.awt.event.FocusEvent event, final NativeSurfaceHolder sourceHolder) {
final short newtType = eventTypeAWT2NEWT(event.getID());
if( (short)0 != newtType ) {
- return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis());
+ return new com.jogamp.newt.event.WindowEvent(newtType, sourceHolder, System.currentTimeMillis());
}
return null; // no mapping ..
}
- public static final com.jogamp.newt.event.MouseEvent createMouseEvent(java.awt.event.MouseEvent event, com.jogamp.newt.Window newtSource) {
+ public static final com.jogamp.newt.event.MouseEvent createMouseEvent(final java.awt.event.MouseEvent event, final NativeSurfaceHolder sourceHolder) {
final short newtType = eventTypeAWT2NEWT(event.getID());
if( (short)0 != newtType ) {
float rotation = 0;
@@ -626,35 +629,40 @@ public class AWTNewtEventFactory {
final short newtButton = awtButton2Newt(event.getButton());
int mods = awtModifiers2Newt(event.getModifiers(), event.getModifiersEx());
mods |= com.jogamp.newt.event.InputEvent.getButtonMask(newtButton); // always include NEWT BUTTON_MASK
+ final NativeSurface source = sourceHolder.getNativeSurface();
final int[] pixelPos;
- if(null!=newtSource) {
- if(newtSource.isPointerConfined()) {
- mods |= com.jogamp.newt.event.InputEvent.CONFINED_MASK;
- }
- if(!newtSource.isPointerVisible()) {
- mods |= com.jogamp.newt.event.InputEvent.INVISIBLE_MASK;
+ if( null != source ) {
+ if( source instanceof com.jogamp.newt.Window ) {
+ final com.jogamp.newt.Window newtSource = (com.jogamp.newt.Window) source;
+ if(newtSource.isPointerConfined()) {
+ mods |= com.jogamp.newt.event.InputEvent.CONFINED_MASK;
+ }
+ if(!newtSource.isPointerVisible()) {
+ mods |= com.jogamp.newt.event.InputEvent.INVISIBLE_MASK;
+ }
}
- pixelPos = newtSource.convertToPixelUnits(new int[] { event.getX(), event.getY() });
+ pixelPos = source.convertToPixelUnits(new int[] { event.getX(), event.getY() });
} else {
pixelPos = new int[] { event.getX(), event.getY() };
}
+
return new com.jogamp.newt.event.MouseEvent(
- newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(),
+ newtType, sourceHolder, event.getWhen(),
mods, pixelPos[0], pixelPos[1], (short)event.getClickCount(),
newtButton, MouseEvent.getRotationXYZ(rotation, mods), 1f);
}
return null; // no mapping ..
}
- public static final com.jogamp.newt.event.KeyEvent createKeyEvent(java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) {
- return createKeyEvent(eventTypeAWT2NEWT(event.getID()), event, newtSource);
+ public static final com.jogamp.newt.event.KeyEvent createKeyEvent(final java.awt.event.KeyEvent event, final NativeSurfaceHolder sourceHolder) {
+ return createKeyEvent(eventTypeAWT2NEWT(event.getID()), event, sourceHolder);
}
- public static final com.jogamp.newt.event.KeyEvent createKeyEvent(short newtType, java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) {
+ public static final com.jogamp.newt.event.KeyEvent createKeyEvent(final short newtType, final java.awt.event.KeyEvent event, final NativeSurfaceHolder sourceHolder) {
if( (short)0 != newtType ) {
final short newtKeyCode = awtKeyCode2NewtKeyCode( event.getKeyCode() );
return com.jogamp.newt.event.KeyEvent.create(
- newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(),
+ newtType, sourceHolder, event.getWhen(),
awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()),
newtKeyCode, newtKeyCode, event.getKeyChar());
}
diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java
index b5c45c1aa..386149b22 100644
--- a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java
@@ -28,6 +28,9 @@
package jogamp.newt.swt.event;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeSurfaceHolder;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
@@ -134,7 +137,7 @@ public class SWTNewtEventFactory {
}
public static int newtKeyCode2SWTKeyCode(final short newtKeyCode) {
- final int defSWTKeyCode = 0xFFFF & (int)newtKeyCode;
+ final int defSWTKeyCode = 0xFFFF & newtKeyCode;
switch (newtKeyCode) {
case com.jogamp.newt.event.KeyEvent.VK_HOME : return SWT.HOME;
case com.jogamp.newt.event.KeyEvent.VK_END : return SWT.END;
@@ -199,15 +202,15 @@ public class SWTNewtEventFactory {
}
- public static final com.jogamp.newt.event.InputEvent createInputEvent(org.eclipse.swt.widgets.Event event, Object source) {
- com.jogamp.newt.event.InputEvent res = createMouseEvent(event, source);
+ public static final com.jogamp.newt.event.InputEvent createInputEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder) {
+ com.jogamp.newt.event.InputEvent res = createMouseEvent(event, sourceHolder);
if(null == res) {
- res = createKeyEvent(event, source);
+ res = createKeyEvent(event, sourceHolder);
}
return res;
}
- public static final com.jogamp.newt.event.MouseEvent createMouseEvent(org.eclipse.swt.widgets.Event event, Object source) {
+ public static final com.jogamp.newt.event.MouseEvent createMouseEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder) {
switch(event.type) {
case SWT.MouseDown:
case SWT.MouseUp:
@@ -230,24 +233,31 @@ public class SWTNewtEventFactory {
int mods = swtModifiers2Newt(event.stateMask, true);
- if( source instanceof com.jogamp.newt.Window) {
- final com.jogamp.newt.Window newtSource = (com.jogamp.newt.Window)source;
- if(newtSource.isPointerConfined()) {
- mods |= InputEvent.CONFINED_MASK;
- }
- if(!newtSource.isPointerVisible()) {
- mods |= InputEvent.INVISIBLE_MASK;
+ final NativeSurface source = sourceHolder.getNativeSurface();
+ final int[] pixelPos;
+ if( null != source ) {
+ if( source instanceof com.jogamp.newt.Window) {
+ final com.jogamp.newt.Window newtSource = (com.jogamp.newt.Window)source;
+ if(newtSource.isPointerConfined()) {
+ mods |= InputEvent.CONFINED_MASK;
+ }
+ if(!newtSource.isPointerVisible()) {
+ mods |= InputEvent.INVISIBLE_MASK;
+ }
}
+ pixelPos = source.convertToPixelUnits(new int[] { event.x, event.y });
+ } else {
+ pixelPos = new int[] { event.x, event.y };
}
return new com.jogamp.newt.event.MouseEvent(
- type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time),
- mods, event.x, event.y, (short)event.count, (short)event.button, MouseEvent.getRotationXYZ(rotation, mods), 1f);
+ type, sourceHolder, (0xFFFFFFFFL & event.time),
+ mods, pixelPos[0], pixelPos[1], (short)event.count, (short)event.button, MouseEvent.getRotationXYZ(rotation, mods), 1f);
}
return null; // no mapping ..
}
- public static final com.jogamp.newt.event.KeyEvent createKeyEvent(org.eclipse.swt.widgets.Event event, Object source) {
+ public static final com.jogamp.newt.event.KeyEvent createKeyEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder) {
switch(event.type) {
case SWT.KeyDown:
case SWT.KeyUp:
@@ -259,7 +269,7 @@ public class SWTNewtEventFactory {
if( (short)0 != type ) {
final short newtKeyCode = swtKeyCode2NewtKeyCode( event.keyCode );
return com.jogamp.newt.event.KeyEvent.create(
- type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time),
+ type, sourceHolder, (0xFFFFFFFFL & event.time),
swtModifiers2Newt(event.stateMask, false),
newtKeyCode, newtKeyCode, event.character);
}
@@ -280,8 +290,8 @@ public class SWTNewtEventFactory {
dragButtonDown = 0;
}
- public final boolean dispatchMouseEvent(org.eclipse.swt.widgets.Event event, Object source, com.jogamp.newt.event.MouseListener l) {
- com.jogamp.newt.event.MouseEvent res = createMouseEvent(event, source);
+ public final boolean dispatchMouseEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder, com.jogamp.newt.event.MouseListener l) {
+ com.jogamp.newt.event.MouseEvent res = createMouseEvent(event, sourceHolder);
if(null != res) {
if(null != l) {
switch(event.type) {
@@ -331,8 +341,8 @@ public class SWTNewtEventFactory {
return false;
}
- public final boolean dispatchKeyEvent(org.eclipse.swt.widgets.Event event, Object source, com.jogamp.newt.event.KeyListener l) {
- com.jogamp.newt.event.KeyEvent res = createKeyEvent(event, source);
+ public final boolean dispatchKeyEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder, com.jogamp.newt.event.KeyListener l) {
+ com.jogamp.newt.event.KeyEvent res = createKeyEvent(event, sourceHolder);
if(null != res) {
if(null != l) {
switch(event.type) {
@@ -349,27 +359,38 @@ public class SWTNewtEventFactory {
return false;
}
- public final void attachDispatchListener(final org.eclipse.swt.widgets.Control ctrl, final Object source,
+ public final void attachDispatchListener(final org.eclipse.swt.widgets.Control ctrl, final NativeSurfaceHolder sourceHolder,
final com.jogamp.newt.event.MouseListener ml,
final com.jogamp.newt.event.KeyListener kl) {
- final Listener listener = new Listener () {
- @Override
- public void handleEvent (Event event) {
- if( dispatchMouseEvent( event, source, ml ) ) {
- return;
- }
- if( dispatchKeyEvent( event, source, kl ) ) {
- return;
- }
- } };
- ctrl.addListener(SWT.MouseDown, listener);
- ctrl.addListener(SWT.MouseUp, listener);
- ctrl.addListener(SWT.MouseMove, listener);
- ctrl.addListener(SWT.MouseEnter, listener);
- ctrl.addListener(SWT.MouseExit, listener);
- ctrl.addListener(SWT.MouseVerticalWheel, listener);
- ctrl.addListener(SWT.KeyDown, listener);
- ctrl.addListener(SWT.KeyUp, listener);
+ if(null==ctrl) {
+ throw new IllegalArgumentException("Argument ctrl is null");
+ }
+ if(null==sourceHolder) {
+ throw new IllegalArgumentException("Argument source is null");
+ }
+
+ if( null != ml ) {
+ final Listener listener = new Listener () {
+ @Override
+ public void handleEvent (Event event) {
+ dispatchMouseEvent( event, sourceHolder, ml );
+ } };
+ ctrl.addListener(SWT.MouseDown, listener);
+ ctrl.addListener(SWT.MouseUp, listener);
+ ctrl.addListener(SWT.MouseMove, listener);
+ ctrl.addListener(SWT.MouseEnter, listener);
+ ctrl.addListener(SWT.MouseExit, listener);
+ ctrl.addListener(SWT.MouseVerticalWheel, listener);
+ }
+ if( null != kl ) {
+ final Listener listener = new Listener () {
+ @Override
+ public void handleEvent (Event event) {
+ dispatchKeyEvent( event, sourceHolder, kl );
+ } };
+ ctrl.addListener(SWT.KeyDown, listener);
+ ctrl.addListener(SWT.KeyUp, listener);
+ }
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java
index 316199d07..c612f1204 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java
@@ -45,7 +45,6 @@ import javax.media.opengl.awt.GLCanvas;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.GLDrawableUtil;
-
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -116,14 +115,14 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase {
final GLCapabilities capsOffscreen = (GLCapabilities) capsOnscreen.clone();
capsOffscreen.setOnscreen(false);
- final QuitAdapter quitAdapter = new QuitAdapter();
-
final Frame frame = new Frame("Gears AWT Test");
Assert.assertNotNull(frame);
- new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
GLAutoDrawable glCanvas = createGLAutoDrawable(frame, capsOnscreen, width, height);
+ final QuitAdapter quitAdapter = new QuitAdapter();
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas).addTo(frame);
+
final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
GearsES2 gears = new GearsES2(1);
glCanvas.addGLEventListener(gears);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java
index 443908ff8..28e00dfe2 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java
@@ -236,9 +236,8 @@ public class TestBug816OSXCALayerPos01AWT extends UITestCase {
if( twoCanvas ) {
animator.add(glCanvas2);
}
- QuitAdapter quitAdapter = new QuitAdapter();
-
- new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
+ final QuitAdapter quitAdapter = new QuitAdapter();
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java
index df24fc6e0..5f1b43a61 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java
@@ -80,9 +80,9 @@ public class TestBug816OSXCALayerPos02AWT extends UITestCase {
final Animator animator = new Animator();
animator.add(glCanvas1);
- QuitAdapter quitAdapter = new QuitAdapter();
- new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
+ final QuitAdapter quitAdapter = new QuitAdapter();
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame);
// Build a GUI where the canvas 3D is located at top right of the frame
// and can be resized with split panes dividers
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java
index 29dc9a190..f37cdf332 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java
@@ -87,9 +87,9 @@ public class TestBug816OSXCALayerPos03aB729AWT extends UITestCase {
final Animator animator = new Animator();
animator.add(glCanvas1);
- QuitAdapter quitAdapter = new QuitAdapter();
- new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
+ final QuitAdapter quitAdapter = new QuitAdapter();
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame);
// Create a check box that hides / shows canvas
final Checkbox checkbox = new Checkbox("Visible canvas", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java
index 3e60c8b47..acdd40764 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java
@@ -93,9 +93,9 @@ public class TestBug816OSXCALayerPos03bB849AWT extends UITestCase {
final Animator animator = new Animator();
animator.add(glCanvas1);
- QuitAdapter quitAdapter = new QuitAdapter();
- new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
+ final QuitAdapter quitAdapter = new QuitAdapter();
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame);
// Create a check box that hides / shows canvas
final Checkbox checkbox = new Checkbox("Visible canvas", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java
index 24f9de961..52480b89b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java
@@ -95,9 +95,9 @@ public class TestBug816OSXCALayerPos03cB849AWT extends UITestCase {
final Animator animator = new Animator();
animator.add(glCanvas1);
- QuitAdapter quitAdapter = new QuitAdapter();
- new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
+ final QuitAdapter quitAdapter = new QuitAdapter();
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame);
// Create a check box that hides / shows canvas
final JCheckBox checkbox = new JCheckBox("Visible canvas", true);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java
index b558b1680..246c5cdb5 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.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.jogl.awt;
import java.awt.BorderLayout;
@@ -59,55 +59,55 @@ import com.jogamp.opengl.util.Animator;
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestBug816OSXCALayerPos04aAWT extends UITestCase {
- static long duration = 1600; // ms
+ static long duration = 1600; // ms
static int width=640, height=480;
-
+
@Test
public void test() throws InterruptedException, InvocationTargetException {
final GLCapabilities caps = new GLCapabilities(getGLP());
-
+
final Frame frame = new Frame("TestBug816OSXCALayerPos04aAWT");
Assert.assertNotNull(frame);
final GLCanvas glCanvas1 = new GLCanvas(caps);
Assert.assertNotNull(glCanvas1);
glCanvas1.addGLEventListener(new GearsES2(1));
-
+
final Animator animator = new Animator();
animator.add(glCanvas1);
- QuitAdapter quitAdapter = new QuitAdapter();
-
- new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame);
+
+ final QuitAdapter quitAdapter = new QuitAdapter();
+ new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame);
// Display the canvas 3D in a dialog child of a frame
frame.setSize(400, 400);
-
+
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame.setLocation(100, 100);
frame.setSize(width, height);
frame.setVisible(true);
- }});
+ }});
Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
-
+
final Dialog dialog = new Dialog(frame, "Bug 816 AWT Top-Level Dialog");
dialog.setLayout(new BorderLayout());
dialog.add(glCanvas1, BorderLayout.CENTER);
-
+
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
dialog.setLocation(200, 200);
dialog.setSize(width/2, height/2);
dialog.setVisible(true);
- }});
+ }});
Assert.assertEquals(true, AWTRobotUtil.waitForVisible(dialog, true));
- Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true));
-
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true));
+
animator.start();
Assert.assertTrue(animator.isStarted());
Assert.assertTrue(animator.isAnimating());
animator.setUpdateFPSFrames(60, System.err);
-
+
final long t0 = System.currentTimeMillis();
long t1 = t0;
while(!quitAdapter.shouldQuit() && t1 - t0 < duration) {
@@ -117,7 +117,7 @@ public class TestBug816OSXCALayerPos04aAWT extends UITestCase {
Assert.assertNotNull(frame);
Assert.assertNotNull(glCanvas1);
-
+
Assert.assertNotNull(animator);
animator.stop();
Assert.assertFalse(animator.isAnimating());
@@ -138,7 +138,7 @@ public class TestBug816OSXCALayerPos04aAWT extends UITestCase {
static GLProfile getGLP() {
return GLProfile.getMaxProgrammableCore(true);
}
-
+
public static void main(String args[]) {
for(int i=0; i* {@link RandomTileRenderer} setup and finishing is performed - * within the pre- and post {@link GLEventListener} + * within the pre- and post {@link GLEventListener} * set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)} - * on the animation thread. + * on the animation thread. *
** At tile rendering finish, the viewport and * and the original {@link GLEventListener}'s PMV matrix as well. - * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. + * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. *
*/ @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -82,7 +82,7 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { static long duration = 3500; // ms static int width = 512; static int height = 512; - + @Test public void test01_aa0() throws IOException, InterruptedException, InvocationTargetException { doTest(0); @@ -92,7 +92,7 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { doTest(8); } - void doTest(int msaaCount) throws IOException, InterruptedException, InvocationTargetException { + void doTest(int msaaCount) throws IOException, InterruptedException, InvocationTargetException { final GLCapabilities caps = new GLCapabilities(null); if( msaaCount > 0 ) { caps.setSampleBuffers(true); @@ -113,11 +113,9 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { final Gears gears = new Gears(); glad.addGLEventListener( gears ); - final Animator animator = new Animator(glad); final QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glad); - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glad).addTo(glad); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glad).addTo(frame); // Fix the image size for now final int maxTileSize = 64; @@ -134,7 +132,7 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { final GLEventListener preTileGLEL = new GLEventListener() { final int w = maxTileSize, h = maxTileSize; int dx = 0, dy = 0; - + @Override public void init(GLAutoDrawable drawable) { final GL gl = drawable.getGL(); @@ -183,15 +181,15 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { caps.getGLProfile(), 0 /* internalFormat */, imageWidth, imageHeight, - 0, + 0, imageBuffer.pixelAttributes, - false, false, + false, false, flipVertically[0], imageBuffer.buffer, null /* Flusher */); try { final String filename = getSnapshotFilename(0, "-tile", glad.getChosenGLCapabilities(), imageWidth, imageHeight, false, TextureIO.PNG, null); - final File file = new File(filename); + final File file = new File(filename); TextureIO.write(textureData, file); } catch (IOException e) { e.printStackTrace(); @@ -206,19 +204,21 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} }; renderer.setGLEventListener(preTileGLEL, postTileGLEL); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.pack(); frame.setVisible(true); }}); - animator.setUpdateFPSFrames(60, System.err); + + final Animator animator = new Animator(glad); + animator.setUpdateFPSFrames(60, System.err); animator.start(); boolean signalTileRenderer = true; - - while(!quitAdapter.shouldQuit() && animator.isAnimating() && - ( rendererActive[0] || animator.getTotalFPSDuration()