Permalink
Browse files

NEWT: Fix / Stabilize Fullscreen/Decoration/Reparenting Mode Changes

    - setSizeImpl/setPositionImpl/reparent -> reconfigureWindowImpl
    - setVisible(boolean) is state checked (500ms) for better reliability
      on resource creation. Guarantees valid surface.
    - reparentWindow: start pos of child -> top is current position on screen
    - reparentWindow: Recheck success (setVisible), if failed fall back to recreate,
      which gets rid of a lost child windows (1/20) ..
    - reparentWindow: if size failed, reconfigure for size again
    - add toggle decoration
    - unify nfs_ size/pos state
    - WindowsWindow.c/X11Window.c: Unify size/pos settings
    - X11Window.c:
        - NewtWindows_setFullscreen: use 'root of screen' instead of 'default root of display'
        - Adding SubstructureNotifyMask incl event semantics
        - Parse ReparentNotify (debugging of reparenting)

Misc:
    - Add native getLocationOnScreen() impl to avoid possible AWT deadlock
    - setSize/setPosition/setFullScreen -> EDT
    - More documentation on expected native implementation semantics
  • Loading branch information...
1 parent 6da90f1 commit 18bf27fa86da1f26fd085565f501736816d2f2e9 @sgothel committed Oct 21, 2010
Showing with 1,488 additions and 834 deletions.
  1. +27 −0 make/scripts/check-junit.sh
  2. +2 −1 make/scripts/java-win64-dbg.bat
  3. +6 −3 make/scripts/tests.bat
  4. +5 −0 src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java
  5. +16 −5 src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/Gears.java
  6. +1 −1 src/junit/com/jogamp/test/junit/newt/TestDisplayLifecycle01NEWT.java
  7. +4 −4 src/junit/com/jogamp/test/junit/newt/parenting/TestParenting01NEWT.java
  8. +23 −60 src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java
  9. +258 −0 src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03bAWT.java
  10. +3 −0 src/newt/classes/com/jogamp/newt/Window.java
  11. +10 −12 src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java
  12. +387 −187 src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
  13. +22 −30 src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java
  14. +26 −24 src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java
  15. +28 −27 src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
  16. +32 −7 src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java
  17. +28 −19 src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java
  18. +34 −36 src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
  19. +37 −37 src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
  20. +8 −3 src/newt/native/KDWindow.c
  21. +18 −5 src/newt/native/NewtMacWindow.m
  22. +229 −150 src/newt/native/WindowsWindow.c
  23. +284 −223 src/newt/native/X11Window.c
