aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java2
-rw-r--r--src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java2
-rw-r--r--src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java2
-rw-r--r--src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java2
-rw-r--r--src/junit/com/jogamp/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java6
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java92
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle02NEWT.java75
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestEventSourceNotAWTBug.java2
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java2
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java2
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestGLWindows00NEWT.java3
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java55
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java30
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java2
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestRemoteGLWindows01NEWT.java4
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestScreenMode00NEWT.java5
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java33
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java26
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java12
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java92
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java12
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java2
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java4
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java4
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java2
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java2
-rw-r--r--src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03bAWT.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/Display.java42
-rw-r--r--src/newt/classes/com/jogamp/newt/NewtFactory.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/Screen.java42
-rw-r--r--src/newt/classes/com/jogamp/newt/Window.java28
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java22
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/DefaultEDTUtil.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java32
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java6
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/ScreenImpl.java32
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/WindowImpl.java319
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java46
38 files changed, 501 insertions, 551 deletions
diff --git a/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java
index 0c64cfdf2..860a181a4 100644
--- a/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java
@@ -150,7 +150,7 @@ public class TestGLProfile01NEWT extends UITestCase {
glWindow.setSize(128, 128);
glWindow.setVisible(true);
glWindow.display();
- glWindow.destroy(true);
+ glWindow.invalidate();
}
public static void main(String args[]) throws IOException {
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java
index f88d4d16f..d83deea4b 100644
--- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java
@@ -101,7 +101,7 @@ public class TestGearsNEWT extends UITestCase {
}
animator.stop();
- glWindow.destroy(true);
+ glWindow.invalidate();
}
@Test
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java
index c965d5c21..ef4b657fc 100644
--- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java
@@ -89,7 +89,7 @@ public class TestGearsNewtAWTWrapper extends UITestCase {
}
animator.stop();
- glWindow.destroy(true);
+ glWindow.invalidate();
}
@Test
diff --git a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
index 95db913ab..9b6194ca6 100644
--- a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
@@ -145,7 +145,7 @@ public class TestDrawable01NEWT extends UITestCase {
// GLWindow.destroy(..) sequence cont..
Assert.assertNotNull(window);
- window.destroy(true); // incl screen + display
+ window.invalidate();
drawable = null;
context = null;
diff --git a/src/junit/com/jogamp/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java b/src/junit/com/jogamp/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java
index 79d899b6c..8f56f6f46 100644
--- a/src/junit/com/jogamp/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java
+++ b/src/junit/com/jogamp/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java
@@ -265,10 +265,10 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase {
anim1.start();
runTestGL(newtCanvasAWT, win1);
- win0.destroy(true);
+ win0.destroy();
Assert.assertEquals(false, anim0.isAnimating());
- newtCanvasAWT.destroy(true);
+ newtCanvasAWT.destroy();
Assert.assertEquals(false, anim1.isAnimating());
System.err.println("TestSwingAWTRobotUsageBeforeJOGLInitBug411.test01NewtCanvasAWT(): End");
@@ -303,7 +303,7 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase {
Assert.assertEquals(false, anim1.isAnimating());
/**
- win0.destroy(true);
+ win0.destroy();
Assert.assertEquals(false, anim0.isAnimating());
*/
diff --git a/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java
index 44b4e7325..94f915834 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java
@@ -92,7 +92,7 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
return glWindow;
}
- private void testDisplayCreate01(Display display, Screen screen, boolean destroyWhenUnused) throws InterruptedException {
+ private void testDisplayCreate01(Display display, Screen screen) throws InterruptedException {
// start-state == end-state
Assert.assertEquals(0,Display.getActiveDisplayNumber());
Assert.assertEquals(0,display.getReferenceCount());
@@ -102,13 +102,6 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
Assert.assertEquals(0,screen.getReferenceCount());
Assert.assertEquals(false,screen.isNativeValid());
- // Setup/Verify default DestroyWhenUnused behavior
- if(destroyWhenUnused) {
- screen.setDestroyWhenUnused(true);
- }
- Assert.assertEquals(destroyWhenUnused,display.getDestroyWhenUnused());
- Assert.assertEquals(destroyWhenUnused,screen.getDestroyWhenUnused());
-
// Create Window, pending lazy native creation
GLWindow window = createWindow(screen, caps, width, height);
Assert.assertEquals(screen,window.getScreen());
@@ -118,6 +111,9 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
Assert.assertEquals(true,display.getEDTUtil().isRunning());
Assert.assertEquals(0,screen.getReferenceCount());
Assert.assertEquals(false,screen.isNativeValid());
+
+ Assert.assertNotNull(window.getScreen());
+ Assert.assertEquals(true,window.isValid());
Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
@@ -163,16 +159,17 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
}
System.err.println("duration: "+window.getDuration());
- // recoverable destruction, ie Display/Screen untouched
- window.destroy(false);
+ // destruction ..
+ window.destroy();
Assert.assertEquals(screen,window.getScreen());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
- Assert.assertEquals(1,display.getReferenceCount());
- Assert.assertEquals(true,display.isNativeValid());
+ Assert.assertEquals(0,Display.getActiveDisplayNumber());
+ Assert.assertEquals(0,display.getReferenceCount());
+ Assert.assertEquals(false,display.isNativeValid());
Assert.assertNotNull(display.getEDTUtil());
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
- Assert.assertEquals(1,screen.getReferenceCount());
- Assert.assertEquals(true,screen.isNativeValid());
+ Assert.assertEquals(false,display.getEDTUtil().isRunning());
+ Assert.assertEquals(0,screen.getReferenceCount());
+ Assert.assertEquals(false,screen.isNativeValid());
+ Assert.assertEquals(true, window.isValid());
Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
window.resetCounter();
@@ -205,35 +202,9 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
}
System.err.println("duration: "+window.getDuration());
- // unrecoverable destruction, ie Display/Screen will be unreferenced
- window.destroy(true);
- Assert.assertEquals(null,window.getScreen());
+ // destruction ..
+ window.destroy();
display.dumpDisplayList("Post destroy(true)");
- if(!destroyWhenUnused) {
- // display/screen untouched when unused, default
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
- Assert.assertEquals(1,display.getReferenceCount());
- Assert.assertEquals(true,display.isNativeValid());
- Assert.assertNotNull(display.getEDTUtil());
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
- Assert.assertEquals(0,screen.getReferenceCount());
- Assert.assertEquals(true,screen.isNativeValid());
-
- // manual destruction: Screen
- screen.destroy();
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
- Assert.assertEquals(0,display.getReferenceCount());
- Assert.assertEquals(true,display.isNativeValid());
- Assert.assertNotNull(display.getEDTUtil());
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
- Assert.assertEquals(0,screen.getReferenceCount());
- Assert.assertEquals(false,screen.isNativeValid());
-
- // manual destruction: Display
- display.destroy();
- } else {
- // display/screen destroyed when unused
- }
// end-state == start-state
Assert.assertEquals(0,Display.getActiveDisplayNumber());
@@ -244,32 +215,21 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
Assert.assertEquals(0,screen.getReferenceCount());
Assert.assertEquals(false,screen.isNativeValid());
+ Assert.assertNotNull(window.getScreen());
+ Assert.assertEquals(true,window.isValid());
Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
}
@Test
- public void testDisplayCreate01_DestroyWhenUnused_False() throws InterruptedException {
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
-
- // Create Display/Screen, pending lazy native creation
- Display display = NewtFactory.createDisplay(null);
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- testDisplayCreate01(display, screen, false);
- testDisplayCreate01(display, screen, false);
-
- Assert.assertEquals(0,Display.getActiveDisplayNumber());
- }
-
- @Test
- public void testDisplayCreate01_DestroyWhenUnused_True() throws InterruptedException {
+ public void testDisplayCreate01_AutoDestroyLifecycle() throws InterruptedException {
Assert.assertEquals(0,Display.getActiveDisplayNumber());
// Create Display/Screen, pending lazy native creation
Display display = NewtFactory.createDisplay(null);
Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- testDisplayCreate01(display, screen, true);
- testDisplayCreate01(display, screen, true);
+ testDisplayCreate01(display, screen);
+ testDisplayCreate01(display, screen);
Assert.assertEquals(0,Display.getActiveDisplayNumber());
}
@@ -298,17 +258,7 @@ public class TestDisplayLifecycle01NEWT extends UITestCase {
}
System.err.println("durationPerTest: "+durationPerTest);
String tstname = TestDisplayLifecycle01NEWT.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" } );
+ org.junit.runner.JUnitCore.main(tstname);
}
}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle02NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle02NEWT.java
index 7253b7353..9fc6e3bc9 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle02NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle02NEWT.java
@@ -94,9 +94,6 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
Screen screen = window.getScreen();
Display display = screen.getDisplay();
- Assert.assertEquals(true,display.getDestroyWhenUnused());
- Assert.assertEquals(true,screen.getDestroyWhenUnused());
-
Assert.assertEquals(screen,window.getScreen());
Assert.assertEquals(0,Display.getActiveDisplayNumber());
Assert.assertEquals(0,display.getReferenceCount());
@@ -151,19 +148,22 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
}
System.err.println("duration: "+window.getDuration());
- // recoverable destruction, ie Display/Screen untouched
- window.destroy(false);
+ // destruction.. ref count down, but keep all
+ window.destroy();
Assert.assertEquals(screen,window.getScreen());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
- Assert.assertEquals(1,display.getReferenceCount());
- Assert.assertEquals(true,display.isNativeValid());
+ Assert.assertEquals(0,Display.getActiveDisplayNumber());
+ Assert.assertEquals(0,display.getReferenceCount());
+ Assert.assertEquals(false,display.isNativeValid());
Assert.assertNotNull(display.getEDTUtil());
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
- Assert.assertEquals(1,Screen.getActiveScreenNumber());
- Assert.assertEquals(1,screen.getReferenceCount());
- Assert.assertEquals(true,screen.isNativeValid());
+ Assert.assertEquals(false,display.getEDTUtil().isRunning());
+ Assert.assertEquals(0,Screen.getActiveScreenNumber());
+ Assert.assertEquals(0,screen.getReferenceCount());
+ Assert.assertEquals(false,screen.isNativeValid());
+ Assert.assertNotNull(window.getScreen());
+ Assert.assertEquals(true,window.isValid());
Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
+
window.resetCounter();
Assert.assertEquals(0, window.getTotalFrames());
@@ -179,6 +179,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
Assert.assertEquals(screen,window.getScreen());
Assert.assertEquals(1,Display.getActiveDisplayNumber());
Assert.assertEquals(1,display.getReferenceCount());
+ Assert.assertEquals(true,window.isValid());
Assert.assertEquals(true,display.isNativeValid());
Assert.assertEquals(true,display.getEDTUtil().isRunning());
Assert.assertEquals(1,Screen.getActiveScreenNumber());
@@ -195,9 +196,10 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
}
System.err.println("duration: "+window.getDuration());
- // unrecoverable destruction, ie Display/Screen will be unreferenced
- window.destroy(true);
- Assert.assertEquals(null,window.getScreen());
+ // destruction + invalidate, ie Display/Screen will be unreferenced
+ window.invalidate();
+ Assert.assertNull(window.getScreen());
+ Assert.assertEquals(false,window.isValid());
Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
@@ -240,9 +242,6 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
Assert.assertSame(display, window2.getScreen().getDisplay());
window2.setPosition(screen.getWidth()-width, 0);
- Assert.assertEquals(true,display.getDestroyWhenUnused());
- Assert.assertEquals(true,screen.getDestroyWhenUnused());
-
Assert.assertEquals(0,Display.getActiveDisplayNumber());
Assert.assertEquals(0,display.getReferenceCount());
Assert.assertEquals(false,display.isNativeValid());
@@ -297,9 +296,10 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
Assert.assertEquals(true,window1.isNativeValid());
Assert.assertEquals(false,window1.isVisible());
- // unrecoverable destruction, ie Display/Screen will be unreferenced
- window1.destroy(true);
- Assert.assertEquals(null,window1.getScreen());
+ // destruction ...
+ window1.destroy();
+ Assert.assertNotNull(window1.getScreen());
+ Assert.assertEquals(true,window1.isValid());
Assert.assertEquals(false,window1.isNativeValid());
Assert.assertEquals(false,window1.isVisible());
@@ -312,9 +312,10 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
Assert.assertEquals(1,screen.getReferenceCount());
Assert.assertEquals(true,screen.isNativeValid());
- // unrecoverable destruction, ie Display/Screen will be unreferenced
- window2.destroy(true);
- Assert.assertEquals(null,window2.getScreen());
+ // destruction
+ window2.destroy();
+ Assert.assertNotNull(window2.getScreen());
+ Assert.assertEquals(true,window2.isValid());
Assert.assertEquals(false,window2.isNativeValid());
Assert.assertEquals(false,window2.isVisible());
@@ -328,6 +329,20 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
Assert.assertEquals(0,screen.getReferenceCount());
Assert.assertEquals(false,screen.isNativeValid());
+ // invalidate .. remove all refs
+ window1.invalidate();
+ Assert.assertNull(window1.getScreen());
+ Assert.assertEquals(false,window1.isValid());
+ Assert.assertEquals(false,window1.isNativeValid());
+ Assert.assertEquals(false,window1.isVisible());
+
+ // invalidate .. remove all refs
+ window2.invalidate();
+ Assert.assertNull(window2.getScreen());
+ Assert.assertEquals(false,window2.isValid());
+ Assert.assertEquals(false,window2.isNativeValid());
+ Assert.assertEquals(false,window2.isVisible());
+
}
@Test
@@ -365,17 +380,7 @@ public class TestDisplayLifecycle02NEWT extends UITestCase {
}
System.err.println("durationPerTest: "+durationPerTest);
String tstname = TestDisplayLifecycle02NEWT.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" } );
+ org.junit.runner.JUnitCore.main(tstname);
}
}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestEventSourceNotAWTBug.java b/src/junit/com/jogamp/test/junit/newt/TestEventSourceNotAWTBug.java
index 8776b7be8..ff791b03a 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestEventSourceNotAWTBug.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestEventSourceNotAWTBug.java
@@ -88,7 +88,7 @@ public class TestEventSourceNotAWTBug extends UITestCase {
f_jf.dispose();
}
});
- glWindow.destroy(true);
+ glWindow.invalidate();
}
public static void main(String args[]) throws IOException {
diff --git a/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java
index 762e906fc..d597af889 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestFocus01SwingAWTRobot.java
@@ -175,7 +175,7 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
// Shutdown the test.
animator.stop();
frame1.dispose();
- glWindow1.destroy(true);
+ glWindow1.invalidate();
}
static int atoi(String a) {
diff --git a/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java
index 3ce6080a9..b96279cac 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestFocus02SwingAWTRobot.java
@@ -261,7 +261,7 @@ public class TestFocus02SwingAWTRobot extends UITestCase {
_jFrame1.dispose();
} });
- glWindow1.destroy(true);
+ glWindow1.invalidate();
}
@Test
diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows00NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows00NEWT.java
index 5568f2e1a..d28dd2c11 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows00NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestGLWindows00NEWT.java
@@ -87,8 +87,9 @@ public class TestGLWindows00NEWT extends UITestCase {
static void destroyWindow(GLWindow glWindow) {
if(null!=glWindow) {
- glWindow.destroy(true);
+ glWindow.invalidate();
Assert.assertEquals(false,glWindow.isNativeValid());
+ Assert.assertEquals(false,glWindow.isValid());
}
}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java
index 279f2c370..934d75f7c 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java
@@ -71,15 +71,11 @@ public class TestGLWindows01NEWT extends UITestCase {
//
GLWindow glWindow;
if(null!=screen) {
- boolean destroyWhenUnused = screen.getDestroyWhenUnused();
- Assert.assertEquals(destroyWhenUnused, screen.getDisplay().getDestroyWhenUnused());
glWindow = GLWindow.create(screen, caps);
Assert.assertNotNull(glWindow);
- Assert.assertEquals(destroyWhenUnused, glWindow.getScreen().getDestroyWhenUnused());
} else {
glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
- Assert.assertTrue(glWindow.getScreen().getDestroyWhenUnused());
}
glWindow.setUndecorated(onscreen && undecorated);
@@ -121,18 +117,11 @@ public class TestGLWindows01NEWT extends UITestCase {
return glWindow;
}
- static void destroyWindow(GLWindow glWindow, Screen screen, Display display, boolean unrecoverable) {
+ static void destroyWindow(GLWindow glWindow) {
if(null!=glWindow) {
- glWindow.destroy(unrecoverable);
+ glWindow.invalidate();
Assert.assertEquals(false,glWindow.isNativeValid());
- }
- if(null!=screen) {
- screen.destroy();
- Assert.assertEquals(false,screen.isNativeValid());
- }
- if(null!=display) {
- display.destroy();
- Assert.assertEquals(false,display.isNativeValid());
+ Assert.assertEquals(false,glWindow.isValid());
}
}
@@ -146,7 +135,7 @@ public class TestGLWindows01NEWT extends UITestCase {
Assert.assertEquals(true,window.isNativeValid());
Assert.assertEquals(true,window.isVisible());
- window.destroy(false);
+ window.destroy();
Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
@@ -162,7 +151,7 @@ public class TestGLWindows01NEWT extends UITestCase {
Assert.assertEquals(true,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
- destroyWindow(window, null, null, true);
+ destroyWindow(window);
}
@Test
@@ -175,7 +164,7 @@ public class TestGLWindows01NEWT extends UITestCase {
Assert.assertEquals(true,window.isNativeValid());
Assert.assertEquals(true,window.isVisible());
- window.destroy(false);
+ window.destroy();
Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
@@ -191,7 +180,7 @@ public class TestGLWindows01NEWT extends UITestCase {
Assert.assertEquals(true,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
- destroyWindow(window, null, null, true);
+ destroyWindow(window);
}
@Test
@@ -207,7 +196,7 @@ public class TestGLWindows01NEWT extends UITestCase {
Thread.sleep(100);
}
System.out.println("duration: "+window.getDuration());
- destroyWindow(window, null, null, true);
+ destroyWindow(window);
}
@Test
@@ -223,7 +212,7 @@ public class TestGLWindows01NEWT extends UITestCase {
Thread.sleep(100);
}
System.out.println("duration: "+window.getDuration());
- destroyWindow(window, null, null, true);
+ destroyWindow(window);
}
@Test
@@ -238,8 +227,7 @@ public class TestGLWindows01NEWT extends UITestCase {
Thread.sleep(100);
}
System.out.println("duration: "+window.getDuration());
- destroyWindow(window, null, null, false);
- destroyWindow(window, null, null, true);
+ destroyWindow(window);
}
@Test
@@ -249,7 +237,6 @@ public class TestGLWindows01NEWT extends UITestCase {
Display display = NewtFactory.createDisplay(null); // local display
Assert.assertNotNull(display);
- display.setDestroyWhenUnused(true);
Screen screen = NewtFactory.createScreen(display, 0); // screen 0
Assert.assertNotNull(screen);
@@ -279,8 +266,8 @@ public class TestGLWindows01NEWT extends UITestCase {
System.out.println("duration1: "+window1.getDuration());
System.out.println("duration2: "+window2.getDuration());
- destroyWindow(window1, null, null, true);
- destroyWindow(window2, null, null, true);
+ destroyWindow(window1);
+ destroyWindow(window2);
Assert.assertEquals(0,Display.getActiveDisplayNumber());
@@ -300,10 +287,8 @@ public class TestGLWindows01NEWT extends UITestCase {
Display display1 = NewtFactory.createDisplay(null, false); // local display
Assert.assertNotNull(display1);
- display1.setDestroyWhenUnused(true);
Display display2 = NewtFactory.createDisplay(null, false); // local display
Assert.assertNotNull(display2);
- display2.setDestroyWhenUnused(true);
Assert.assertNotSame(display1, display2);
Screen screen1 = NewtFactory.createScreen(display1, 0); // screen 0
@@ -349,8 +334,8 @@ public class TestGLWindows01NEWT extends UITestCase {
// opening them, otherwise some driver related bug appears.
// You may test this, ie just reverse the destroy order below.
// See also native test: jogl/test/native/displayMultiple02.c
- destroyWindow(window1, null, null, true);
- destroyWindow(window2, null, null, true);
+ destroyWindow(window1);
+ destroyWindow(window2);
Assert.assertEquals(0,Display.getActiveDisplayNumber());
@@ -393,17 +378,7 @@ public class TestGLWindows01NEWT extends UITestCase {
}
System.out.println("durationPerTest: "+durationPerTest);
String tstname = TestGLWindows01NEWT.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" } );
+ org.junit.runner.JUnitCore.main(tstname);
}
}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java
index a6809e0bd..78b9773a8 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java
@@ -114,9 +114,9 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
return glWindow;
}
- static void destroyWindow(GLWindow glWindow, boolean deep) {
+ static void destroyWindow(GLWindow glWindow) {
if(null!=glWindow) {
- glWindow.destroy(deep);
+ glWindow.destroy();
}
}
@@ -130,7 +130,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
while(animator.isAnimating() && animator.getDuration()<durationPerTest) {
Thread.sleep(100);
}
- destroyWindow(window, true);
+ destroyWindow(window);
Assert.assertEquals(false, animator.isAnimating());
}
@@ -144,8 +144,8 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
while(animator.isAnimating() && animator.getDuration()<durationPerTest) {
Thread.sleep(100);
}
- destroyWindow(window, false);
- destroyWindow(window, true);
+ destroyWindow(window);
+ destroyWindow(window);
Assert.assertEquals(false, animator.isAnimating());
}
@@ -175,10 +175,10 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
Thread.sleep(100);
}
- destroyWindow(window1, true);
+ destroyWindow(window1);
Assert.assertEquals(false, animator1.isAnimating());
- destroyWindow(window2, true);
+ destroyWindow(window2);
Assert.assertEquals(false, animator2.isAnimating());
}
@Test
@@ -212,10 +212,10 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
Thread.sleep(100);
}
- destroyWindow(window1, true);
+ destroyWindow(window1);
Assert.assertEquals(false, animator1.isAnimating());
- destroyWindow(window2, true);
+ destroyWindow(window2);
Assert.assertEquals(false, animator2.isAnimating());
}
@@ -242,17 +242,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
}
}
String tstname = TestGLWindows02NEWTAnimated.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" } );
+ org.junit.runner.JUnitCore.main(tstname);
}
}
diff --git a/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java b/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java
index 39eb47ca9..4407ffef1 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestListenerCom01AWT.java
@@ -119,7 +119,7 @@ public class TestListenerCom01AWT extends UITestCase {
Assert.assertEquals(false, animator1.isAnimating());
frame.dispose();
- glWindow.destroy(true);
+ glWindow.invalidate();
}
public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
diff --git a/src/junit/com/jogamp/test/junit/newt/TestRemoteGLWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestRemoteGLWindows01NEWT.java
index 623651f2d..fc5327c9d 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestRemoteGLWindows01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestRemoteGLWindows01NEWT.java
@@ -88,8 +88,9 @@ public class TestRemoteGLWindows01NEWT extends UITestCase {
static void destroyWindow(GLWindow glWindow) {
if(null!=glWindow) {
- glWindow.destroy(true);
+ glWindow.invalidate();
Assert.assertEquals(false,glWindow.isNativeValid());
+ Assert.assertEquals(false,glWindow.isValid());
}
}
@@ -109,7 +110,6 @@ public class TestRemoteGLWindows01NEWT extends UITestCase {
// Eager initialization of NEWT Display -> AbstractGraphicsDevice -> GLProfile (device)
Display display2 = NewtFactory.createDisplay("charelle:0.0"); // remote display
- display2.setDestroyWhenUnused(true);
try {
display2.createNative();
} catch (NativeWindowException nwe) {
diff --git a/src/junit/com/jogamp/test/junit/newt/TestScreenMode00NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestScreenMode00NEWT.java
index 06911e82b..9f39274c5 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestScreenMode00NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestScreenMode00NEWT.java
@@ -120,9 +120,12 @@ public class TestScreenMode00NEWT extends UITestCase {
Assert.assertNotNull(sm_c);
System.err.println("orig: "+sm_o);
System.err.println("curr: "+sm_c);
+ } else {
+ // no support ..
+ System.err.println("Your platform has no ScreenMode change support, sorry");
}
- window.destroy(true);
+ window.invalidate();
Assert.assertEquals(false,window.isVisible());
Assert.assertEquals(false,window.isNativeValid());
diff --git a/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java
index fe17857ef..de4def2fa 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestScreenMode01NEWT.java
@@ -72,26 +72,18 @@ public class TestScreenMode01NEWT extends UITestCase {
Assert.assertNotNull(caps);
caps.setOnscreen(onscreen);
- boolean destroyWhenUnused = screen.getDestroyWhenUnused();
GLWindow window = GLWindow.create(screen, caps);
window.setSize(width, height);
window.addGLEventListener(new Gears());
Assert.assertNotNull(window);
- Assert.assertEquals(destroyWhenUnused, window.getScreen().getDestroyWhenUnused());
window.setVisible(true);
return window;
}
- static void destroyWindow(Display display, Screen screen, Window window) {
+ static void destroyWindow(Window window) {
if(null!=window) {
window.destroy();
}
- if(null!=screen) {
- screen.destroy();
- }
- if(null!=display) {
- display.destroy();
- }
}
@Test
@@ -118,7 +110,7 @@ public class TestScreenMode01NEWT extends UITestCase {
Thread.sleep(waitTimeShort);
animator.stop();
- destroyWindow(display, screen, window);
+ destroyWindow(window);
}
@Test
@@ -137,7 +129,8 @@ public class TestScreenMode01NEWT extends UITestCase {
List screenModes = screen.getScreenModes();
if(null==screenModes) {
// no support ..
- destroyWindow(display, screen, window);
+ System.err.println("Your platform has no ScreenMode change support, sorry");
+ destroyWindow(window);
return;
}
Assert.assertTrue(screenModes.size()>0);
@@ -183,15 +176,14 @@ public class TestScreenMode01NEWT extends UITestCase {
Assert.assertEquals(true,window.isVisible());
animator.stop();
- destroyWindow(null, screen, window);
+ destroyWindow(window);
Assert.assertEquals(false,window.isVisible());
Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,screen.isNativeValid());
- Assert.assertEquals(true,display.isNativeValid());
+ Assert.assertEquals(false,display.isNativeValid());
- screen = NewtFactory.createScreen(display, 0); // screen 0
- screen.addReference(); // trigger native creation
+ screen.createNative(); // trigger native re-creation
Assert.assertEquals(true,display.isNativeValid());
Assert.assertEquals(true,screen.isNativeValid());
@@ -202,7 +194,7 @@ public class TestScreenMode01NEWT extends UITestCase {
Assert.assertNotNull(smCurrent);
Assert.assertEquals(saveOrigMode, smOrig);
- destroyWindow(display, screen, null);
+ screen.destroy();
Assert.assertEquals(false,screen.isNativeValid());
Assert.assertEquals(false,display.isNativeValid());
@@ -236,7 +228,7 @@ public class TestScreenMode01NEWT extends UITestCase {
List screenModes = screen.getScreenModes();
if(null==screenModes) {
// no support ..
- destroyWindow(display, screen, window);
+ destroyWindow(window);
return;
}
Assert.assertTrue(screenModes.size()>0);
@@ -272,10 +264,9 @@ public class TestScreenMode01NEWT extends UITestCase {
ScreenMode saveOrigMode = (ScreenMode) smOrig.clone();
animator.stop();
- destroyWindow(null, screen, window);
+ destroyWindow(window);
- screen = NewtFactory.createScreen(display, 0); // screen 0
- screen.addReference(); // trigger native creation
+ screen.createNative(); // trigger native re-creation
ScreenMode smCurrent = screen.getCurrentScreenMode();
System.err.println("[1] current/orig: "+smCurrent);
@@ -283,7 +274,7 @@ public class TestScreenMode01NEWT extends UITestCase {
Assert.assertNotNull(smCurrent);
Assert.assertEquals(saveOrigMode, smOrig);
- destroyWindow(display, screen, null);
+ screen.destroy();
}
public static void main(String args[]) throws IOException {
diff --git a/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java
index 98c8fd58c..011af6330 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestScreenMode02NEWT.java
@@ -70,26 +70,19 @@ public class TestScreenMode02NEWT extends UITestCase {
Assert.assertNotNull(caps);
caps.setOnscreen(onscreen);
- boolean destroyWhenUnused = screen.getDestroyWhenUnused();
GLWindow window = GLWindow.create(screen, caps);
window.setSize(width, height);
window.addGLEventListener(new Gears());
Assert.assertNotNull(window);
- Assert.assertEquals(destroyWhenUnused, window.getScreen().getDestroyWhenUnused());
window.setVisible(true);
+ Assert.assertTrue(window.isVisible());
return window;
}
- static void destroyWindow(Display display, Screen screen, Window window) {
+ static void destroyWindow(Window window) {
if(null!=window) {
window.destroy();
}
- if(null!=screen) {
- screen.destroy();
- }
- if(null!=display) {
- display.destroy();
- }
}
@Test
@@ -108,7 +101,8 @@ public class TestScreenMode02NEWT extends UITestCase {
List screenModes = screen.getScreenModes();
if(null==screenModes) {
// no support ..
- destroyWindow(display, screen, window);
+ System.err.println("Your platform has no ScreenMode change support, sorry");
+ destroyWindow(window);
return;
}
Assert.assertTrue(screenModes.size()>0);
@@ -129,7 +123,8 @@ public class TestScreenMode02NEWT extends UITestCase {
screenModes = ScreenModeUtil.filterByRotation(screenModes, 90);
if(null==screenModes) {
// no rotation support ..
- destroyWindow(display, screen, window);
+ System.err.println("Your platform has no rotation support, sorry");
+ destroyWindow(window);
return;
}
Assert.assertTrue(screenModes.size()>0);
@@ -158,15 +153,14 @@ public class TestScreenMode02NEWT extends UITestCase {
Assert.assertEquals(true,window.isVisible());
animator.stop();
- destroyWindow(null, screen, window);
+ destroyWindow(window);
Assert.assertEquals(false,window.isVisible());
Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,screen.isNativeValid());
- Assert.assertEquals(true,display.isNativeValid());
+ Assert.assertEquals(false,display.isNativeValid());
- screen = NewtFactory.createScreen(display, 0); // screen 0
- screen.addReference(); // trigger native creation
+ screen.createNative(); // trigger native re-creation
Assert.assertEquals(true,display.isNativeValid());
Assert.assertEquals(true,screen.isNativeValid());
@@ -177,7 +171,7 @@ public class TestScreenMode02NEWT extends UITestCase {
Assert.assertNotNull(smCurrent);
Assert.assertEquals(saveOrigMode, smOrig);
- destroyWindow(display, screen, null);
+ screen.destroy();
Assert.assertEquals(false,screen.isNativeValid());
Assert.assertEquals(false,display.isNativeValid());
diff --git a/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java
index 88edd89ba..706ad5192 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java
@@ -173,17 +173,7 @@ public class TestWindows01NEWT extends UITestCase {
public static void main(String args[]) throws IOException {
String tstname = TestWindows01NEWT.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" } );
+ org.junit.runner.JUnitCore.main(tstname);
}
}
diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java
index b9182dbaa..1f45c6c1d 100644
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java
@@ -78,7 +78,6 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertNull(glWindow1.getParent());
screen = glWindow1.getScreen();
display = screen.getDisplay();
- Assert.assertEquals(true,display.getDestroyWhenUnused());
Assert.assertEquals(0,display.getReferenceCount());
Assert.assertEquals(false,display.isNativeValid());
Assert.assertNotNull(display.getEDTUtil());
@@ -105,7 +104,6 @@ public class TestParenting01NEWT extends UITestCase {
setDemoFields(demo2, glWindow2, false);
glWindow2.addGLEventListener(demo2);
- Assert.assertEquals(true,display.getDestroyWhenUnused());
Assert.assertEquals(0,display.getReferenceCount());
Assert.assertEquals(false,display.isNativeValid());
Assert.assertNotNull(display.getEDTUtil());
@@ -226,7 +224,7 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertEquals(true,display.isNativeValid());
Assert.assertNotNull(display.getEDTUtil());
Assert.assertEquals(true,display.getEDTUtil().isRunning());
- Assert.assertEquals(2,screen.getReferenceCount());
+ Assert.assertEquals(1,screen.getReferenceCount());
Assert.assertEquals(true,screen.isNativeValid());
Assert.assertEquals(1,Display.getActiveDisplayNumber());
@@ -238,13 +236,13 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertEquals(false, glWindow2.isNativeValid());
Assert.assertEquals(true, glWindow2.isValid());
- Assert.assertEquals(1,display.getReferenceCount());
- Assert.assertEquals(true,display.isNativeValid());
+ Assert.assertEquals(0,display.getReferenceCount());
+ Assert.assertEquals(false,display.isNativeValid());
Assert.assertNotNull(display.getEDTUtil());
- Assert.assertEquals(true,display.getEDTUtil().isRunning());
- Assert.assertEquals(2,screen.getReferenceCount());
- Assert.assertEquals(true,screen.isNativeValid());
- Assert.assertEquals(1,Display.getActiveDisplayNumber());
+ Assert.assertEquals(false,display.getEDTUtil().isRunning());
+ Assert.assertEquals(0,screen.getReferenceCount());
+ Assert.assertEquals(false,screen.isNativeValid());
+ Assert.assertEquals(0,Display.getActiveDisplayNumber());
// recreation ..
glWindow1.resetCounter();
@@ -269,11 +267,11 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertEquals(true,screen.isNativeValid());
Assert.assertEquals(1,Display.getActiveDisplayNumber());
- // cannot be recreated, will drop Display/Screen refs
- glWindow1.destroy(true);
- Assert.assertEquals(false, glWindow1.isValid());
+ // chain glwindow1 -> glwindow2 ; can be recreated ..
+ glWindow1.destroy();
+ Assert.assertEquals(true, glWindow1.isValid());
Assert.assertEquals(false, glWindow1.isNativeValid());
- Assert.assertEquals(false, glWindow2.isValid());
+ Assert.assertEquals(true, glWindow2.isValid());
Assert.assertEquals(false, glWindow2.isNativeValid());
Assert.assertEquals(0,display.getReferenceCount());
Assert.assertEquals(false,display.isNativeValid());
@@ -283,9 +281,13 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertEquals(false,screen.isNativeValid());
Assert.assertEquals(0,Display.getActiveDisplayNumber());
- // test double destroy ..
- glWindow2.destroy(true);
- Assert.assertEquals(false, glWindow2.isValid());
+ glWindow1.invalidate();
+ Assert.assertEquals(false, glWindow1.isValid());
+ Assert.assertEquals(false, glWindow2.isValid());
+
+ // test double destroy/invalidate ..
+ glWindow2.invalidate();
+ Assert.assertEquals(false, glWindow2.isValid());
Assert.assertEquals(0,display.getReferenceCount());
Assert.assertEquals(false,display.isNativeValid());
@@ -328,7 +330,6 @@ public class TestParenting01NEWT extends UITestCase {
screen1 = glWindow1.getScreen();
display1 = screen1.getDisplay();
- Assert.assertEquals(true,display1.getDestroyWhenUnused());
Assert.assertEquals(0,display1.getReferenceCount());
Assert.assertEquals(false,display1.isNativeValid());
Assert.assertNotNull(display1.getEDTUtil());
@@ -345,7 +346,6 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertSame(screen1, glWindow2.getScreen());
Assert.assertSame(display1, glWindow2.getScreen().getDisplay());
- Assert.assertEquals(true,display1.getDestroyWhenUnused());
Assert.assertEquals(0,display1.getReferenceCount());
Assert.assertEquals(false,display1.isNativeValid());
Assert.assertNotNull(display1.getEDTUtil());
@@ -442,6 +442,10 @@ public class TestParenting01NEWT extends UITestCase {
}
state++;
}
+ //
+ // both windows are now top level
+ //
+
animator1.stop();
Assert.assertEquals(false, animator1.isAnimating());
Assert.assertEquals(false, animator1.isPaused());
@@ -461,9 +465,13 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertEquals(1,Display.getActiveDisplayNumber());
// destroy glWindow2
- glWindow2.destroy(true);
+ glWindow2.destroy();
Assert.assertEquals(true, glWindow1.isValid());
- Assert.assertEquals(false, glWindow2.isValid());
+ Assert.assertEquals(true, glWindow1.isNativeValid());
+ Assert.assertEquals(true, glWindow1.isVisible());
+ Assert.assertEquals(true, glWindow2.isValid());
+ Assert.assertEquals(false, glWindow2.isNativeValid());
+ Assert.assertEquals(false, glWindow2.isVisible());
Assert.assertEquals(1,display1.getReferenceCount());
Assert.assertEquals(true,display1.isNativeValid());
@@ -475,9 +483,13 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertEquals(1,Display.getActiveDisplayNumber());
// destroy glWindow1
- glWindow1.destroy(true);
- Assert.assertEquals(false, glWindow1.isValid());
- Assert.assertEquals(false, glWindow2.isValid());
+ glWindow1.destroy();
+ Assert.assertEquals(true, glWindow1.isValid());
+ Assert.assertEquals(false, glWindow1.isNativeValid());
+ Assert.assertEquals(false, glWindow1.isVisible());
+ Assert.assertEquals(true, glWindow2.isValid());
+ Assert.assertEquals(false, glWindow2.isNativeValid());
+ Assert.assertEquals(false, glWindow2.isVisible());
Assert.assertEquals(0,display1.getReferenceCount());
Assert.assertEquals(false,display1.isNativeValid());
@@ -487,6 +499,13 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertEquals(false,screen1.isNativeValid());
Assert.assertEquals(0,Display.getActiveDisplayNumber());
+
+ glWindow1.invalidate();
+ Assert.assertEquals(false, glWindow1.isValid());
+ Assert.assertEquals(true, glWindow2.isValid());
+
+ glWindow2.invalidate();
+ Assert.assertEquals(false, glWindow2.isValid());
}
@Test
@@ -520,7 +539,6 @@ public class TestParenting01NEWT extends UITestCase {
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
- Assert.assertEquals(true,display1.getDestroyWhenUnused());
Assert.assertEquals(0,display1.getReferenceCount());
Assert.assertEquals(false,display1.isNativeValid());
Assert.assertNotNull(display1.getEDTUtil());
@@ -537,7 +555,6 @@ public class TestParenting01NEWT extends UITestCase {
setDemoFields(demo2, glWindow2, false);
glWindow2.addGLEventListener(demo2);
- Assert.assertEquals(true,display2.getDestroyWhenUnused());
Assert.assertEquals(0,display2.getReferenceCount());
Assert.assertEquals(false,display2.isNativeValid());
Assert.assertNotNull(display2.getEDTUtil());
@@ -556,7 +573,6 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertTrue(0 < glWindow2.getTotalFrames());
Assert.assertTrue(0 < glWindow1.getTotalFrames());
- Assert.assertEquals(true,display1.getDestroyWhenUnused());
Assert.assertEquals(1,display1.getReferenceCount());
Assert.assertEquals(true,display1.isNativeValid());
Assert.assertNotNull(display1.getEDTUtil());
@@ -606,6 +622,10 @@ public class TestParenting01NEWT extends UITestCase {
}
state++;
}
+ //
+ // glwindow2 is child of glwindow1
+ //
+
animator1.stop();
Assert.assertEquals(false, animator1.isAnimating());
Assert.assertEquals(false, animator1.isPaused());
@@ -615,7 +635,6 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertEquals(false, animator2.isPaused());
Assert.assertEquals(null, animator2.getThread());
- Assert.assertEquals(true,display1.getDestroyWhenUnused());
Assert.assertEquals(1,display1.getReferenceCount());
Assert.assertEquals(true,display1.isNativeValid());
Assert.assertNotNull(display1.getEDTUtil());
@@ -627,11 +646,14 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertEquals(1,Display.getActiveDisplayNumber());
- glWindow1.destroy(true); // should destroy both windows, actually, since glWindow2 is a child
- Assert.assertEquals(false, glWindow1.isValid());
- Assert.assertEquals(false, glWindow2.isValid());
+ glWindow1.destroy(); // should destroy both windows, actually, since glWindow2 is a child
+ Assert.assertEquals(true, glWindow1.isValid());
+ Assert.assertEquals(false, glWindow1.isNativeValid());
+ Assert.assertEquals(false, glWindow1.isVisible());
+ Assert.assertEquals(true, glWindow2.isValid());
+ Assert.assertEquals(false, glWindow2.isNativeValid());
+ Assert.assertEquals(false, glWindow2.isVisible());
- Assert.assertEquals(true,display1.getDestroyWhenUnused());
Assert.assertEquals(0,display1.getReferenceCount());
Assert.assertEquals(false,display1.isNativeValid());
Assert.assertNotNull(display1.getEDTUtil());
@@ -639,7 +661,6 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertEquals(0,screen1.getReferenceCount());
Assert.assertEquals(false,screen1.isNativeValid());
- Assert.assertEquals(true,display2.getDestroyWhenUnused());
Assert.assertEquals(0,display2.getReferenceCount());
Assert.assertEquals(false,display2.isNativeValid());
Assert.assertNotNull(display2.getEDTUtil());
@@ -649,7 +670,11 @@ public class TestParenting01NEWT extends UITestCase {
Assert.assertEquals(0,Display.getActiveDisplayNumber());
- glWindow2.destroy(true);
+ glWindow2.destroy(); // dbl destroy check ..
+ Assert.assertEquals(false, glWindow1.isNativeValid());
+ Assert.assertEquals(false, glWindow2.isNativeValid());
+
+ glWindow1.invalidate(); // parent -> child
Assert.assertEquals(false, glWindow1.isValid());
Assert.assertEquals(false, glWindow2.isValid());
@@ -698,3 +723,4 @@ public class TestParenting01NEWT extends UITestCase {
}
}
+
diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java
index 931cf2d5f..2c3455cb0 100644
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01aAWT.java
@@ -143,7 +143,7 @@ public class TestParenting01aAWT extends UITestCase {
frame1.dispose();
Assert.assertEquals(true, glWindow1.isValid());
- glWindow1.destroy(true);
+ glWindow1.invalidate();
//Assert.assertEquals(false, glWindow1.isValid());
}
@@ -188,7 +188,7 @@ public class TestParenting01aAWT extends UITestCase {
Assert.assertEquals(false, animator1.isAnimating());
frame.dispose();
- glWindow1.destroy(true);
+ glWindow1.invalidate();
}
@Test
@@ -223,7 +223,7 @@ public class TestParenting01aAWT extends UITestCase {
Assert.assertEquals(true, animator1.isAnimating()); // !!!
frame.dispose();
- glWindow1.destroy(true);
+ glWindow1.invalidate();
}
@Test
@@ -273,7 +273,7 @@ public class TestParenting01aAWT extends UITestCase {
Assert.assertEquals(false, animator1.isAnimating());
frame.dispose();
- glWindow1.destroy(true);
+ glWindow1.invalidate();
}
@Test
@@ -328,7 +328,7 @@ public class TestParenting01aAWT extends UITestCase {
Assert.assertEquals(false, animator1.isAnimating());
frame.dispose();
- glWindow1.destroy(true);
+ glWindow1.invalidate();
}
@Test
@@ -393,7 +393,7 @@ public class TestParenting01aAWT extends UITestCase {
frame1.dispose();
frame2.dispose();
- glWindow1.destroy(true);
+ glWindow1.invalidate();
}
public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java
index 9eecf31a1..89cefa8b1 100644
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01bAWT.java
@@ -156,7 +156,7 @@ public class TestParenting01bAWT extends UITestCase {
frame1.dispose();
frame2.dispose();
- glWindow1.destroy(true);
+ glWindow1.invalidate();
}
public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java
index 2dcc7af9b..b79f4c57c 100644
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cAWT.java
@@ -137,7 +137,7 @@ public class TestParenting01cAWT extends UITestCase {
frame1.dispose();
Assert.assertEquals(true, glWindow1.isValid());
- glWindow1.destroy(true);
+ glWindow1.invalidate();
//Assert.assertEquals(false, glWindow1.isValid());
}
@@ -196,7 +196,7 @@ public class TestParenting01cAWT extends UITestCase {
frame1.dispose();
frame2.dispose();
- glWindow1.destroy(true);
+ glWindow1.invalidate();
}
public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java
index 3fc39a3f1..ec54a0f9e 100644
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01cSwingAWT.java
@@ -189,7 +189,7 @@ public class TestParenting01cSwingAWT extends UITestCase {
} });
Assert.assertEquals(true, glWindow1.isValid());
- glWindow1.destroy(true);
+ glWindow1.invalidate();
//Assert.assertEquals(false, glWindow1.isValid());
}
@@ -324,7 +324,7 @@ public class TestParenting01cSwingAWT extends UITestCase {
} });
Assert.assertEquals(true, glWindow1.isValid());
- glWindow1.destroy(true);
+ glWindow1.invalidate();
//Assert.assertEquals(false, glWindow1.isValid());
}
diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java
index 3311bc691..6c9e5b2b2 100644
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting02AWT.java
@@ -213,7 +213,7 @@ public class TestParenting02AWT extends UITestCase {
}
Thread.sleep(waitReparent);
- glWindow.destroy(true);
+ glWindow.invalidate();
if(useLayout) {
frame.remove(newtCanvasAWT);
}
diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java
index 5fa7dee41..61086099c 100644
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java
@@ -152,7 +152,7 @@ public class TestParenting03AWT extends UITestCase {
Assert.assertEquals(null, animator1.getThread());
frame1.dispose();
- glWindow1.destroy(true);
+ glWindow1.invalidate();
}
public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
diff --git a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03bAWT.java b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03bAWT.java
index b4ced6973..a31e49b45 100644
--- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03bAWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03bAWT.java
@@ -206,8 +206,8 @@ public class TestParenting03bAWT extends UITestCase {
Assert.assertEquals(null, animator2.getThread());
frame1.dispose();
- glWindow1.destroy(true);
- glWindow2.destroy(true);
+ glWindow1.invalidate();
+ glWindow2.invalidate();
}
public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java
index 19733723e..3e5c0c25e 100644
--- a/src/newt/classes/com/jogamp/newt/Display.java
+++ b/src/newt/classes/com/jogamp/newt/Display.java
@@ -54,43 +54,39 @@ public abstract class Display {
}
/**
- * Manual trigger the native creation.<br>
+ * Manual trigger the native creation, if it is not done yet.<br>
* This is useful to be able to request the {@link javax.media.nativewindow.AbstractGraphicsDevice}, via
- * {@link #getGraphicsDevice()}. Otherwise the abstract device won't be available before the dependent components (Screen and Window)
- * are realized.
+ * {@link #getGraphicsDevice()}.<br>
+ * Otherwise the abstract device won't be available before the dependent components (Screen and Window) are realized.
+ * <p>
+ * This method is usually invoke by {@link #addReference()}
+ * </p>
* @throws NativeWindowException if the native creation failed.
*/
public abstract void createNative() throws NativeWindowException;
- public abstract void destroy();
-
/**
- * @return true if the native display handle is valid and ready to operate,
- * otherwise false.
- *
- * @see #destroy()
+ * Manually trigger the destruction, incl. native destruction.<br>
+ * <p>
+ * This method is usually invoke by {@link #removeReference()}
+ * </p>
*/
- public abstract boolean isNativeValid();
+ public abstract void destroy();
/**
- * @return the value set by {@link #setDestroyWhenUnused(boolean)}
- * or the default <code>false</code>.
- *
- * @see #addReference()
- * @see #removeReference()
+ * Validate EDT running state.<br>
+ * Stop the running EDT in case this display is destroyed already.<br>
+ * @return true if EDT has been stopped (destroyed but running), otherwise false.
*/
- public abstract boolean getDestroyWhenUnused();
+ public abstract boolean validateEDT();
/**
- * Handles the lifecycle of the native Display instance.<br>
- * If set to <code>true</code>, the last {@link #removeReference()} call
- * will destroy this instance, otherwise it will stay alive.<br>
- * Default is <code>false</code>.
+ * @return true if the native display handle is valid and ready to operate,
+ * otherwise false.
*
- * @see #addReference()
- * @see #removeReference()
+ * @see #destroy()
*/
- public abstract void setDestroyWhenUnused(boolean v);
+ public abstract boolean isNativeValid();
/**
* @return number of references by Screen
diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java
index e1b15da69..892a2426e 100644
--- a/src/newt/classes/com/jogamp/newt/NewtFactory.java
+++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java
@@ -162,7 +162,6 @@ public class NewtFactory {
Display display = NewtFactory.createDisplay(type, null, true); // local display
screen = NewtFactory.createScreen(display, 0); // screen 0
}
- screen.setDestroyWhenUnused(true);
}
final Window win = createWindowImpl(nParentWindow, screen, caps);
@@ -189,7 +188,6 @@ public class NewtFactory {
protected static Window createWindowImpl(String type, Capabilities caps) {
Display display = NewtFactory.createDisplay(type, null, true); // local display
Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- screen.setDestroyWhenUnused(true);
return WindowImpl.create(null, 0, screen, caps);
}
diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java
index a6d45d789..bf8c6f0eb 100644
--- a/src/newt/classes/com/jogamp/newt/Screen.java
+++ b/src/newt/classes/com/jogamp/newt/Screen.java
@@ -59,38 +59,36 @@ public abstract class Screen {
}
/**
- * Manual trigger the native creation.<br>
+ * Manual trigger the native creation, if it is not done yet..<br>
* This is useful to be able to request the {@link javax.media.nativewindow.AbstractGraphicsScreen}, via
- * {@link #getGraphicsScreen()}. Otherwise the abstract device won't be available before the dependent component (Window)
- * is realized.
+ * {@link #getGraphicsScreen()}.<br>
+ * Otherwise the abstract device won't be available before the dependent component (Window) is realized.
+ * <p>
+ * This method is usually invoke by {@link #addReference()}
+ * </p>
+ * <p>
+ * This method invokes {@link Display#addReference()} after creating the native peer,<br>
+ * which will issue {@link Display#createNative()} if the reference count was 0.
+ * </p>
* @throws NativeWindowException if the native creation failed.
*/
public abstract void createNative() throws NativeWindowException;
- public abstract void destroy();
-
- public abstract boolean isNativeValid();
-
/**
- * @return {@link Display#getDestroyWhenUnused()}
- *
- * @see #addReference()
- * @see #removeReference()
- * @see Display#setDestroyWhenUnused(boolean)
+ * Manually trigger the destruction, incl. native destruction.<br>
+ * <p>
+ * This method is usually invoke by {@link #removeReference()}
+ * </p>
+ * <p>
+ * This method invokes {@link Display#removeReference()} after it's own destruction,<br>
+ * which will issue {@link Display#destroy()} if the reference count becomes 0.
+ * </p>
*/
- public abstract boolean getDestroyWhenUnused();
+ public abstract void destroy();
- /**
- * calls {@link Display#setDestroyWhenUnused(boolean)}.
- *
- * @see #addReference()
- * @see #removeReference()
- * @see Display#setDestroyWhenUnused(boolean)
- */
- public abstract void setDestroyWhenUnused(boolean v);
+ public abstract boolean isNativeValid();
/**
- *
* @return number of references by Window
*/
public abstract int getReferenceCount();
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index ba7d51e67..9307ea7f7 100644
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -87,30 +87,24 @@ public interface Window extends NativeWindow, ScreenModeListener {
Capabilities getChosenCapabilities();
/**
- *
- * <p>
- * destroys the window and children and releases
- * windowing related resources.<br></p>
+ * Destroy the Window and it's children, incl. native destruction.<br>
+ * The Window can be recreate via {@link #setVisible(boolean) setVisible(true)}.
* <p>
- * all other resources and states are kept intact,
- * ie listeners, parent handles, size, position and Screen reference.<br></p>
- *
- * @see #destroy(boolean)
+ * This method invokes {@link Screen#removeReference()} after it's own destruction,<br>
+ * which will issue {@link Screen#destroy()} if the reference count becomes 0.<br>
+ * This destruction sequence shall end up in {@link Display#destroy()}, if all reference counts become 0.
+ * </p>
* @see #invalidate()
+ * @see #setVisible(boolean)
*/
void destroy();
/**
- *
- * Destroys the Window and it's children.
- * @param unrecoverable If true, all resources, ie listeners, parent handles,
- * size, position and reference to it's Screen will be destroyed as well.
- * Otherwise you can recreate the window, via <code>setVisible(true)</code>.
- * @see #destroy()
- * @see #invalidate(boolean)
- * @see #setVisible(boolean)
+ * Destroys the Window via {@link #destroy()} and clears all Object references,
+ * eg. all states, size, position, parent handles, list of child Windows and reference to it's Screen.<br>
+ * This Window cannot be recreated after calling this method anymore.<br>
*/
- void destroy(boolean unrecoverable);
+ void invalidate();
/**
* <p>
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 3ba721855..a0ab5f9f6 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -193,37 +193,27 @@ public class NewtCanvasAWT extends java.awt.Canvas {
}
/**
- * @see #destroy(boolean)
- */
- public final void destroy() {
- destroy(false);
- }
-
- /**
* Destroys this resource:
* <ul>
* <li> Make the NEWT Child invisible </li>
* <li> Disconnects the NEWT Child from this Canvas NativeWindow, reparent to NULL </li>
- * <li> Issues <code>destroy(unrecoverable)</code> on the NEWT Child</li>
- * <li> Remove reference to the NEWT Child, if unrecoverable</li>
+ * <li> Issues <code>destroy()</code> on the NEWT Child</li>
+ * <li> Remove reference to the NEWT Child</li>
* <li> Remove this Canvas from it's parent.</li>
* </ul>
* @see Window#destroy()
- * @see Window#destroy(boolean)
*/
- public final void destroy(boolean unrecoverable) {
+ public final void destroy() {
if(null!=newtChild) {
java.awt.Container cont = getContainer(this);
if(DEBUG) {
- System.err.println("NewtCanvasAWT.destroy("+unrecoverable+"): "+newtChild+", from "+cont);
+ System.err.println("NewtCanvasAWT.destroy(): "+newtChild+", from "+cont);
}
nativeWindow = null;
newtChild.setVisible(false);
newtChild.reparentWindow(null);
- newtChild.destroy(unrecoverable);
- if(unrecoverable) {
- newtChild = null;
- }
+ newtChild.destroy();
+ newtChild=null;
if(null!=cont) {
cont.remove(this);
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/DefaultEDTUtil.java b/src/newt/classes/com/jogamp/newt/impl/DefaultEDTUtil.java
index e2b3b81ef..7a2a0c9bd 100644
--- a/src/newt/classes/com/jogamp/newt/impl/DefaultEDTUtil.java
+++ b/src/newt/classes/com/jogamp/newt/impl/DefaultEDTUtil.java
@@ -57,6 +57,7 @@ public class DefaultEDTUtil implements EDTUtil {
this.name=new String(Thread.currentThread().getName()+"-"+name+"-EDT-");
this.dispatchMessages=dispatchMessages;
this.edt = new EventDispatchThread(threadGroup, name);
+ this.edt.setDaemon(true); // don't stop JVM from shutdown ..
}
public final void reset() {
@@ -72,6 +73,7 @@ public class DefaultEDTUtil implements EDTUtil {
System.err.println(Thread.currentThread()+": EDT reset - edt: "+edt);
}
this.edt = new EventDispatchThread(threadGroup, name);
+ this.edt.setDaemon(true); // don't stop JVM from shutdown ..
}
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java b/src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java
index 7983a1118..2af01c217 100644
--- a/src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java
+++ b/src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java
@@ -181,13 +181,29 @@ public abstract class DisplayImpl extends Display {
}
}
+ public boolean validateEDT() {
+ if(0==refCount && null==aDevice && null != edtUtil && edtUtil.isRunning()) {
+ stopEDT( new Runnable() {
+ public void run() {
+ // nop
+ }
+ } );
+ edtUtil.waitUntilStopped();
+ edtUtil.reset();
+ return true;
+ }
+ return false;
+ }
+
public synchronized final void destroy() {
if(DEBUG) {
dumpDisplayList("Display.destroy("+getFQName()+") BEGIN");
}
synchronized(displayList) {
displayList.remove(this);
- displaysActive--;
+ if(0 < displaysActive) {
+ displaysActive--;
+ }
}
if(DEBUG) {
System.err.println("Display.destroy(): "+this+" "+getThreadName());
@@ -225,7 +241,7 @@ public abstract class DisplayImpl extends Display {
if(null == aDevice) {
throw new NativeWindowException ("Display.addReference() (refCount "+refCount+") null AbstractGraphicsDevice");
}
- return ++refCount;
+ return refCount++;
}
@@ -233,9 +249,10 @@ public abstract class DisplayImpl extends Display {
if(DEBUG) {
System.err.println("Display.removeReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount-1));
}
- refCount--; // could become < 0, in case of forced destruction without actual creation/addReference
- if(0>=refCount && getDestroyWhenUnused()) {
+ refCount--; // could become < 0, in case of manual destruction without actual creation/addReference
+ if(0>=refCount) {
destroy();
+ refCount=0; // fix < 0
}
return refCount;
}
@@ -244,9 +261,6 @@ public abstract class DisplayImpl extends Display {
return refCount;
}
- public final boolean getDestroyWhenUnused() { return destroyWhenUnused; }
- public final void setDestroyWhenUnused(boolean v) { destroyWhenUnused=v; }
-
protected abstract void createNativeImpl();
protected abstract void closeNativeImpl();
@@ -275,7 +289,7 @@ public abstract class DisplayImpl extends Display {
return ( null == name ) ? nilString : name ;
}
- protected static final String getFQName(String type, String name, int id) {
+ private static final String getFQName(String type, String name, int id) {
if(null==type) type=nilString;
if(null==name) name=nilString;
StringBuffer sb = new StringBuffer();
@@ -284,7 +298,7 @@ public abstract class DisplayImpl extends Display {
sb.append(name);
sb.append("-");
sb.append(id);
- return sb.toString();
+ return sb.toString().intern();
}
public final long getHandle() {
diff --git a/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java b/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java
index f3c7b8415..30dc945db 100644
--- a/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java
@@ -68,13 +68,13 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable {
// nop
}
- public void invalidate(boolean unrecoverable) {
+ protected void invalidate(boolean unrecoverable) {
super.invalidate(unrecoverable);
surfaceHandle = 0;
}
- public synchronized void destroy(boolean unrecoverable) {
- super.destroy(unrecoverable);
+ public synchronized void destroy() {
+ super.destroy();
surfaceHandle = 0;
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/ScreenImpl.java b/src/newt/classes/com/jogamp/newt/impl/ScreenImpl.java
index c9d1a9c32..071122a68 100644
--- a/src/newt/classes/com/jogamp/newt/impl/ScreenImpl.java
+++ b/src/newt/classes/com/jogamp/newt/impl/ScreenImpl.java
@@ -50,7 +50,8 @@ import java.util.ArrayList;
import java.util.List;
public abstract class ScreenImpl extends Screen implements ScreenModeListener {
- protected static final boolean DisableScreenModeImpl = Debug.debug("Screen.DisableScreenModeImpl");
+ protected static final boolean DEBUG_TEST_SCREENMODE_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableScreenMode", true);
+
protected DisplayImpl display;
protected int screen_idx;
protected String fqname;
@@ -112,7 +113,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
ScreenImpl screen = (ScreenImpl) screenClass.newInstance();
screen.display = (DisplayImpl) display;
screen.screen_idx = idx;
- screen.fqname = display.getFQName()+idx;
+ screen.fqname = (display.getFQName()+idx).intern();
screen.hashCode = screen.fqname.hashCode();
screenList.add(screen);
if(DEBUG) {
@@ -157,7 +158,9 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
synchronized(screenList) {
screenList.remove(this);
- screensActive--;
+ if(0 < screensActive) {
+ screensActive--;
+ }
}
if ( null != aScreen ) {
@@ -183,11 +186,15 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
public synchronized final int removeReference() {
if(DEBUG) {
- System.err.println("Screen.removeReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount-1));
+ String msg = "Screen.removeReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount-1);
+ // Throwable t = new Throwable(msg);
+ // t.printStackTrace();
+ System.err.println(msg);
}
- refCount--; // could become < 0, in case of forced destruction without actual creation/addReference
- if(0>=refCount && getDestroyWhenUnused()) {
+ refCount--; // could become < 0, in case of manual destruction without actual creation/addReference
+ if(0>=refCount) {
destroy();
+ refCount=0; // fix < 0
}
return refCount;
}
@@ -196,13 +203,6 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
return refCount;
}
- public final boolean getDestroyWhenUnused() {
- return display.getDestroyWhenUnused();
- }
- public final void setDestroyWhenUnused(boolean v) {
- display.setDestroyWhenUnused(v);
- }
-
protected abstract void createNativeImpl();
protected abstract void closeNativeImpl();
@@ -260,7 +260,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
ScreenMode smU = null;
ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName());
if(null != sms) {
- ScreenMode sm0 = ( DisableScreenModeImpl ) ? null : getCurrentScreenModeImpl();
+ ScreenMode sm0 = ( DEBUG_TEST_SCREENMODE_DISABLED ) ? null : getCurrentScreenModeImpl();
if(null == sm0) {
return null;
}
@@ -415,7 +415,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
ArrayHashSet screenModes = collectNativeScreenModes(screenModesIdx2NativeIdx);
sms = new ScreenModeStatus(screenModes, screenModesIdx2NativeIdx);
if(null!=screenModes && screenModes.size()>0) {
- ScreenMode originalScreenMode = ( DisableScreenModeImpl ) ? null : getCurrentScreenModeImpl();
+ ScreenMode originalScreenMode = ( DEBUG_TEST_SCREENMODE_DISABLED ) ? null : getCurrentScreenModeImpl();
if(null != originalScreenMode) {
ScreenMode originalScreenMode0 = (ScreenMode) screenModes.get(originalScreenMode); // unify via value hash
if(null == originalScreenMode0) {
@@ -450,7 +450,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
+ ScreenModeUtil.NUM_SURFACE_SIZE_PROPERTIES
- 1 ; // index 0 based
do {
- if(DisableScreenModeImpl) {
+ if(DEBUG_TEST_SCREENMODE_DISABLED) {
smProps = null;
} else if(0 == num) {
smProps = getScreenModeFirstImpl();
diff --git a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
index c34081ebf..9f744be82 100644
--- a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
+++ b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
@@ -71,6 +71,59 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
{
public static final boolean DEBUG_TEST_REPARENT_INCOMPATIBLE = Debug.isPropertyDefined("newt.test.Window.reparent.incompatible", true);
+ private RecursiveLock windowLock = new RecursiveLock();
+ private long windowHandle;
+ private ScreenImpl screen;
+ private boolean screenReferenceAdded = false;
+ private NativeWindow parentWindow;
+ private long parentWindowHandle;
+ protected AbstractGraphicsConfiguration config;
+ protected Capabilities caps;
+ protected boolean fullscreen, visible, hasFocus;
+ protected int width, height, x, y;
+ protected int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen dimensions ..
+ protected String title = "Newt Window";
+ protected boolean undecorated = false;
+ private LifecycleHook lifecycleHook = null;
+
+ private DestroyAction destroyAction = new DestroyAction();
+ private boolean handleDestroyNotify = true;
+
+ private ReparentActionRecreate reparentActionRecreate = new ReparentActionRecreate();
+
+ private RequestFocusAction requestFocusAction = new RequestFocusAction();
+ private FocusRunnable focusAction = null;
+
+ private Object surfaceUpdatedListenersLock = new Object();
+ private ArrayList surfaceUpdatedListeners;
+
+ private Object childWindowsLock = new Object();
+ private ArrayList childWindows;
+
+ private ArrayList mouseListeners;
+ private int mouseButtonPressed; // current pressed mouse button number
+ private long lastMousePressed; // last time when a mouse button was pressed
+ private int lastMouseClickCount; // last mouse button click count
+
+ private ArrayList keyListeners;
+
+ private ArrayList windowListeners;
+ private boolean repaintQueued = false;
+
+ private void initializeStates() {
+ invalidate(true);
+
+ childWindows = new ArrayList();
+ surfaceUpdatedListeners = new ArrayList();
+ windowListeners = new ArrayList();
+ mouseListeners = new ArrayList();
+
+ mouseButtonPressed = 0; // current pressed mouse button number
+ lastMousePressed = 0; // last time when a mouse button was pressed
+ lastMouseClickCount = 0; // last mouse button click count
+ keyListeners = new ArrayList();
+ }
+
// Workaround for initialization order problems on Mac OS X
// between native Newt and (apparently) Fmod -- if Fmod is
// initialized first then the connection to the window server
@@ -89,8 +142,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
// Construction Methods
//
- private static Class getWindowClass(String type)
- throws ClassNotFoundException
+ private static Class getWindowClass(String type)
+ throws ClassNotFoundException
{
Class windowClass = NewtFactory.getCustomClass(type, "Window");
if(null==windowClass) {
@@ -120,7 +173,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
windowClass = OffscreenWindow.class;
}
WindowImpl window = (WindowImpl) windowClass.newInstance();
- window.invalidate(true);
+ window.initializeStates();
window.parentWindow = parentWindow;
window.parentWindowHandle = parentWindowHandle;
window.screen = (ScreenImpl) screen;
@@ -145,7 +198,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
throw new NativeWindowException("WindowClass "+windowClass+" constructor mismatch at argument #"+argsChecked+"; Constructor: "+getTypeStrList(cstrArgumentTypes)+", arguments: "+getArgsStrList(cstrArguments));
}
WindowImpl window = (WindowImpl) ReflectionUtil.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ;
- window.invalidate(true);
+ window.initializeStates();
window.screen = (ScreenImpl) screen;
window.caps = (Capabilities)caps.clone();
return window;
@@ -174,7 +227,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
* Surface not locked yet.<br>
* Called not necessarily from EDT.
*/
- void destroyActionPreLock(boolean unrecoverable);
+ void destroyActionPreLock();
/**
* Invoked before Window destroy action,
@@ -182,7 +235,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
* Surface locked.<br>
* Called from EDT while window is locked.
*/
- void destroyActionInLock(boolean unrecoverable);
+ void destroyActionInLock();
+
+ /**
+ * Invoked after destruction from Window's invalidate method.<br>
+ * Called while window is locked.
+ * @param unrecoverable
+ */
+ void invalidate(boolean unrecoverable);
/**
* Invoked for expensive modifications, ie while reparenting and ScreenMode change.<br>
@@ -201,41 +261,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
void resumeRenderingAction();
}
- private LifecycleHook lifecycleHook = null;
- private RecursiveLock windowLock = new RecursiveLock();
- private long windowHandle;
- private ScreenImpl screen;
- private boolean screenReferenced = false;
- private NativeWindow parentWindow;
- private long parentWindowHandle;
-
- protected AbstractGraphicsConfiguration config;
- protected Capabilities caps;
- protected boolean fullscreen, visible, hasFocus;
- protected int width, height, x, y;
- protected int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen dimensions ..
-
- protected String title = "Newt Window";
- protected boolean undecorated = false;
- private boolean handleDestroyNotify = true;
-
- private final void destroyScreen() {
- if(null!=screen) {
- if(screenReferenced) {
- screen.removeReference();
- screenReferenced = false;
- }
- screen = null;
- }
- }
- private final void setScreen(ScreenImpl newScreen) {
- if(screenReferenced) {
- screenReferenced = false;
- screen.removeReference();
- }
- screen = newScreen;
- }
-
private boolean createNative() {
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.createNative() START ("+getThreadName()+", "+this+")");
@@ -246,10 +271,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
}
try {
if(validateParentWindowHandle()) {
- if(!screenReferenced) {
- screenReferenced = true;
- screen.addReference();
+ if(screenReferenceAdded) {
+ throw new InternalError("XXX");
}
+ screen.addReference();
+ screenReferenceAdded = true;
createNativeImpl();
setVisibleImpl(true, x, y, width, height);
screen.addScreenModeListener(this);
@@ -265,6 +291,36 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
return 0 != windowHandle ;
}
+ private void removeScreenReference() {
+ if(screenReferenceAdded) {
+ // be nice, probably already called recursive via
+ // closeAndInvalidate() -> closeNativeIml() -> .. -> windowDestroyed() -> closeAndInvalidate() !
+ // or via reparentWindow .. etc
+ screenReferenceAdded = false;
+ screen.removeReference();
+ }
+ }
+
+ private void closeAndInvalidate() {
+ windowLock.lock();
+ try {
+ if( null != screen ) {
+ if( 0 != windowHandle ) {
+ screen.removeScreenModeListener(WindowImpl.this);
+ closeNativeImpl();
+ removeScreenReference();
+ }
+ Display dpy = screen.getDisplay();
+ if(null != dpy) {
+ dpy.validateEDT();
+ }
+ }
+ invalidate(false);
+ } finally {
+ windowLock.unlock();
+ }
+ }
+
private boolean validateParentWindowHandle() {
if(null!=parentWindow) {
parentWindowHandle = getNativeWindowHandle(parentWindow);
@@ -446,9 +502,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
// NativeWindow
//
- public final void destroy() {
- destroy(false);
- }
+ // public final void destroy() - see below
public final NativeWindow getParent() {
return parentWindow;
@@ -649,11 +703,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
}
class DestroyAction implements Runnable {
- boolean unrecoverable;
-
- public DestroyAction(boolean unrecoverable) {
- this.unrecoverable = unrecoverable;
- }
public void run() {
windowLock.lock();
try {
@@ -663,47 +712,29 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
// Childs first ..
synchronized(childWindowsLock) {
- // avoid ConcurrentModificationException: parent -> child -> parent.removeChild(this)
- ArrayList clonedChildWindows = (ArrayList) childWindows.clone();
- while( clonedChildWindows.size() > 0 ) {
- NativeWindow nw = (NativeWindow) clonedChildWindows.remove(0);
- if(nw instanceof WindowImpl) {
- ((WindowImpl)nw).sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY);
- if(unrecoverable) {
- ((WindowImpl)nw).destroy(unrecoverable);
- }
- } else {
- nw.destroy();
+ if(childWindows.size()>0) {
+ // avoid ConcurrentModificationException: parent -> child -> parent.removeChild(this)
+ ArrayList clonedChildWindows = (ArrayList) childWindows.clone();
+ while( clonedChildWindows.size() > 0 ) {
+ NativeWindow nw = (NativeWindow) clonedChildWindows.remove(0);
+ if(nw instanceof WindowImpl) {
+ ((WindowImpl)nw).sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY);
+ ((WindowImpl)nw).destroy();
+ } else {
+ nw.destroy();
+ }
}
}
}
if(null!=lifecycleHook) {
- lifecycleHook.destroyActionInLock(unrecoverable);
+ lifecycleHook.destroyActionInLock();
}
- // Now us ..
- if(unrecoverable) {
- if(null!=parentWindow && parentWindow instanceof Window) {
- ((Window)parentWindow).removeChild(WindowImpl.this);
- }
- synchronized(childWindowsLock) {
- childWindows = new ArrayList();
- }
- synchronized(surfaceUpdatedListenersLock) {
- surfaceUpdatedListeners = new ArrayList();
- }
- windowListeners = new ArrayList();
- mouseListeners = new ArrayList();
- keyListeners = new ArrayList();
- }
- if( null != screen && 0 != windowHandle ) {
- screen.removeScreenModeListener(WindowImpl.this);
- closeNativeImpl();
- }
- invalidate(unrecoverable);
+ closeAndInvalidate();
+
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.destroy(unrecoverable: "+unrecoverable+") END "+getThreadName()/*+", "+WindowImpl.this*/);
+ System.err.println("Window.destroy() END "+getThreadName()/*+", "+WindowImpl.this*/);
}
} finally {
windowLock.unlock();
@@ -711,36 +742,27 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
}
}
- public void destroy(boolean unrecoverable) {
+ public void destroy() {
if( isValid() ) {
if(DEBUG_IMPLEMENTATION) {
- String msg = new String("Window.destroy(unrecoverable: "+unrecoverable+") START "+getThreadName()/*+", "+this*/);
+ String msg = new String("Window.destroy() START "+getThreadName()/*+", "+this*/);
System.err.println(msg);
//Exception ee = new Exception(msg);
//ee.printStackTrace();
- }
+ }
if(null!=lifecycleHook) {
- lifecycleHook.destroyActionPreLock(unrecoverable);
+ lifecycleHook.pauseRenderingAction();
+ }
+ if(null!=lifecycleHook) {
+ lifecycleHook.destroyActionPreLock();
}
- DestroyAction destroyAction = new DestroyAction(unrecoverable);
runOnEDTIfAvail(true, destroyAction);
}
}
- /**
- * <p>
- * render all native window information invalid,
- * as if the native window was destroyed.<br></p>
- * <p>
- * all other resources and states are kept intact,
- * ie listeners, parent handles and size, position etc.<br></p>
- *
- * @see #destroy()
- * @see #destroy(boolean)
- * @see #invalidate(boolean)
- */
public final void invalidate() {
- invalidate(false);
+ destroy();
+ invalidate(true);
}
/**
@@ -757,16 +779,49 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
String msg = new String("!!! Window Invalidate(unrecoverable: "+unrecoverable+") "+getThreadName());
System.err.println(msg);
- // Exception e = new Exception(msg);
- // e.printStackTrace();
+ // Throwable t = new Throwable(msg);
+ // t.printStackTrace();
+ }
+
+ // Childs first ..
+ synchronized(childWindowsLock) {
+ // avoid ConcurrentModificationException: parent -> child -> parent.removeChild(this)
+ if(null!=childWindows && childWindows.size()>0) {
+ ArrayList clonedChildWindows = (ArrayList) childWindows.clone();
+ while( clonedChildWindows.size() > 0 ) {
+ NativeWindow nw = (NativeWindow) clonedChildWindows.remove(0);
+ if(nw instanceof WindowImpl) {
+ ((WindowImpl)nw).invalidate(unrecoverable);
+ }
+ }
+ }
}
+
+ if(null!=lifecycleHook) {
+ lifecycleHook.invalidate(unrecoverable);
+ }
+
windowHandle = 0;
visible = false;
fullscreen = false;
hasFocus = false;
if(unrecoverable) {
- destroyScreen();
+ if(null!=parentWindow && parentWindow instanceof Window) {
+ ((Window)parentWindow).removeChild(WindowImpl.this);
+ }
+ screen = null;
+
+ synchronized(childWindowsLock) {
+ childWindows = null;
+ }
+ synchronized(surfaceUpdatedListenersLock) {
+ surfaceUpdatedListeners = null;
+ }
+ windowListeners = null;
+ mouseListeners = null;
+ keyListeners = null;
+
parentWindowHandle = 0;
parentWindow = null;
caps = null;
@@ -794,10 +849,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
this.reparentAction = -1; // ensure it's set
}
- public int getStrategy() {
+ public final int getStrategy() {
return reparentAction;
}
+ private final void setScreen(ScreenImpl newScreen) {
+ WindowImpl.this.removeScreenReference();
+ screen = newScreen;
+ }
+
public void run() {
boolean wasVisible;
@@ -846,9 +906,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
if(null==newParentWindowNEWT) {
throw new NativeWindowException("Reparenting with non NEWT Window type only available after it's realized: "+newParentWindow);
}
- // Destroy this window (handle screen + native) and use parent's Screen.
+ // Destroy this window and use parent's Screen.
// It may be created properly when the parent is made visible.
- destroy(false);
+ destroy();
setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() );
reparentAction = ACTION_NATIVE_CREATION_PENDING;
} else if(newParentWindow != getParent()) {
@@ -862,7 +922,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
Screen newScreen = NewtFactory.createCompatibleScreen(newParentWindow, getScreen());
if( getScreen() != newScreen ) {
// auto destroy on-the-fly created Screen/Display
- newScreen.setDestroyWhenUnused(true);
setScreen( (ScreenImpl) newScreen );
}
}
@@ -873,15 +932,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
}
} else if ( DEBUG_TEST_REPARENT_INCOMPATIBLE || forceDestroyCreate ||
!NewtFactory.isScreenCompatible(newParentWindow, getScreen()) ) {
- // Destroy this window (handle screen + native) and
- // may create a new compatible Screen/Display and
- // mark it for creation.
- destroy(false);
+ // Destroy this window, may create a new compatible Screen/Display,
+ // and mark it for creation.
+ destroy();
if(null!=newParentWindowNEWT) {
setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() );
} else {
setScreen( (ScreenImpl) NewtFactory.createCompatibleScreen(newParentWindow, getScreen()) );
- screen.setDestroyWhenUnused(true);
}
reparentAction = ACTION_NATIVE_CREATION;
} else {
@@ -906,9 +963,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
// Already Top Window
reparentAction = ACTION_UNCHANGED;
} else if( !isNativeValid() || DEBUG_TEST_REPARENT_INCOMPATIBLE || forceDestroyCreate ) {
- // Destroy this window (handle screen + native),
- // keep Screen/Display and mark it for creation.
- destroy(false);
+ // Destroy this window and mark it for [pending] creation.
+ destroy();
if( 0<width*height ) {
reparentAction = ACTION_NATIVE_CREATION;
} else {
@@ -1015,7 +1071,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.reparent: native reparenting failed ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+" -> "+toHexString(newParentWindowHandle)+" - Trying recreation");
}
- destroy(false);
+ destroy();
reparentAction = ACTION_NATIVE_CREATION ;
}
}
@@ -1065,7 +1121,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
}
}
}
- private ReparentActionRecreate reparentActionRecreate = new ReparentActionRecreate();
public final int reparentWindow(NativeWindow newParent) {
return reparentWindow(newParent, false);
@@ -1075,7 +1130,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
int reparentActionStrategy = ReparentAction.ACTION_INVALID;
if(isValid()) {
if(null!=lifecycleHook) {
- // pause animation
lifecycleHook.pauseRenderingAction();
}
try {
@@ -1084,7 +1138,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
reparentActionStrategy = reparentAction.getStrategy();
} finally {
if(null!=lifecycleHook) {
- // resume animation
lifecycleHook.resumeRenderingAction();
}
}
@@ -1316,7 +1369,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
WindowImpl.this.requestFocusImpl(false);
}
}
- RequestFocusAction requestFocusAction = new RequestFocusAction();
protected void enqueueRequestFocus(boolean wait) {
runOnEDTIfAvail(wait, requestFocusAction);
@@ -1345,7 +1397,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
}
return res;
}
- protected FocusRunnable focusAction = null;
class SetPositionActionImpl implements Runnable {
int x, y;
@@ -1475,7 +1526,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
}
if(null!=lifecycleHook) {
- // pause animation
lifecycleHook.pauseRenderingAction();
}
}
@@ -1494,7 +1544,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
}
if(null!=lifecycleHook) {
- // resume animation
lifecycleHook.resumeRenderingAction();
sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener
}
@@ -1504,9 +1553,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
// Child Window Management
//
- private ArrayList childWindows = new ArrayList();
- private Object childWindowsLock = new Object();
-
public final void removeChild(NativeWindow win) {
synchronized(childWindowsLock) {
childWindows.remove(win);
@@ -1591,15 +1637,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
}
return true;
}
- protected boolean repaintQueued = false;
//
// SurfaceUpdatedListener Support
//
- private ArrayList surfaceUpdatedListeners = new ArrayList();
- private Object surfaceUpdatedListenersLock = new Object();
-
public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
addSurfaceUpdatedListener(-1, l);
}
@@ -1660,11 +1702,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
//
// MouseListener/Event Support
//
- private ArrayList mouseListeners = new ArrayList();
- private int mouseButtonPressed = 0; // current pressed mouse button number
- private long lastMousePressed = 0; // last time when a mouse button was pressed
- private int lastMouseClickCount = 0; // last mouse button click count
-
public void sendMouseEvent(int eventType, int modifiers,
int x, int y, int button, int rotation) {
doMouseEvent(false, false, eventType, modifiers, x, y, button, rotation);
@@ -1857,8 +1894,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
return (KeyListener[]) keyListeners.toArray();
}
- private ArrayList keyListeners = new ArrayList();
-
protected void consumeKeyEvent(KeyEvent e) {
if(DEBUG_KEY_EVENT) {
System.err.println("consumeKeyEvent: "+e);
@@ -1892,8 +1927,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
enqueueEvent( wait, new WindowEvent(eventType, this, System.currentTimeMillis()) );
}
- private ArrayList windowListeners = new ArrayList();
-
public void addWindowListener(WindowListener l) {
addWindowListener(-1, l);
}
@@ -2055,7 +2088,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.windowDestroyed "+getThreadName());
}
- invalidate();
+ closeAndInvalidate();
}
public void windowRepaint(int x, int y, int width, int height) {
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index f84c65cb7..72963eaa3 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -246,8 +246,8 @@ public class GLWindow implements GLAutoDrawable, Window {
// Window.LifecycleHook Implementation
//
- public final void destroy(boolean unrecoverable) {
- window.destroy(unrecoverable);
+ public final void destroy() {
+ window.destroy();
}
public final void setVisible(boolean visible) {
@@ -282,23 +282,14 @@ public class GLWindow implements GLAutoDrawable, Window {
DisposeAction disposeAction = new DisposeAction();
/** Window.LifecycleHook */
- public synchronized void destroyActionPreLock(boolean unrecoverable) {
- GLAnimatorControl animator = GLWindow.this.getAnimator();
- if(null!=animator) {
- if(unrecoverable) {
- if(animator.isStarted()) {
- animator.stop();
- }
- } else if(animator.isAnimating()) {
- animator.pause();
- }
- }
+ public synchronized void destroyActionPreLock() {
+ // nop
}
/** Window.LifecycleHook */
- public synchronized void destroyActionInLock(boolean unrecoverable) {
+ public synchronized void destroyActionInLock() {
if(Window.DEBUG_WINDOW_EVENT || Window.DEBUG_IMPLEMENTATION) {
- String msg = new String("GLWindow.destroy("+unrecoverable+") "+Thread.currentThread()+", start");
+ String msg = new String("GLWindow.destroy() "+Thread.currentThread()+", start");
System.err.println(msg);
//Exception e1 = new Exception(msg);
//e1.printStackTrace();
@@ -320,12 +311,25 @@ public class GLWindow implements GLAutoDrawable, Window {
context = null;
drawable = null;
- if(unrecoverable) {
- helper=null;
+ if(Window.DEBUG_WINDOW_EVENT || Window.DEBUG_IMPLEMENTATION) {
+ System.err.println("GLWindow.destroy() "+Thread.currentThread()+", fin");
}
+ }
+ /** Window.LifecycleHook */
+ public synchronized void invalidate(boolean unrecoverable) {
if(Window.DEBUG_WINDOW_EVENT || Window.DEBUG_IMPLEMENTATION) {
- System.err.println("GLWindow.destroy("+unrecoverable+") "+Thread.currentThread()+", fin");
+ String msg = new String("GLWindow.invalidate("+unrecoverable+") "+Thread.currentThread()+", start");
+ System.err.println(msg);
+ //Exception e1 = new Exception(msg);
+ //e1.printStackTrace();
+ }
+ if(unrecoverable) {
+ GLAnimatorControl ctrl = GLWindow.this.getAnimator();
+ if ( null!=ctrl && ctrl.isStarted() ) {
+ ctrl.stop();
+ }
+ helper=null;
}
}
@@ -635,10 +639,6 @@ public class GLWindow implements GLAutoDrawable, Window {
return null!=drawable ? drawable.getHandle() : 0;
}
- public final void destroy() {
- window.destroy();
- }
-
public final int getX() {
return window.getX();
}
@@ -878,7 +878,7 @@ public class GLWindow implements GLAutoDrawable, Window {
});
glWindow.setVisible(true);
- glWindow.destroy(true);
+ glWindow.invalidate();
}
}