diff options
6 files changed, 99 insertions, 65 deletions
diff --git a/make/scripts/make.jogl.all.linux-x86_64.sh b/make/scripts/make.jogl.all.linux-x86_64.sh index 220848693..cc7b97ef7 100755 --- a/make/scripts/make.jogl.all.linux-x86_64.sh +++ b/make/scripts/make.jogl.all.linux-x86_64.sh @@ -50,6 +50,8 @@ echo LIBXCB_ALLOW_SLOPPY_LOCK: $LIBXCB_ALLOW_SLOPPY_LOCK 2>&1 | tee -a $LOGF echo LIBGL_DRIVERS_PATH: $LIBGL_DRIVERS_PATH 2>&1 | tee -a $LOGF echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a $LOGF +# -Dbuild.noarchives=true \ + ant \ $CUSTOMLIBDIR \ -Dbuild.noarchives=true \ diff --git a/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java b/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java index 18f176e16..9f12b658a 100644 --- a/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java +++ b/src/junit/com/jogamp/test/junit/jogl/awt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java @@ -48,7 +48,6 @@ import java.awt.Canvas; import java.awt.Color; import java.awt.Dimension; import java.awt.AWTException; -import java.awt.Container; import java.awt.LayoutManager; import java.awt.Robot; import java.awt.Point; 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 86900a41e..f7374a98b 100644 --- a/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java +++ b/src/junit/com/jogamp/test/junit/newt/parenting/TestParenting03AWT.java @@ -43,8 +43,9 @@ import org.junit.Test; import java.awt.Button; import java.awt.BorderLayout; import java.awt.Canvas; -import java.awt.Frame; +import java.awt.Container; import java.awt.Dimension; +import java.awt.Frame; import java.awt.Label; import javax.media.opengl.*; @@ -67,24 +68,23 @@ public class TestParenting03AWT extends UITestCase { GLProfile.initSingleton(); } - static int width, height; + static Dimension size; static long durationPerTest = 800; - static long waitReparent = 0; + static long waitAdd2nd = 500; static GLCapabilities glCaps; @BeforeClass public static void initClass() { - width = 800; - height = 400; + size = new Dimension(400,200); glCaps = new GLCapabilities(null); } @Test - public void testWindowParenting1AWT2NewtChilds01() throws InterruptedException { - testWindowParenting1AWT2NewtChilds(); + public void testWindowParenting1AWT2NewtChilds01() throws InterruptedException, InvocationTargetException { + testWindowParenting1AWT2NewtChilds(true); } - public void testWindowParenting1AWT2NewtChilds() throws InterruptedException { + public void testWindowParenting1AWT2NewtChilds(boolean visibleChild2) throws InterruptedException, InvocationTargetException { int x = 0; int y = 0; @@ -131,19 +131,33 @@ public class TestParenting03AWT extends UITestCase { 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(newtCanvasAWT1, BorderLayout.EAST); + frame1.add(cont1, BorderLayout.EAST); frame1.add(new Label("center"), BorderLayout.CENTER); - frame1.add(newtCanvasAWT2, BorderLayout.WEST); frame1.setLocation(0, 0); - frame1.setSize(width/2, height/2); - System.err.println("1: "+frame1); - frame1.pack(); - frame1.setVisible(true); - System.err.println("2: "+frame1); + frame1.setSize((int)size.getWidth()*2, (int)size.getHeight()*2); + final Frame f_frame1 = frame1; + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f_frame1.pack(); + f_frame1.setVisible(true); + }}); Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent()); Assert.assertEquals(newtCanvasAWT2.getNativeWindow(),glWindow2.getParent()); @@ -156,6 +170,14 @@ public class TestParenting03AWT extends UITestCase { 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(); @@ -199,7 +221,7 @@ public class TestParenting03AWT extends UITestCase { if(args[i].equals("-time")) { durationPerTest = atoi(args[++i]); } else if(args[i].equals("-wait")) { - waitReparent = atoi(args[++i]); + waitAdd2nd = atoi(args[++i]); } } String tstname = TestParenting03AWT.class.getName(); diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 223b4193a..3ba721855 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -173,13 +173,15 @@ public class NewtCanvasAWT extends java.awt.Canvas { if(DEBUG) { System.err.println("NewtCanvasAWT.reparentWindow: "+newtChild); } - setSize(cont.getWidth(), cont.getHeight()); - newtChild.setSize(cont.getWidth(), cont.getHeight()); + final int w = cont.getWidth(); + final int h = cont.getHeight(); + setSize(w, h); + newtChild.setSize(w, h); newtChild.reparentWindow(nativeWindow); newtChild.setVisible(true); setWindowAdapter(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener - newtChild.windowRepaint(0, 0, newtChild.getWidth(), newtChild.getHeight()); + newtChild.windowRepaint(0, 0, w, h); newtChild.setFocusAction(focusAction); // enable AWT focus traversal } } else { diff --git a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java index 7802251e5..ae2b7c6e1 100644 --- a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java +++ b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java @@ -400,6 +400,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public void setVisible(boolean visible) { if(isValid()) { + if( 0==windowHandle && visible && 0>=width*height ) { + // fast-path: not realized yet, make visible, but zero size + return; + } VisibleAction va = new VisibleAction(visible); runOnEDTIfAvail(true, va); if( va.getChanged() ) { @@ -427,51 +431,49 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public void run() { windowLock.lock(); try { - if( isValid() ) { - if(DEBUG_IMPLEMENTATION) { - String msg = new String("Window setVisible: START ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+WindowImpl.this.visible+" -> "+visible+", parentWindowHandle "+toHexString(WindowImpl.this.parentWindowHandle)+", parentWindow "+(null!=WindowImpl.this.parentWindow)/*+", "+this*/); - System.err.println(msg); - } - if(!visible && childWindows.size()>0) { - synchronized(childWindowsLock) { - for(Iterator i = childWindows.iterator(); i.hasNext(); ) { - NativeWindow nw = (NativeWindow) i.next(); - if(nw instanceof WindowImpl) { - ((WindowImpl)nw).setVisible(false); - } + if(DEBUG_IMPLEMENTATION) { + String msg = new String("Window setVisible: START ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+WindowImpl.this.visible+" -> "+visible+", parentWindowHandle "+toHexString(WindowImpl.this.parentWindowHandle)+", parentWindow "+(null!=WindowImpl.this.parentWindow)/*+", "+this*/); + System.err.println(msg); + } + if(!visible && childWindows.size()>0) { + synchronized(childWindowsLock) { + for(Iterator i = childWindows.iterator(); i.hasNext(); ) { + NativeWindow nw = (NativeWindow) i.next(); + if(nw instanceof WindowImpl) { + ((WindowImpl)nw).setVisible(false); } - } } - if(0==windowHandle && visible) { - WindowImpl.this.visible = visible; - if( 0<width*height ) { - nativeWindowCreated = createNative(); - } - } else if(WindowImpl.this.visible != visible) { - WindowImpl.this.visible = visible; - if(0 != windowHandle) { - setVisibleImpl(visible); - madeVisible = visible; - } + } + } + if(0==windowHandle && visible) { + WindowImpl.this.visible = visible; + if( 0<width*height ) { + nativeWindowCreated = createNative(); } - - if(null!=lifecycleHook) { - lifecycleHook.setVisibleAction(visible, nativeWindowCreated); + } else if(WindowImpl.this.visible != visible) { + WindowImpl.this.visible = visible; + if(0 != windowHandle) { + setVisibleImpl(visible); + madeVisible = visible; } + } - if(0!=windowHandle && visible && childWindows.size()>0) { - synchronized(childWindowsLock) { - for(Iterator i = childWindows.iterator(); i.hasNext(); ) { - NativeWindow nw = (NativeWindow) i.next(); - if(nw instanceof WindowImpl) { - ((WindowImpl)nw).setVisible(true); - } + if(null!=lifecycleHook) { + lifecycleHook.setVisibleAction(visible, nativeWindowCreated); + } + + if(0!=windowHandle && visible && childWindows.size()>0) { + synchronized(childWindowsLock) { + for(Iterator i = childWindows.iterator(); i.hasNext(); ) { + NativeWindow nw = (NativeWindow) i.next(); + if(nw instanceof WindowImpl) { + ((WindowImpl)nw).setVisible(true); } - } - } - if(DEBUG_IMPLEMENTATION) { - System.err.println("Window setVisible: END ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+WindowImpl.this.visible+", nativeWindowCreated: "+nativeWindowCreated+", madeVisible: "+madeVisible); } + } + } + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window setVisible: END ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+WindowImpl.this.visible+", nativeWindowCreated: "+nativeWindowCreated+", madeVisible: "+madeVisible); } } finally { windowLock.unlock(); @@ -711,7 +713,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer displayChanged = true; } } - reparentAction = ACTION_NATIVE_CREATION; + if( 0<width*height ) { + reparentAction = ACTION_NATIVE_CREATION; + } else { + reparentAction = ACTION_NATIVE_CREATION_PENDING; + } } else if ( DEBUG_TEST_REPARENT_INCOMPATIBLE || forceDestroyCreate || !NewtFactory.isScreenCompatible(newParentWindow, getScreen()) ) { // Destroy this window (handle screen + native) and @@ -739,12 +745,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( 0 == getParentWindowHandle() ) { // Already Top Window reparentAction = ACTION_UNCHANGED; - } else if ( DEBUG_TEST_REPARENT_INCOMPATIBLE || forceDestroyCreate ) { - // Destroy this window (handle screen + native) and - // keep Screen/Display and - // mark it for creation. + } else if( !isNativeValid() || DEBUG_TEST_REPARENT_INCOMPATIBLE || forceDestroyCreate ) { + // Destroy this window (handle screen + native), + // keep Screen/Display and mark it for creation. destroy(false); - reparentAction = ACTION_NATIVE_CREATION; + if( 0<width*height ) { + reparentAction = ACTION_NATIVE_CREATION; + } else { + reparentAction = ACTION_NATIVE_CREATION_PENDING; + } } else { // Mark it for native reparenting reparentAction = ACTION_NATIVE_REPARENTING; diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index d39e0e29b..c44f4c6c8 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -447,7 +447,7 @@ public class GLWindow implements GLAutoDrawable, Window { return; } - if( null == context && isVisible() ) { + if( null == context && isVisible() && 0<getWidth()*getHeight() ) { // retry native window and drawable/context creation setVisible(true); } |