@@ -0,0 +1,27 @@
+#! /bin/bash
+
+builddir=$1
+shift
+
+echo number of junit classes
+grep failures $builddir/test/results/* | wc
+echo
+echo number of passed junit classes - failures
+grep failures $builddir/test/results/* | grep "failures=\"0\"" | wc
+echo
+echo number of passed junit classes - errors
+grep failures $builddir/test/results/* | grep "errors=\"0\"" | wc
+echo
+echo number of failed junit classes - failures
+grep failures $builddir/test/results/* | grep -v "failures=\"0\"" | wc
+echo
+echo number of failed junit classes - errors
+grep failures $builddir/test/results/* | grep -v "errors=\"0\"" | wc
+echo
+echo failed junit classes - failures
+grep failures $builddir/test/results/* | grep -v "failures=\"0\""
+echo
+echo failed junit classes - errors
+grep failures $builddir/test/results/* | grep -v "errors=\"0\""
+echo
+
@@ -14,10 +14,11 @@ set CP_ALL=.;%BLD_DIR%\jogl\jogl.all.jar;%BLD_DIR%\nativewindow\nativewindow.all
echo CP_ALL %CP_ALL%
REM set D_ARGS="-Djogamp.debug.JNILibLoader=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLProfile=true"
-set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.Lock" "-Djogamp.debug.Lock.TraceLock"
+REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.Lock" "-Djogamp.debug.Lock.TraceLock"
REM set D_ARGS="-Dnewt.debug.Window" "-Dnativewindow.debug.TraceLock"
REM set D_ARGS="-Dnativewindow.debug.TraceLock"
REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display"
+set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.EDT" "-Dnativewindow.debug=all" "-Djogamp.common.utils.locks.Lock.timeout=600000" "-Djogamp.debug.Lock" "-Djogamp.debug.Lock.TraceLock"
REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true"
set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true"
View
@@ -3,16 +3,19 @@ REM scripts\java-win64-dbg.bat com.jogamp.test.junit.jogl.acore.TestGLProfile01C
REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.TestParenting01AWT
REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.parenting.TestParenting01cAWT -time 50000
-REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.TestDisplayLifecycle01NEWT
REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.TestListenerCom01AWT
REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.parenting.TestParenting01NEWT
-scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.TestGLWindows01NEWT
+REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.TestGLWindows01NEWT
REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.TestGLWindows02NEWTAnimated
REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.parenting.TestParenting01NEWT
REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.TestFocus02SwingAWTRobot
REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.TestFocus01SwingAWTRobot
REM scripts\java-win64-dbg.bat com.jogamp.test.junit.nativewindow.TestRecursiveToolkitLockCORE
-REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.parenting.TestParenting03AWT
+REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.parenting.TestParenting03AWT -time 100000
REM scripts\java-win32.bat com.jogamp.test.junit.newt.TestFocus02SwingAWTRobot
+
+scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.TestDisplayLifecycle01NEWT
+REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.parenting.TestParenting01NEWT
+REM scripts\java-win64-dbg.bat com.jogamp.test.junit.newt.parenting.TestParenting02NEWT
@@ -39,6 +39,7 @@
import javax.media.opengl.awt.GLCanvas;
import com.jogamp.opengl.util.Animator;
+import com.jogamp.newt.Screen;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.newt.awt.NewtCanvasAWT;
@@ -254,6 +255,8 @@ public void test01GLCanvas() throws AWTException, InterruptedException, Invocati
GLWindow win0 = GLWindow.create(caps);
win0.setSize(100,100);
win0.setVisible(true);
+ Screen screen = win0.getScreen();
+ win0.setPosition(screen.getWidth()-150, screen.getHeight()-150);
win0.addGLEventListener(new Gears());
Animator anim0 = new Animator(win0);
anim0.start();
@@ -277,6 +280,8 @@ public void test02NewtCanvasAWT() throws AWTException, InterruptedException, Inv
GLWindow win0 = GLWindow.create(caps);
win0.setSize(100,100);
win0.setVisible(true);
+ Screen screen = win0.getScreen();
+ win0.setPosition(screen.getWidth()-150, screen.getHeight()-150);
win0.addGLEventListener(new Gears());
Animator anim0 = new Animator(win0);
anim0.start();
@@ -22,10 +22,19 @@
private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
private int gear1, gear2, gear3;
private float angle = 0.0f;
+ private int swapInterval;
private int prevMouseX, prevMouseY;
private boolean mouseRButtonDown = false;
+ public Gears(int swapInterval) {
+ this.swapInterval = swapInterval;
+ }
+
+ public Gears() {
+ this.swapInterval = 1;
+ }
+
public static void main(String[] args) {
// set argument 'NotFirstUIActionOnProcess' in the JNLP's application-desc tag for example
// <application-desc main-class="demos.j2d.TextCube"/>
@@ -69,12 +78,12 @@ public void init(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
- gl.setSwapInterval(1);
+ gl.setSwapInterval(swapInterval);
float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
- float red[] = { 0.8f, 0.1f, 0.0f, 1.0f };
- float green[] = { 0.0f, 0.8f, 0.2f, 1.0f };
- float blue[] = { 0.2f, 0.2f, 1.0f, 1.0f };
+ float red[] = { 0.8f, 0.1f, 0.0f, 0.7f };
+ float green[] = { 0.0f, 0.8f, 0.2f, 0.7f };
+ float blue[] = { 0.2f, 0.2f, 1.0f, 0.7f };
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, 0);
gl.glEnable(GL2.GL_CULL_FACE);
@@ -116,7 +125,7 @@ public void init(GLAutoDrawable drawable) {
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
- System.err.println("Gears: Reshape");
+ System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height);
GL2 gl = drawable.getGL().getGL2();
float h = (float)height / (float)width;
@@ -141,6 +150,8 @@ public void display(GLAutoDrawable drawable) {
// Get the GL corresponding to the drawable we are animating
GL2 gl = drawable.getGL().getGL2();
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
// Special handling for the case where the GLJPanel is translucent
// and wants to be composited with other Java 2D content
if ((drawable instanceof GLJPanel) &&
@@ -115,7 +115,7 @@ private void testDisplayCreate01(Display display, Screen screen, boolean destroy
Assert.assertEquals(0,Display.getActiveDisplayNumber());
Assert.assertEquals(0,display.getReferenceCount());
Assert.assertEquals(false,display.isNativeValid());
- Assert.assertEquals(false,display.getEDTUtil().isRunning());
+ Assert.assertEquals(true,display.getEDTUtil().isRunning());
Assert.assertEquals(0,screen.getReferenceCount());
Assert.assertEquals(false,screen.isNativeValid());
Assert.assertEquals(false,window.isNativeValid());
@@ -90,7 +90,7 @@ public void testWindowParenting01CreateVisibleDestroy() throws InterruptedExcept
Assert.assertEquals(0,display.getReferenceCount());
Assert.assertEquals(false,display.isNativeValid());
Assert.assertNotNull(display.getEDTUtil());
- Assert.assertEquals(false,display.getEDTUtil().isRunning());
+ Assert.assertEquals(true,display.getEDTUtil().isRunning());
Assert.assertEquals(0,screen.getReferenceCount());
Assert.assertEquals(false,screen.isNativeValid());
Assert.assertEquals(0,Display.getActiveDisplayNumber());
@@ -355,7 +355,7 @@ protected void testWindowParenting02ReparentTop2WinImpl(boolean reparentRecreate
Assert.assertEquals(0,display1.getReferenceCount());
Assert.assertEquals(false,display1.isNativeValid());
Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(false,display1.getEDTUtil().isRunning());
+ Assert.assertEquals(true,display1.getEDTUtil().isRunning());
Assert.assertEquals(0,screen1.getReferenceCount());
Assert.assertEquals(false,screen1.isNativeValid());
Assert.assertEquals(0,Display.getActiveDisplayNumber());
@@ -372,7 +372,7 @@ protected void testWindowParenting02ReparentTop2WinImpl(boolean reparentRecreate
Assert.assertEquals(0,display2.getReferenceCount());
Assert.assertEquals(false,display2.isNativeValid());
Assert.assertNotNull(display2.getEDTUtil());
- Assert.assertEquals(false,display2.getEDTUtil().isRunning());
+ Assert.assertEquals(true,display2.getEDTUtil().isRunning());
Assert.assertEquals(0,screen2.getReferenceCount());
Assert.assertEquals(false,screen2.isNativeValid());
Assert.assertEquals(0,Display.getActiveDisplayNumber());
@@ -630,7 +630,7 @@ protected void testWindowParenting03ReparentWin2TopImpl(boolean reparentRecreate
Assert.assertEquals(0,display1.getReferenceCount());
Assert.assertEquals(false,display1.isNativeValid());
Assert.assertNotNull(display1.getEDTUtil());
- Assert.assertEquals(false,display1.getEDTUtil().isRunning());
+ Assert.assertEquals(true,display1.getEDTUtil().isRunning());
Assert.assertEquals(0,screen1.getReferenceCount());
Assert.assertEquals(false,screen1.isNativeValid());
Assert.assertEquals(0,Display.getActiveDisplayNumber());
@@ -65,15 +65,17 @@
public class TestParenting03AWT extends UITestCase {
static Dimension size;
- static long durationPerTest = 800;
- static long waitAdd2nd = 500;
+ static long durationPerTest = 400;
+ static long waitAdd2nd = 200;
static GLCapabilities glCaps;
@BeforeClass
public static void initClass() {
GLProfile.initSingleton(true);
size = new Dimension(400,200);
glCaps = new GLCapabilities(null);
+ glCaps.setAlphaBits(8);
+ glCaps.setBackgroundOpaque(false);
}
@Test
@@ -88,67 +90,48 @@ public void testWindowParenting1AWT2NewtChilds(boolean visibleChild2) throws Int
NEWTEventFiFo eventFifo = new NEWTEventFiFo();
GLWindow glWindow1 = GLWindow.create(glCaps);
+ glWindow1.enablePerfLog(true);
glWindow1.setUndecorated(true);
- GLEventListener demo1 = new Gears();
+ NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
+ newtCanvasAWT1.setPreferredSize(size);
+
+ GLEventListener demo1 = new Gears(1);
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
+ final NewtCanvasAWT f_newtCanvasAWT1 = newtCanvasAWT1;
final GLWindow f_glWindow1 = glWindow1;
glWindow1.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) {
- if(e.getKeyChar()=='f') {
- f_glWindow1.invoke(false, new GLRunnable() {
- public void run(GLAutoDrawable drawable) {
- GLWindow win = (GLWindow)drawable;
- win.setFullscreen(!win.isFullscreen());
- } });
+ if(e.getKeyChar()=='d') {
+ f_glWindow1.setUndecorated(!f_glWindow1.isUndecorated());
+ } else if(e.getKeyChar()=='f') {
+ f_glWindow1.setFullscreen(!f_glWindow1.isFullscreen());
+ } else if(e.getKeyChar()=='r') {
+ if(f_glWindow1.getParent()==null) {
+ System.err.println("XXX glWin1 -> home");
+ f_glWindow1.reparentWindow(f_newtCanvasAWT1.getNativeWindow());
+ } else {
+ System.err.println("XXX glWin1 -> TOP");
+ f_glWindow1.reparentWindow(null);
+ }
}
}
});
GLAnimatorControl animator1 = new Animator(glWindow1);
animator1.start();
- GLWindow glWindow2 = GLWindow.create(glCaps);
- glWindow2.setUndecorated(true);
- GLEventListener demo2 = new Gears();
- setDemoFields(demo2, glWindow2, false);
- glWindow2.addGLEventListener(demo2);
- final GLWindow f_glWindow2 = glWindow2;
- glWindow2.addKeyListener(new KeyAdapter() {
- public void keyTyped(KeyEvent e) {
- if(e.getKeyChar()=='f') {
- f_glWindow2.invoke(false, new GLRunnable() {
- public void run(GLAutoDrawable drawable) {
- GLWindow win = (GLWindow)drawable;
- win.setFullscreen(!win.isFullscreen());
- } });
- }
- }
- });
- GLAnimatorControl animator2 = new Animator(glWindow2);
- animator2.start();
-
- NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
- newtCanvasAWT1.setPreferredSize(size);
Container cont1 = new Container();
cont1.setLayout(new BorderLayout());
cont1.add(newtCanvasAWT1, BorderLayout.CENTER);
cont1.setVisible(true);
final Container f_cont1 = cont1;
- NewtCanvasAWT newtCanvasAWT2 = new NewtCanvasAWT(glWindow2);
- newtCanvasAWT2.setPreferredSize(size);
- Container cont2 = new Container();
- cont2.setLayout(new BorderLayout());
- cont2.add(newtCanvasAWT2, BorderLayout.CENTER);
- cont2.setVisible(true);
- final Container f_cont2 = cont2;
-
Frame frame1 = new Frame("AWT Parent Frame");
frame1.setLayout(new BorderLayout());
frame1.add(cont1, BorderLayout.EAST);
frame1.add(new Label("center"), BorderLayout.CENTER);
frame1.setLocation(0, 0);
- frame1.setSize((int)size.getWidth()*2, (int)size.getHeight()*2);
+ frame1.setSize((int)size.getWidth(), (int)size.getHeight());
final Frame f_frame1 = frame1;
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -157,39 +140,19 @@ public void run() {
}});
Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent());
- Assert.assertEquals(newtCanvasAWT2.getNativeWindow(),glWindow2.getParent());
-
Assert.assertEquals(true, animator1.isAnimating());
Assert.assertEquals(false, animator1.isPaused());
Assert.assertNotNull(animator1.getThread());
- Assert.assertEquals(true, animator2.isAnimating());
- Assert.assertEquals(false, animator2.isPaused());
- Assert.assertNotNull(animator2.getThread());
-
- Thread.sleep(waitAdd2nd);
-
- javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- f_frame1.add(f_cont2, BorderLayout.WEST);
- f_frame1.pack();
- }});
-
Thread.sleep(durationPerTest);
animator1.stop();
Assert.assertEquals(false, animator1.isAnimating());
Assert.assertEquals(false, animator1.isPaused());
Assert.assertEquals(null, animator1.getThread());
- animator2.stop();
- Assert.assertEquals(false, animator2.isAnimating());
- Assert.assertEquals(false, animator2.isPaused());
- Assert.assertEquals(null, animator2.getThread());
-
frame1.dispose();
glWindow1.destroy(true);
- glWindow2.destroy(true);
}
public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
Oops, something went wrong.

0 comments on commit 18bf27f

Please sign in to comment.