diff options
author | Sven Gothel <[email protected]> | 2010-10-29 03:58:33 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-10-29 03:58:33 +0200 |
commit | 7e606ef39fa9d73cc7306cc0027989bc7704708d (patch) | |
tree | 9dad08525d8bc33195194a010dc31f3ea4a267c8 /src/newt/classes/com/jogamp | |
parent | 27530775e22bd04242a91a8f12f8c6c930c398b9 (diff) |
Proper X11 Display Closing
X11Util:
Removed TLS semantics, since TLS name -> dpy mapping is erroneous at this point.
Added lists for open connections (for optional later shutdown).
AbstractGraphicsDevice interface and implementations:
Adding 'close()' method allowing native implementations the ability
to close the native resource, ie X11GraphicsDevice.
This becomes necessary for 'on the fly' created X11 Display connections,
ie in X11AWTGLXGraphicsConfigurationFactory, which enables closing.
Utilize 'close' call in use cases: GLCanvas, GLJPanel and AWTCanvas.
Remove active X11 Display creation in X11JAWTWindow,
as a last resort, use the X11SunJDKReflection method.
Used for reference only, not active rendering etc,
mostly for on the fly AWT parenting in NewtFactoryAWT.
However, these 'on the fly' references are erroneous and should be remodelled,
ie passice and active X11GraphicsDevice's ..
Diffstat (limited to 'src/newt/classes/com/jogamp')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java index bbf75798e..9b0ec6907 100644 --- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java +++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java @@ -37,12 +37,10 @@ import com.jogamp.newt.Window; import java.awt.Canvas; import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; import java.awt.GraphicsConfiguration; import javax.media.nativewindow.*; import javax.media.nativewindow.awt.*; -import com.jogamp.newt.impl.Debug; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; @@ -102,6 +100,28 @@ public class AWTCanvas extends Canvas { } } + public void removeNotify() { + try { + dispose(); + } finally { + super.removeNotify(); + } + } + + private void dispose() { + if(null != awtConfig) { + AbstractGraphicsDevice adevice = awtConfig.getNativeGraphicsConfiguration().getScreen().getDevice(); + String adeviceMsg=null; + if(Window.DEBUG_IMPLEMENTATION) { + adeviceMsg = adevice.toString(); + } + boolean closed = adevice.close(); + if(Window.DEBUG_IMPLEMENTATION) { + System.err.println("AWTCanvas.dispose(): closed GraphicsDevice: "+adeviceMsg+", result: "+closed); + } + } + } + /** * Overridden to choose a GraphicsConfiguration on a parent container's * GraphicsDevice because both devices |