diff options
Diffstat (limited to 'src/newt')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 40 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java | 23 |
2 files changed, 13 insertions, 50 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index f56a95537..2506710f5 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -41,8 +41,6 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Set; -import javax.media.nativewindow.Capabilities; -import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.WindowClosingProtocol; import javax.media.nativewindow.awt.AWTWindowClosingProtocol; @@ -72,6 +70,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto public static final boolean DEBUG = Debug.debug("Window"); private JAWTWindow jawtWindow = null; + private boolean shallUseOffscreenLayer = false; private Window newtChild = null; private boolean isOnscreen = true; private int newtChildCloseOp; @@ -91,7 +90,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto */ public NewtCanvasAWT() { super(); - createNativeWindow(new Capabilities()); } /** @@ -99,23 +97,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto */ public NewtCanvasAWT(GraphicsConfiguration gc) { super(gc); - createNativeWindow(new Capabilities()); - } - - /** - * Instantiates a NewtCanvas without a NEWT child.<br> - */ - public NewtCanvasAWT(CapabilitiesImmutable caps) { - super(); - createNativeWindow(caps); - } - - /** - * Instantiates a NewtCanvas without a NEWT child.<br> - */ - public NewtCanvasAWT(GraphicsConfiguration gc, CapabilitiesImmutable caps) { - super(gc); - createNativeWindow(caps); } /** @@ -123,7 +104,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto */ public NewtCanvasAWT(Window child) { super(); - createNativeWindow(child.getRequestedCapabilities()); setNEWTChild(child); } @@ -132,14 +112,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto */ public NewtCanvasAWT(GraphicsConfiguration gc, Window child) { super(gc); - createNativeWindow(child.getRequestedCapabilities()); setNEWTChild(child); } - private final void createNativeWindow(CapabilitiesImmutable caps) { - jawtWindow = NewtFactoryAWT.getNativeWindow(this, caps); - } - /** * Request an JAWT offscreen layer if supported it. * Shall be called before {@link #addNotify()} is issued, @@ -148,7 +123,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto * @see #isOffscreenLayerSurface() */ public void setShallUseOffscreenLayer(boolean v) { - jawtWindow.setShallUseOffscreenLayer(v); + shallUseOffscreenLayer = v; } /** @@ -391,9 +366,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChild.setFocusAction(null); // no AWT focus traversal .. if(add) { - NewtFactoryAWT.updateGraphicsConfiguration(jawtWindow, this); + jawtWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities()); + jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); if(DEBUG) { - System.err.println("NewtCanvasAWT.reparentWindow: "+newtChild); + System.err.println("NewtCanvasAWT.reparentWindow: newtChild: "+newtChild); } final int w; final int h; @@ -424,9 +400,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto // since this it is completely covered by the newtChild (z-order). setFocusable(true); } else { - configureNewtChild(false); + configureNewtChild(false); newtChild.setVisible(false); newtChild.reparentWindow(null); + if(null != jawtWindow) { + jawtWindow.destroy(); + jawtWindow=null; + } } } diff --git a/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java b/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java index d4b2fd3d6..a551ae689 100644 --- a/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java +++ b/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java @@ -36,6 +36,7 @@ import javax.media.nativewindow.awt.*; import com.jogamp.newt.NewtFactory; import jogamp.nativewindow.jawt.JAWTWindow; +import jogamp.nativewindow.x11.awt.X11AWTGraphicsConfigurationFactory; import jogamp.newt.Debug; public class NewtFactoryAWT extends NewtFactory { @@ -64,7 +65,7 @@ public class NewtFactoryAWT extends NewtFactory { } public static JAWTWindow getNativeWindow(java.awt.Component awtComp, CapabilitiesImmutable capsRequested) { - AWTGraphicsConfiguration config = AWTGraphicsConfiguration.create(awtComp, null, capsRequested); + AWTGraphicsConfiguration config = X11AWTGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(awtComp, null, capsRequested); NativeWindow nw = NativeWindowFactory.getNativeWindow(awtComp, config); // a JAWTWindow if(! ( nw instanceof JAWTWindow ) ) { throw new NativeWindowException("Not an AWT NativeWindow: "+nw); @@ -73,24 +74,6 @@ public class NewtFactoryAWT extends NewtFactory { System.err.println("NewtFactoryAWT.getNativeWindow: "+awtComp+" -> "+nw); } return (JAWTWindow)nw; - } - - public static void updateGraphicsConfiguration(JAWTWindow nw, java.awt.Component awtComp) { - if(DEBUG_IMPLEMENTATION) { - System.err.println("NewtFactoryAWT.updateGraphicsConfiguration: (pre) "+awtComp+" -> "+nw); - } - final AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration) nw.getGraphicsConfiguration(); - awtConfig.updateGraphicsConfiguration(awtComp); - // lockSurface() re-issues JAWTWindow's native validation - if( NativeSurface.LOCK_SURFACE_NOT_READY >= nw.lockSurface() ) { - throw new NativeWindowException("could not lock "+nw); - } - nw.unlockSurface(); - - if(DEBUG_IMPLEMENTATION) { - System.err.println("NewtFactoryAWT.updateGraphicsConfiguration: (post) "+awtComp+" -> "+nw); - } - } - + } } |