summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/javax
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-10-29 03:58:33 +0200
committerSven Gothel <[email protected]>2010-10-29 03:58:33 +0200
commit7e606ef39fa9d73cc7306cc0027989bc7704708d (patch)
tree9dad08525d8bc33195194a010dc31f3ea4a267c8 /src/nativewindow/classes/javax
parent27530775e22bd04242a91a8f12f8c6c930c398b9 (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/nativewindow/classes/javax')
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java12
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java44
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java15
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java7
4 files changed, 51 insertions, 27 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java
index b003db8f5..581df5163 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java
@@ -68,4 +68,16 @@ public interface AbstractGraphicsDevice extends Cloneable {
* The lock implementation must be recursive.
*/
public void unlock();
+
+ /**
+ * Optionally closing the device.<br>
+ * The default implementation is a NOP operation, returning false.<br>
+ * The specific implementing, ie {@link javax.media.nativewindow.x11.X11GraphicsDevice},
+ * shall have a enable/disable like {@link javax.media.nativewindow.x11.X11GraphicsDevice#setCloseDisplay(boolean, boolean)},<br>
+ * which shall be invoked at creation time to determine ownership/role of freeing the resource.<br>
+ *
+ * @return true if a specialized closing operation was successfully issued, otherwise false,
+ * ie no native closing operation was issued, which doesn't imply an error at all.
+ */
+ public boolean close();
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java
index ca0f106f5..b67688116 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java
@@ -91,26 +91,6 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice
}
/**
- * Set the internal ToolkitLock, which is used within the
- * {@link #lock()} and {@link #unlock()} implementation.
- *
- * @param locker the ToolkitLock, if null, {@link com.jogamp.nativewindow.impl.NullToolkitLock} is being used
- */
- protected void setToolkitLock(ToolkitLock locker) {
- this.toolkitLock = ( null == locker ) ? NativeWindowFactoryImpl.getNullToolkitLock() : locker ;
- }
-
- /**
- * @return the used ToolkitLock
- *
- * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long)
- * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock)
- */
- public final ToolkitLock getToolkitLock() {
- return toolkitLock;
- }
-
- /**
* No lock is performed on the graphics device per default,
* instead the aggregated recursive {@link ToolkitLock#lock()} is invoked.
*
@@ -132,7 +112,31 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice
toolkitLock.unlock();
}
+ public boolean close() {
+ return false;
+ }
+
public String toString() {
return getClass().toString()+"[type "+getType()+", handle 0x"+Long.toHexString(getHandle())+"]";
}
+
+ /**
+ * Set the internal ToolkitLock, which is used within the
+ * {@link #lock()} and {@link #unlock()} implementation.
+ *
+ * @param locker the ToolkitLock, if null, {@link com.jogamp.nativewindow.impl.NullToolkitLock} is being used
+ */
+ protected void setToolkitLock(ToolkitLock locker) {
+ this.toolkitLock = ( null == locker ) ? NativeWindowFactoryImpl.getNullToolkitLock() : locker ;
+ }
+
+ /**
+ * @return the used ToolkitLock
+ *
+ * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long)
+ * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock)
+ */
+ public final ToolkitLock getToolkitLock() {
+ return toolkitLock;
+ }
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java
index 31744702d..c60597661 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java
@@ -32,12 +32,15 @@
package javax.media.nativewindow.x11;
+import com.jogamp.nativewindow.impl.x11.X11Util;
import javax.media.nativewindow.*;
/** Encapsulates a graphics device on X11 platforms.
*/
public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneable {
+ boolean closeDisplay = false;
+
/** Constructs a new X11GraphicsDevice corresponding to the given native display handle and default
* {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#createDefaultToolkitLock(java.lang.String, long)}.
*/
@@ -62,5 +65,17 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
public Object clone() {
return super.clone();
}
+
+ public void setCloseDisplay(boolean close) {
+ closeDisplay = close;
+ }
+ public boolean close() {
+ if(closeDisplay && 0 != handle) {
+ X11Util.closeDisplay(handle);
+ handle = 0;
+ return true;
+ }
+ return true;
+ }
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
index 73af5f852..dca0d1de3 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
@@ -53,13 +53,6 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl
return new X11GraphicsScreen(new X11GraphicsDevice(display), screenIdx);
}
- /** Creates a new X11GraphicsScreen using a thread local display connection */
- public static AbstractGraphicsScreen createDefault() {
- long display = X11Util.createThreadLocalDisplay(null);
- int scrnIdx = X11Util.DefaultScreen(display);
- return createScreenDevice(display, scrnIdx);
- }
-
public long getDefaultVisualID() {
// It still could be an AWT hold handle ..
long display = getDevice().getHandle();