diff options
author | Sven Gothel <[email protected]> | 2010-06-02 04:13:43 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-06-02 04:13:43 +0200 |
commit | d94115b3d72ec556371e6d09c2967345662fc781 (patch) | |
tree | d25dbcc892cb0a7e9316123e5e2e12885a2e29d5 | |
parent | dd0400a41478c1f365414b8c760eee1c91105280 (diff) |
NEWT: Simplified Locking
- Using Display.getEDTUtil() and Display.runCreateAndDestroyOnEDT()
to determine the NEWT EDT behavior, which may be specialized by the implementation.
- AWTWrapper and Newt/AWT Parenting deadlock fix.
- Misc fixes in test cases
14 files changed, 210 insertions, 152 deletions
diff --git a/make/build.xml b/make/build.xml index 9a1cf81ce..4b6c2cabe 100644 --- a/make/build.xml +++ b/make/build.xml @@ -63,7 +63,7 @@ </copy> </target> - <target name="one.dir" depends="one-lib-dir,one-jar-dir"/> + <target name="one-dir" depends="one-lib-dir,one-jar-dir"/> <target name="repack-jars" depends="one-jar-dir"> <!-- Re-pack jars we have the intent to compress later, after signing --> @@ -155,7 +155,7 @@ - Main build target. --> - <target name="all" description="Build nativewindow, jogl and newt projects, incl. all junit tests " depends="init,build.nativewindow,build.jogl,build.newt,junit.compile,one-lib-dir,one-jar-dir,developer-zip-archive,source-archive" /> + <target name="all" description="Build nativewindow, jogl and newt projects, incl. all junit tests " depends="init,build.nativewindow,build.jogl,build.newt,junit.compile,one-dir,developer-zip-archive,source-archive" /> <target name="junit.compile"> <ant antfile="build-junit.xml" target="junit.compile" inheritRefs="true" inheritAll="true"/> diff --git a/make/scripts/java-run-all.sh b/make/scripts/java-run-all.sh index 0e5be242a..5f6cff28a 100755 --- a/make/scripts/java-run-all.sh +++ b/make/scripts/java-run-all.sh @@ -38,6 +38,7 @@ uname -a | grep -i Darwin && MOSX=1 # D_ARGS="-Dnewt.debug=all -Dnativewindow.debug=all" # D_ARGS="-Dnewt.debug=all" # D_ARGS="-Dnewt.debug.Window" +# D_ARGS="-Dnewt.debug.Display" # D_ARGS="-Djogl.debug=all" rm -f java-run.log diff --git a/src/junit/com/jogamp/test/junit/jogl/texture/TestTexture01AWT.java b/src/junit/com/jogamp/test/junit/jogl/texture/TestTexture01AWT.java index 45c782d38..7fdbd59c8 100755 --- a/src/junit/com/jogamp/test/junit/jogl/texture/TestTexture01AWT.java +++ b/src/junit/com/jogamp/test/junit/jogl/texture/TestTexture01AWT.java @@ -48,29 +48,44 @@ import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.image.BufferedImage; +import java.io.IOException; +import org.junit.Assert; import org.junit.After; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; public class TestTexture01AWT { - Frame frame; + static GLProfile glp; + static GLCapabilities caps; BufferedImage textureImage; + @BeforeClass + public static void initClass() { + glp = GLProfile.get(GLProfile.GL2GL3); + Assert.assertNotNull(glp); + caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + } + @Before - public void init() { + public void initTest() { // create base image - BufferedImage baseImage = new BufferedImage(256, 256, BufferedImage.TYPE_INT_RGB); + BufferedImage baseImage = new BufferedImage(256, 256, BufferedImage.TYPE_3BYTE_BGR); + Assert.assertNotNull(baseImage); Graphics2D g = baseImage.createGraphics(); + Assert.assertNotNull(g); g.setPaint(new GradientPaint(0, 0, Color.CYAN, baseImage.getWidth(), baseImage.getHeight(), Color.BLUE)); g.fillRect(0, 0, baseImage.getWidth(), baseImage.getHeight()); g.dispose(); // create texture image - int imageType = BufferedImage.TYPE_INT_RGB; + int imageType = BufferedImage.TYPE_3BYTE_BGR; textureImage = new BufferedImage(baseImage.getWidth(), baseImage.getHeight(), imageType); + Assert.assertNotNull(textureImage); g = textureImage.createGraphics(); g.setComposite(AlphaComposite.Src); g.drawImage(baseImage, 0, 0, null); @@ -78,22 +93,21 @@ public class TestTexture01AWT { baseImage.flush(); baseImage=null; - - frame = new Frame("Texture Test"); } @After - public void cleanup() { + public void cleanupTest() { + Assert.assertNotNull(textureImage); textureImage.flush(); textureImage=null; - frame.dispose(); - frame=null; } @Test public void test1() throws InterruptedException { - GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2GL3)); GLCanvas glCanvas = new GLCanvas(caps); + + Frame frame = new Frame("Texture Test"); + Assert.assertNotNull(frame); frame.add(glCanvas); frame.setSize(512, 512); @@ -111,9 +125,23 @@ public class TestTexture01AWT { frame.setVisible(false); frame.remove(glCanvas); glCanvas=null; + Assert.assertNotNull(frame); + frame.dispose(); + frame=null; } - public static void main(String args[]) { - org.junit.runner.JUnitCore.main(TestTexture01AWT.class.getName()); + public static void main(String args[]) throws IOException { + String tstname = TestTexture01AWT.class.getName(); + org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] { + tstname, + "filtertrace=true", + "haltOnError=false", + "haltOnFailure=false", + "showoutput=true", + "outputtoformatters=true", + "logfailedtests=true", + "logtestlistenerevents=true", + "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter", + "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); } } diff --git a/src/junit/com/jogamp/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java b/src/junit/com/jogamp/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java index eabd4b79d..c5e656572 100755 --- a/src/junit/com/jogamp/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java +++ b/src/junit/com/jogamp/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java @@ -53,7 +53,9 @@ public class TextureGL2ListenerDraw1 implements GLEventListener { } public void init(GLAutoDrawable drawable) { - this.texture = TextureIO.newTexture(textureData); + if(null!=textureData) { + this.texture = TextureIO.newTexture(textureData); + } } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { @@ -89,21 +91,23 @@ public class TextureGL2ListenerDraw1 implements GLEventListener { // Now draw one quad with the texture - texture.enable(); - texture.bind(); - gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE); - TextureCoords coords = texture.getImageTexCoords(); - gl.glBegin(GL2.GL_QUADS); - gl.glTexCoord2f(coords.left(), coords.bottom()); - gl.glVertex3f(0, 0, 0); - gl.glTexCoord2f(coords.right(), coords.bottom()); - gl.glVertex3f(1, 0, 0); - gl.glTexCoord2f(coords.right(), coords.top()); - gl.glVertex3f(1, 1, 0); - gl.glTexCoord2f(coords.left(), coords.top()); - gl.glVertex3f(0, 1, 0); - gl.glEnd(); - texture.disable(); + if(null!=texture) { + texture.enable(); + texture.bind(); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE); + TextureCoords coords = texture.getImageTexCoords(); + gl.glBegin(GL2.GL_QUADS); + gl.glTexCoord2f(coords.left(), coords.bottom()); + gl.glVertex3f(0, 0, 0); + gl.glTexCoord2f(coords.right(), coords.bottom()); + gl.glVertex3f(1, 0, 0); + gl.glTexCoord2f(coords.right(), coords.top()); + gl.glVertex3f(1, 1, 0); + gl.glTexCoord2f(coords.left(), coords.top()); + gl.glVertex3f(0, 1, 0); + gl.glEnd(); + texture.disable(); + } } } diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java index b96e74182..9aec605be 100755 --- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java @@ -127,10 +127,16 @@ public class TestGLWindows01NEWT { window.display(); window.destroy(); Assert.assertEquals(false,window.isNativeWindowValid()); - Assert.assertEquals(true,window.isVisible()); + Assert.assertEquals(false,window.isVisible()); window.display(); + Assert.assertEquals(false,window.isNativeWindowValid()); + Assert.assertEquals(false,window.isVisible()); + + window.setVisible(true); Assert.assertEquals(true,window.isNativeWindowValid()); + Assert.assertEquals(true,window.isVisible()); + window.display(); Animator animator = new Animator(window); animator.start(); diff --git a/src/junit/com/jogamp/test/junit/newt/TestParenting02AWT.java b/src/junit/com/jogamp/test/junit/newt/TestParenting02AWT.java index 6d0791c1c..753da1836 100755 --- a/src/junit/com/jogamp/test/junit/newt/TestParenting02AWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestParenting02AWT.java @@ -68,6 +68,7 @@ public class TestParenting02AWT { static int width, height; static long durationPerTest = 500; static long waitReparent = 300; + static boolean verbose = false; @BeforeClass public static void initClass() { @@ -157,7 +158,9 @@ public class TestParenting02AWT { Assert.assertEquals(true, glWindow.isNativeWindowValid()); Assert.assertNotNull(glWindow.getParentNativeWindow()); - System.out.println("+++++++++++++++++++ 1st ADDED"); + if(verbose) { + System.out.println("+++++++++++++++++++ 1st ADDED"); + } Thread.sleep(waitReparent); if(useLayout) { @@ -166,7 +169,9 @@ public class TestParenting02AWT { Assert.assertEquals(false, glWindow.isVisible()); Assert.assertEquals(true, glWindow.isNativeWindowValid()); Assert.assertNull(glWindow.getParentNativeWindow()); - System.out.println("+++++++++++++++++++ REMOVED!"); + if(verbose) { + System.out.println("+++++++++++++++++++ REMOVED!"); + } Thread.sleep(waitReparent); // should recreate properly .. @@ -175,7 +180,9 @@ public class TestParenting02AWT { Assert.assertEquals(true, glWindow.isVisible()); Assert.assertEquals(true, glWindow.isNativeWindowValid()); Assert.assertNotNull(glWindow.getParentNativeWindow()); - System.out.println("+++++++++++++++++++ 2nd ADDED"); + if(verbose) { + System.out.println("+++++++++++++++++++ 2nd ADDED"); + } Thread.sleep(waitReparent); } @@ -204,7 +211,9 @@ public class TestParenting02AWT { } } } - System.out.println("+++++++++++++++++++ END"); + if(verbose) { + System.out.println("+++++++++++++++++++ END"); + } Thread.sleep(waitReparent); glWindow.destroy(); @@ -236,6 +245,7 @@ public class TestParenting02AWT { } public static void main(String args[]) throws IOException { + verbose = true; for(int i=0; i<args.length; i++) { if(args[i].equals("-time")) { durationPerTest = atoi(args[++i]); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NativeWindowFactoryImpl.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/NativeWindowFactoryImpl.java index d2429cdab..6233bf533 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NativeWindowFactoryImpl.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/NativeWindowFactoryImpl.java @@ -56,13 +56,13 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory { throw new IllegalArgumentException("AbstractGraphicsConfiguration is null with a non NativeWindow object"); } - if (ReflectionUtil.instanceOf(winObj, "java.awt.Component")) { + if (ReflectionUtil.instanceOf(winObj, AWTComponentClassName)) { return getAWTNativeWindow(winObj, config); } throw new IllegalArgumentException("Target window object type " + winObj.getClass().getName() + " is unsupported; expected " + - "javax.media.nativewindow.NativeWindow or java.awt.Component"); + "javax.media.nativewindow.NativeWindow or "+AWTComponentClassName); } private Constructor nativeWindowConstructor = null; diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 2125fb4c0..14cb830e3 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -75,7 +75,7 @@ public abstract class NativeWindowFactory { private static String nativeWindowingTypeCustom; private static String nativeOSNameCustom; private static final boolean isAWTAvailable; - private static final String awtComponentClassName = "java.awt.Component" ; + public static final String AWTComponentClassName = "java.awt.Component" ; /** Creates a new NativeWindowFactory instance. End users do not need to call this method. */ @@ -126,7 +126,7 @@ public abstract class NativeWindowFactory { // make it easier to run this code on mobile devices isAWTAvailable = !Debug.getBooleanProperty("java.awt.headless", true, acc) && - ReflectionUtil.isClassAvailable(awtComponentClassName) && + ReflectionUtil.isClassAvailable(AWTComponentClassName) && ReflectionUtil.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice") ; boolean toolkitLockForced = Debug.getBooleanProperty("nativewindow.locking", true, acc); @@ -195,7 +195,7 @@ public abstract class NativeWindowFactory { if ( isAWTAvailable ) { // register either our default factory or (if exist) the X11/AWT one -> AWT Component - registerFactory(ReflectionUtil.getClass(awtComponentClassName, false), factory); + registerFactory(ReflectionUtil.getClass(AWTComponentClassName, false), factory); } defaultFactory = factory; diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 113ec547e..8710f82ba 100755 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -112,7 +112,7 @@ public abstract class Display { Map displayMap = getCurrentDisplayMap(); Set entrySet = displayMap.entrySet(); Iterator i = entrySet.iterator(); - System.err.println(prefix+" DisplayMap["+entrySet.size()+"] "+Thread.currentThread()); + System.err.println(prefix+" DisplayMap[] entries: "+entrySet.size()+" - "+Thread.currentThread()); for(int j=0; i.hasNext(); j++) { Map.Entry entry = (Map.Entry) i.next(); System.err.println(" ["+j+"] "+entry.getKey()+" -> "+entry.getValue()); @@ -125,7 +125,7 @@ public abstract class Display { } /** Make sure to reuse a Display with the same name */ - protected static Display create(String type, String name, final long handle) { + protected static synchronized Display create(String type, String name, final long handle) { try { Class displayClass = getDisplayClass(type); Display tmpDisplay = (Display) displayClass.newInstance(); @@ -140,41 +140,30 @@ public abstract class Display { tmpDisplay = null; display.name = name; display.type=type; - display.refCount=1; - - if(NewtFactory.useEDT()) { - final Display f_dpy = display; - Thread current = Thread.currentThread(); - display.edtUtil = new EDTUtil(current.getThreadGroup(), - "Display_"+display.getFQName(), - new Runnable() { - public void run() { - if(null!=f_dpy.getGraphicsDevice()) { - f_dpy.pumpMessagesImpl(); - } - } } ); - display.edt = display.edtUtil.start(); - display.edtUtil.invokeAndWait(new Runnable() { - public void run() { - f_dpy.createNative(); - } - } ); - } else { - display.createNative(); - } - if(null==display.aDevice) { - throw new RuntimeException("Display.createNative() failed to instanciate an AbstractGraphicsDevice"); - } - setCurrentDisplay(display); + display.refCount=0; if(DEBUG) { - System.err.println("Display.create("+getFQName(type, name)+") NEW: "+display+" "+Thread.currentThread()); + System.err.println("Display.create("+getFQName(type, name)+") NEW: refCount "+display.refCount+", "+display+" "+Thread.currentThread()); } } else { tmpDisplay = null; - synchronized(display) { - display.refCount++; + if(DEBUG) { + System.err.println("Display.create("+getFQName(type, name)+") REUSE: refCount "+display.refCount+", "+display+" "+Thread.currentThread()); + } + } + synchronized(display) { + display.refCount++; + if(null==display.aDevice) { + final Display f_dpy = display; + display.runOnEDTIfAvail(true, new Runnable() { + public void run() { + f_dpy.createNative(); + }}); + if(null==display.aDevice) { + throw new RuntimeException("Display.createNative() failed to instanciate an AbstractGraphicsDevice"); + } + setCurrentDisplay(display); if(DEBUG) { - System.err.println("Display.create("+getFQName(type, name)+") REUSE: refCount "+display.refCount+", "+display+" "+Thread.currentThread()); + System.err.println("Display.create("+getFQName(type, name)+") CreateNative: "+display+" "+Thread.currentThread()); } } } @@ -187,7 +176,41 @@ public abstract class Display { } } - public EDTUtil getEDTUtil() { return edtUtil; } + public boolean runCreateAndDestroyOnEDT() { + return true; + } + public EDTUtil getEDTUtil() { + if( !edtQueried ) { + synchronized (this) { + if( !edtQueried ) { + edtQueried = true; + if(NewtFactory.useEDT()) { + final Display f_dpy = this; + Thread current = Thread.currentThread(); + edtUtil = new EDTUtil(current.getThreadGroup(), + "Display_"+getFQName(), + new Runnable() { + public void run() { + if(null!=f_dpy.getGraphicsDevice()) { + f_dpy.pumpMessagesImpl(); + } } } ); + edt = edtUtil.start(); + } + } + } + } + return edtUtil; + } + volatile boolean edtQueried = false; + + public void runOnEDTIfAvail(boolean wait, final Runnable task) { + EDTUtil edtUtil = getEDTUtil(); + if(runCreateAndDestroyOnEDT() && null!=edtUtil) { + edtUtil.invoke(wait, task); + } else { + task.run(); + } + } public synchronized void destroy() { if(DEBUG) { @@ -199,18 +222,17 @@ public abstract class Display { if(DEBUG) { System.err.println("Display.destroy("+getFQName()+") REMOVE: "+this+" "+Thread.currentThread()); } - if(null!=edtUtil) { - final Display f_dpy = this; - final EDTUtil f_edt = edtUtil; - edtUtil.invokeAndWait(new Runnable() { - public void run() { - f_dpy.closeNative(); + final Display f_dpy = this; + final EDTUtil f_edt = edtUtil; + runOnEDTIfAvail(true, new Runnable() { + public void run() { + f_dpy.closeNative(); + if(null!=f_edt) { f_edt.stop(); } - } ); - } else { - closeNative(); - } + } + } ); + if(null!=edtUtil) { edtUtil.waitUntilStopped(); edtUtil=null; diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index bb3fa8982..87f0bf0eb 100755 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -161,11 +161,6 @@ public abstract class Window implements NativeWindow if( null==screen || 0!=windowHandle || !visible ) { return 0 != windowHandle ; } - EDTUtil edtUtil = screen.getDisplay().getEDTUtil(); - if( null != edtUtil && edtUtil.isRunning() && !edtUtil.isCurrentThreadEDT() ) { - throw new NativeWindowException("EDT enabled but not on EDT"); - } - if(DEBUG_IMPLEMENTATION) { System.err.println("Window.createNative() START ("+Thread.currentThread()+", "+this+")"); } @@ -219,12 +214,8 @@ public abstract class Window implements NativeWindow if(null==screen) { throw new RuntimeException("Null screen of inner class: "+this); } - EDTUtil edtUtil = screen.getDisplay().getEDTUtil(); - if(null!=edtUtil) { - edtUtil.invoke(wait, task); - } else { - task.run(); - } + Display d = screen.getDisplay(); + d.runOnEDTIfAvail(wait, task); } /** diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java index d94a32a9c..33c291e96 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java @@ -35,12 +35,24 @@ package com.jogamp.newt.event.awt; * Specialized parent/client adapter, * where the NEWT child window really gets resized, * and the parent move window event gets discarded. */ -public class AWTParentWindowAdapter extends AWTWindowAdapter +public class AWTParentWindowAdapter + extends AWTWindowAdapter + implements java.awt.event.HierarchyListener { public AWTParentWindowAdapter(com.jogamp.newt.Window downstream) { super(downstream); } + public AWTAdapter addTo(java.awt.Component awtComponent) { + awtComponent.addHierarchyListener(this); + return super.addTo(awtComponent); + } + + public AWTAdapter removeFrom(java.awt.Component awtComponent) { + awtComponent.removeHierarchyListener(this); + return super.removeFrom(awtComponent); + } + public 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. @@ -67,5 +79,31 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter public void windowDeactivated(java.awt.event.WindowEvent e) { // no propagation to NEWT child window } + + public void hierarchyChanged(java.awt.event.HierarchyEvent e) { + if( null == newtListener ) { + long bits = e.getChangeFlags(); + final java.awt.Component changed = e.getChanged(); + if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) { + final boolean showing = changed.isShowing(); + if(DEBUG_IMPLEMENTATION) { + System.out.println("hierarchyChanged SHOWING_CHANGED: showing "+showing+", "+changed); + } + if(!newtWindow.isDestroyed()) { + newtWindow.runOnEDTIfAvail(false, new Runnable() { + public void run() { + newtWindow.setVisible(showing); + } + }); + } + } + if( 0 != ( java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED & bits ) ) { + final boolean displayability = changed.isDisplayable(); + if(DEBUG_IMPLEMENTATION) { + System.out.println("hierarchyChanged DISPLAYABILITY_CHANGED: displayability "+displayability+", "+changed); + } + } + } + } } 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 53ce03299..570b0678a 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java @@ -33,8 +33,7 @@ package com.jogamp.newt.event.awt; public class AWTWindowAdapter extends AWTAdapter - implements java.awt.event.ComponentListener, java.awt.event.WindowListener, - java.awt.event.HierarchyListener, java.awt.event.HierarchyBoundsListener + implements java.awt.event.ComponentListener, java.awt.event.WindowListener { WindowClosingListener windowClosingListener; @@ -53,8 +52,6 @@ public class AWTWindowAdapter public AWTAdapter addTo(java.awt.Component awtComponent) { java.awt.Window win = getWindow(awtComponent); awtComponent.addComponentListener(this); - awtComponent.addHierarchyListener(this); - awtComponent.addHierarchyBoundsListener(this); if( null == windowClosingListener ) { windowClosingListener = new WindowClosingListener(); } @@ -69,8 +66,6 @@ public class AWTWindowAdapter public AWTAdapter removeFrom(java.awt.Component awtComponent) { awtComponent.removeComponentListener(this); - awtComponent.removeHierarchyListener(this); - awtComponent.removeHierarchyBoundsListener(this); java.awt.Window win = getWindow(awtComponent); if( null != win && null != windowClosingListener ) { win.removeWindowListener(windowClosingListener); @@ -110,6 +105,7 @@ public class AWTWindowAdapter } public void componentShown(java.awt.event.ComponentEvent e) { + /** if(null==newtListener) { if(!newtWindow.isDestroyed()) { newtWindow.runOnEDTIfAvail(false, new Runnable() { @@ -118,10 +114,11 @@ public class AWTWindowAdapter } }); } - } + }*/ } public void componentHidden(java.awt.event.ComponentEvent e) { + /** if(null==newtListener) { if(!newtWindow.isDestroyed()) { newtWindow.runOnEDTIfAvail(false, new Runnable() { @@ -130,7 +127,7 @@ public class AWTWindowAdapter } }); } - } + }*/ } public void windowActivated(java.awt.event.WindowEvent e) { @@ -161,52 +158,6 @@ public class AWTWindowAdapter public void windowOpened(java.awt.event.WindowEvent e) { } - public void hierarchyChanged(java.awt.event.HierarchyEvent e) { - if( null == newtListener ) { - long bits = e.getChangeFlags(); - final java.awt.Component changed = e.getChanged(); - if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) { - final boolean showing = changed.isShowing(); - if(DEBUG_IMPLEMENTATION) { - System.out.println("hierarchyChanged SHOWING_CHANGED: showing "+showing+", "+changed); - } - if(!newtWindow.isDestroyed()) { - newtWindow.runOnEDTIfAvail(false, new Runnable() { - public void run() { - newtWindow.setVisible(showing); - } - }); - } - } - if( 0 != ( java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED & bits ) ) { - final boolean displayability = changed.isDisplayable(); - if(DEBUG_IMPLEMENTATION) { - System.out.println("hierarchyChanged DISPLAYABILITY_CHANGED: displayability "+displayability+", "+changed); - } - } - } - } - - public void ancestorMoved(java.awt.event.HierarchyEvent e) { - if( null == newtListener ) { - final java.awt.Component changed = e.getChanged(); - final boolean showing = changed.isShowing(); - if(DEBUG_IMPLEMENTATION) { - System.out.println("ancestorMoved: showing "+showing+", "+changed); - } - } - } - - public void ancestorResized(java.awt.event.HierarchyEvent e) { - if( null == newtListener ) { - final java.awt.Component changed = e.getChanged(); - final boolean showing = changed.isShowing(); - if(DEBUG_IMPLEMENTATION) { - System.out.println("ancestorResized: showing "+showing+", "+changed); - } - } - } - class WindowClosingListener implements java.awt.event.WindowListener { public void windowClosing(java.awt.event.WindowEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java index f54e66f07..e705d364a 100644 --- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java +++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java @@ -54,6 +54,9 @@ public class AWTDisplay extends Display { protected void closeNative() { } + public boolean runCreateAndDestroyOnEDT() { + return false; + } protected void dispatchMessagesNative() { /* nop */ } } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 2bb28466c..9559043c4 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -120,10 +120,14 @@ public class GLWindow extends Window implements GLAutoDrawable { return (null!=window)?window.isDestroyed():true; } - public Window getInnerWindow() { + public final Window getInnerWindow() { return window.getInnerWindow(); } + public final Object getWrappedWindow() { + return window.getWrappedWindow(); + } + /** * EXPERIMENTAL<br> * Enable or disables running the {@link Display#pumpMessages} in the {@link #display()} call.<br> @@ -244,8 +248,8 @@ public class GLWindow extends Window implements GLAutoDrawable { window.setVisible(visible); if (null == context && visible && 0 != window.getWindowHandle() && 0<getWidth()*getHeight()) { NativeWindow nw; - if (window.getWrappedWindow() != null) { - nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getGraphicsConfiguration()); + if (getWrappedWindow() != null) { + nw = NativeWindowFactory.getNativeWindow(getWrappedWindow(), window.getGraphicsConfiguration()); } else { nw = window; } |