From 5e1a67c9bd3f8420eeab2d3879a795e25de22936 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 9 Oct 2010 19:33:14 +0200 Subject: NEWT: WindowImpl/GLWindow add zero size fast path; Reparent: Zero size -> pending creation NEWT/AWT: TestParenting03AWT use Container and add delay in addNotify(2nd-gl-element); --- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 8 +- .../classes/com/jogamp/newt/impl/WindowImpl.java | 97 ++++++++++++---------- .../classes/com/jogamp/newt/opengl/GLWindow.java | 2 +- 3 files changed, 59 insertions(+), 48 deletions(-) (limited to 'src/newt/classes') 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( 00) { - 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