diff options
Diffstat (limited to 'src/nativewindow/classes/javax')
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(); |