diff options
author | Sven Gothel <[email protected]> | 2011-11-25 00:12:17 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-11-25 00:12:17 +0100 |
commit | c84e235b3284d0e18481748b44594116e25821a9 (patch) | |
tree | e18d64647e830132389ef675d85cef13a080380f /src/newt/classes/com | |
parent | 3bc1ef8344ad44969ef436a0b98b0cde490a78fa (diff) |
JOGL/NativeWindow: Push down JOGL's X11AWTGLXGraphicsConfigurationFactory to NativeWindow X11AWTGraphicsConfigurationFactory
X11AWTGraphicsConfigurationFactory properly construct a AWTGraphicsConfiguration
encapsulated a native X11GraphicsConfiguration, now available for non JOGL modules, ie NEWT.
AWTGraphicsConfiguration's create() utilizes the X11AWTGraphicsConfigurationFactory
via the generic factory mechanism and hence allows encapsulating a native [X11]GraphicsConfiguration.
NewtCanvasAWT creates/destroys the JAWT NativeWindow on addNotify/removeNotify (reparentWindow) again.
Hence the JAWTWindow is instantiated completly only, instead of utilizing updateConfiguration(..),
which simplifies the mechanism.
Diffstat (limited to 'src/newt/classes/com')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 40 |
1 files changed, 10 insertions, 30 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; + } } } |