aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-10-09 19:33:14 +0200
committerSven Gothel <[email protected]>2010-10-09 19:33:14 +0200
commit5e1a67c9bd3f8420eeab2d3879a795e25de22936 (patch)
tree2a9bba744c0970c44e7cfd5afc29664b376fcdfa /src/newt/classes
parent579326db93ebe3d72c6b9f3acf74fadf21ec9f17 (diff)
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);
Diffstat (limited to 'src/newt/classes')
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java8
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/WindowImpl.java97
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java2
3 files changed, 59 insertions, 48 deletions
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);
}