From 7e606ef39fa9d73cc7306cc0027989bc7704708d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 29 Oct 2010 03:58:33 +0200 Subject: 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 .. --- .../com/jogamp/newt/impl/awt/AWTCanvas.java | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/newt/classes') 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 -- cgit v1.2.3