aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/javax
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow/classes/javax')
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java4
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/Capabilities.java16
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java26
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java8
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java38
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java62
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java14
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java135
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java174
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsDevice.java77
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsScreen.java92
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/awt/AWTWindowClosingProtocol.java139
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/egl/EGLGraphicsDevice.java60
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/macosx/MacOSXGraphicsDevice.java50
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/windows/WindowsGraphicsDevice.java54
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java81
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java103
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java77
20 files changed, 251 insertions, 963 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
index 1930bdda3..ebdaf2fbb 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
@@ -43,7 +43,7 @@ package javax.media.nativewindow;
/** A marker interface describing a graphics configuration, visual, or
pixel format in a toolkit-independent manner. */
-public interface AbstractGraphicsConfiguration extends Cloneable {
+public interface AbstractGraphicsConfiguration extends VisualIDHolder, Cloneable {
/**
* Return the screen this graphics configuration is valid for
*/
diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java
index fa25c214f..1dd01a274 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java
@@ -114,8 +114,8 @@ public interface AbstractGraphicsDevice extends Cloneable {
* <p>
* The default implementation is a <code>NOP</code>, just setting the handle to <code>null</code>.
* </p>
- * 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>
+ * The specific implementing, ie {@link com.jogamp.nativewindow.x11.X11GraphicsDevice},
+ * shall have a enable/disable like {@link com.jogamp.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 the handle was not <code>null</code>, otherwise false.
diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
index 368847e5c..7a58e688f 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
@@ -40,11 +40,15 @@
package javax.media.nativewindow;
+import javax.media.nativewindow.VisualIDHolder.VIDType;
+
/** Specifies a set of capabilities that a window's rendering context
must support, such as color depth per channel. It currently
contains the minimal number of routines which allow configuration
on all supported window systems. */
public class Capabilities implements CapabilitiesImmutable, Cloneable, Comparable {
+ protected final static String na_str = "----" ;
+
private int redBits = 8;
private int greenBits = 8;
private int blueBits = 8;
@@ -138,6 +142,17 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable, Comparabl
return 0; // they are equal: RGBA
}
+ @Override
+ public int getVisualID(VIDType type) throws NativeWindowException {
+ switch(type) {
+ case INTRINSIC:
+ case NATIVE:
+ return VisualIDHolder.VID_UNDEFINED;
+ default:
+ throw new NativeWindowException("Invalid type <"+type+">");
+ }
+ }
+
/** Returns the number of bits requested for the color buffer's red
component. On some systems only the color depth, which is the
sum of the red, green, and blue bits, is considered. */
@@ -329,4 +344,5 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable, Comparabl
msg.append("]");
return msg.toString();
}
+
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
index eccdf7797..848ec74e1 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
@@ -36,7 +36,7 @@ import com.jogamp.common.type.WriteCloneable;
*
* @see javax.media.nativewindow.Capabilities
*/
-public interface CapabilitiesImmutable extends WriteCloneable {
+public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable {
/**
* Returns the number of bits requested for the color buffer's red
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
index 3eb7a6c9a..a33c3792a 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
@@ -32,7 +32,11 @@
package javax.media.nativewindow;
+import jogamp.nativewindow.Debug;
+
public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphicsConfiguration {
+ protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
+
private AbstractGraphicsScreen screen;
protected CapabilitiesImmutable capabilitiesChosen;
protected CapabilitiesImmutable capabilitiesRequested;
@@ -40,13 +44,16 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
public DefaultGraphicsConfiguration(AbstractGraphicsScreen screen,
CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) {
if(null == screen) {
- throw new NativeWindowException("Null screen");
+ throw new IllegalArgumentException("Null screen");
}
if(null == capsChosen) {
- throw new NativeWindowException("Null chosen caps");
+ throw new IllegalArgumentException("Null chosen caps");
}
if(null == capsRequested) {
- throw new NativeWindowException("Null requested caps");
+ throw new IllegalArgumentException("Null requested caps");
+ }
+ if( ! ( capsChosen instanceof VisualIDHolder ) ) {
+ throw new IllegalArgumentException("Chosen caps is not implementing NativeVisualID");
}
this.screen = screen;
this.capabilitiesChosen = capsChosen;
@@ -62,15 +69,15 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
}
}
- public AbstractGraphicsScreen getScreen() {
+ final public AbstractGraphicsScreen getScreen() {
return screen;
}
- public CapabilitiesImmutable getChosenCapabilities() {
+ final public CapabilitiesImmutable getChosenCapabilities() {
return capabilitiesChosen;
}
- public CapabilitiesImmutable getRequestedCapabilities() {
+ final public CapabilitiesImmutable getRequestedCapabilities() {
return capabilitiesRequested;
}
@@ -78,6 +85,11 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
return this;
}
+ @Override
+ final public int getVisualID(VIDType type) throws NativeWindowException {
+ return capabilitiesChosen.getVisualID(type);
+ }
+
/**
* Set the capabilities to a new value.
*
@@ -98,7 +110,7 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
*
* A copy of the passed object is being used.
*/
- protected void setScreen(DefaultGraphicsScreen screen) {
+ final protected void setScreen(DefaultGraphicsScreen screen) {
this.screen = (AbstractGraphicsScreen) screen.clone();
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
index fb8bf2764..e5f230b4c 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
@@ -223,12 +223,12 @@ public abstract class GraphicsConfigurationFactory {
* returned graphics configuration must be specified in the
* documentation binding this particular API to the underlying
* window toolkit. The Reference Implementation accepts {@link
- * javax.media.nativewindow.awt.AWTGraphicsDevice AWTGraphicsDevice} objects and returns {@link
- * javax.media.nativewindow.awt.AWTGraphicsConfiguration AWTGraphicsConfiguration} objects. On
+ * com.jogamp.nativewindow.awt.AWTGraphicsDevice AWTGraphicsDevice} objects and returns {@link
+ * com.jogamp.nativewindow.awt.AWTGraphicsConfiguration AWTGraphicsConfiguration} objects. On
* X11 platforms where the AWT is not in use, it also accepts
- * {@link javax.media.nativewindow.x11.X11GraphicsDevice
+ * {@link com.jogamp.nativewindow.x11.X11GraphicsDevice
* X11GraphicsDevice} objects and returns {@link
- * javax.media.nativewindow.x11.X11GraphicsConfiguration
+ * com.jogamp.nativewindow.x11.X11GraphicsConfiguration
* X11GraphicsConfiguration} objects.</P>
*
* @param capsChosen the intermediate chosen capabilities to be refined by this implementation, may be equal to capsRequested
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
index e255dc051..b7829cb6d 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
@@ -50,23 +50,35 @@ public interface NativeSurface extends SurfaceUpdatedListener {
public static final int LOCK_SUCCESS = 3;
/**
- * Lock the surface of this native window<P>
- *
- * The surface handle, see {@link #lockSurface()}, <br>
- * shall be valid after a successfull call,
- * ie return a value other than {@link #LOCK_SURFACE_NOT_READY}.<P>
- *
+ * Lock the surface of this native window.
+ * <p>
+ * The surface handle shall be valid after a successfull call,
+ * ie return a value other than {@link #LOCK_SURFACE_UNLOCKED} and {@link #LOCK_SURFACE_NOT_READY},
+ * which is
+ * <pre>
+ * boolean ok = lockSurface() > LOCK_SURFACE_NOT_READY;
+ * </pre>
+ * </p>
+ * <p>
+ * The caller may need to take care of the result {@link #LOCK_SURFACE_CHANGED},
+ * where the surface handle is valid but has changed.
+ * </p>
+ * <p>
* This call is blocking until the surface has been locked
- * or a timeout is reached. The latter will throw a runtime exception. <P>
- *
- * This call allows recursion from the same thread.<P>
- *
+ * or a timeout is reached. The latter will throw a runtime exception.
+ * </p>
+ * <p>
+ * This call allows recursion from the same thread.
+ * </p>
+ * <p>
* The implementation may want to aquire the
* application level {@link com.jogamp.common.util.locks.RecursiveLock}
- * first before proceeding with a native surface lock. <P>
- *
+ * first before proceeding with a native surface lock.
+ * </p>
+ * <p>
* The implementation shall also invoke {@link AbstractGraphicsDevice#lock()}
- * for the initial lock (recursive count zero).<P>
+ * for the initial lock (recursive count zero).
+ * </p>
*
* @return {@link #LOCK_SUCCESS}, {@link #LOCK_SURFACE_CHANGED} or {@link #LOCK_SURFACE_NOT_READY}.
*
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
index 683fb4847..b8cd41b84 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
@@ -91,9 +91,7 @@ public abstract class NativeWindowFactory {
private static final String OSXUtilClassName = "jogamp.nativewindow.macosx.OSXUtil";
private static final String GDIClassName = "jogamp.nativewindow.windows.GDIUtil";
- private static Class<?> jawtUtilClass;
- private static Method jawtUtilGetJAWTToolkitMethod;
- private static Method jawtUtilInitMethod;
+ private static ToolkitLock jawtUtilJAWTToolkitLock;
public static final String AWTComponentClassName = "java.awt.Component" ;
public static final String X11JAWTToolkitLockClassName = "jogamp.nativewindow.jawt.x11.X11JAWTToolkitLock" ;
@@ -210,31 +208,48 @@ public abstract class NativeWindowFactory {
if( !Debug.getBooleanProperty("java.awt.headless", true, acc) &&
ReflectionUtil.isClassAvailable(AWTComponentClassName, cl) &&
- ReflectionUtil.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice", cl) ) {
-
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
+ ReflectionUtil.isClassAvailable("com.jogamp.nativewindow.awt.AWTGraphicsDevice", cl) ) {
+
+ Method[] jawtUtilMethods = AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
+ public Method[] run() {
try {
- jawtUtilClass = Class.forName(JAWTUtilClassName, true, NativeWindowFactory.class.getClassLoader());
- jawtUtilInitMethod = jawtUtilClass.getDeclaredMethod("initSingleton", (Class[])null);
+ Class<?> _jawtUtilClass = Class.forName(JAWTUtilClassName, true, NativeWindowFactory.class.getClassLoader());
+ Method jawtUtilIsHeadlessMethod = _jawtUtilClass.getDeclaredMethod("isHeadlessMode", (Class[])null);
+ jawtUtilIsHeadlessMethod.setAccessible(true);
+ Method jawtUtilInitMethod = _jawtUtilClass.getDeclaredMethod("initSingleton", (Class[])null);
jawtUtilInitMethod.setAccessible(true);
- jawtUtilGetJAWTToolkitMethod = jawtUtilClass.getDeclaredMethod("getJAWTToolkitLock", new Class[]{});
- jawtUtilGetJAWTToolkitMethod.setAccessible(true);
+ Method jawtUtilGetJAWTToolkitLockMethod = _jawtUtilClass.getDeclaredMethod("getJAWTToolkitLock", new Class[]{});
+ jawtUtilGetJAWTToolkitLockMethod.setAccessible(true);
+ return new Method[] { jawtUtilInitMethod, jawtUtilIsHeadlessMethod, jawtUtilGetJAWTToolkitLockMethod };
} catch (Exception e) {
- // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5
+ if(DEBUG) {
+ e.printStackTrace();
+ }
}
return null;
}
});
- if(null != jawtUtilClass && null != jawtUtilGetJAWTToolkitMethod && null != jawtUtilInitMethod) {
+ if(null != jawtUtilMethods) {
+ final Method jawtUtilInitMethod = jawtUtilMethods[0];
+ final Method jawtUtilIsHeadlessMethod = jawtUtilMethods[1];
+ final Method jawtUtilGetJAWTToolkitLockMethod = jawtUtilMethods[2];
+
ReflectionUtil.callMethod(null, jawtUtilInitMethod);
- Object resO = ReflectionUtil.callStaticMethod(JAWTUtilClassName, "isHeadlessMode", null, null, cl );
+ Object resO = ReflectionUtil.callMethod(null, jawtUtilIsHeadlessMethod);
if(resO instanceof Boolean) {
// AWT is only available in case all above classes are available
// and AWT is not int headless mode
isAWTAvailable = ((Boolean)resO).equals(Boolean.FALSE);
+ } else {
+ throw new RuntimeException("JAWTUtil.isHeadlessMode() didn't return a Boolean");
}
+ resO = ReflectionUtil.callMethod(null, jawtUtilGetJAWTToolkitLockMethod);
+ if(resO instanceof ToolkitLock) {
+ jawtUtilJAWTToolkitLock = (ToolkitLock) resO;
+ } else {
+ throw new RuntimeException("JAWTUtil.getJAWTToolkitLock() didn't return a ToolkitLock");
+ }
}
}
if(!firstUIActionOnProcess) {
@@ -351,10 +366,10 @@ public abstract class NativeWindowFactory {
* <ul>
* <li>If <b>AWT-type</b> and <b>native-X11-type</b> and <b>AWT-available</b></li>
* <ul>
- * <li> return {@link jogamp.nativewindow.jawt.JAWTToolkitLock} </li>
+ * <li> return {@link #getAWTToolkitLock()} </li>
* </ul>
* </ul>
- * <li> Otherwise return {@link jogamp.nativewindow.NullToolkitLock} </li>
+ * <li> Otherwise return {@link #getNullToolkitLock()} </li>
* </ul>
*/
public static ToolkitLock getDefaultToolkitLock(String type) {
@@ -366,18 +381,9 @@ public abstract class NativeWindowFactory {
return NativeWindowFactoryImpl.getNullToolkitLock();
}
- private static ToolkitLock getAWTToolkitLock() {
- Object resO = ReflectionUtil.callMethod(null, jawtUtilGetJAWTToolkitMethod);
-
- if(DEBUG) {
- System.err.println("NativeWindowFactory.getAWTToolkitLock()");
- Thread.dumpStack();
- }
- if(resO instanceof ToolkitLock) {
- return (ToolkitLock) resO;
- } else {
- throw new RuntimeException("JAWTUtil.getJAWTToolkitLock() didn't return a ToolkitLock");
- }
+ /** Returns the AWT Toolkit (JAWT based) if {@link #isAWTAvailable}, otherwise null. */
+ public static ToolkitLock getAWTToolkitLock() {
+ return jawtUtilJAWTToolkitLock;
}
public static ToolkitLock getNullToolkitLock() {
diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
index 9100beac2..6a36bb130 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
@@ -28,15 +28,20 @@
package javax.media.nativewindow;
+
+import jogamp.nativewindow.Debug;
import jogamp.nativewindow.SurfaceUpdatedHelper;
import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
public abstract class ProxySurface implements NativeSurface {
+ public static final boolean DEBUG = Debug.debug("ProxySurface");
+
private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper();
private AbstractGraphicsConfiguration config; // control access due to delegation
protected RecursiveLock surfaceLock = LockFactory.createRecursiveLock();
+ private long surfaceHandle_old;
protected long displayHandle;
protected int height;
protected int scrnIndex;
@@ -46,6 +51,7 @@ public abstract class ProxySurface implements NativeSurface {
invalidate();
config = cfg;
displayHandle=cfg.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle();
+ surfaceHandle_old = 0;
}
void invalidate() {
@@ -115,6 +121,13 @@ public abstract class ProxySurface implements NativeSurface {
adevice.lock();
try {
res = lockSurfaceImpl();
+ if(LOCK_SUCCESS == res && surfaceHandle_old != getSurfaceHandle()) {
+ res = LOCK_SURFACE_CHANGED;
+ if(DEBUG) {
+ System.err.println("ProxySurface: surface change 0x"+Long.toHexString(surfaceHandle_old)+" -> 0x"+Long.toHexString(getSurfaceHandle()));
+ // Thread.dumpStack();
+ }
+ }
} finally {
if (LOCK_SURFACE_NOT_READY >= res) {
adevice.unlock();
@@ -131,6 +144,7 @@ public abstract class ProxySurface implements NativeSurface {
public final void unlockSurface() {
surfaceLock.validateLocked();
+ surfaceHandle_old = getSurfaceHandle();
if (surfaceLock.getHoldCount() == 1) {
final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
diff --git a/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java b/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java
new file mode 100644
index 000000000..4f3d3ff00
--- /dev/null
+++ b/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java
@@ -0,0 +1,135 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package javax.media.nativewindow;
+
+import java.util.Comparator;
+
+/**
+ * Visual ID holder interface.
+ * <p>
+ * Allows queries of different types of native visual IDs,
+ * see {@link #getVisualID(int)}.
+ * </p>
+ */
+public interface VisualIDHolder {
+
+ public enum VIDType {
+ // Generic Values
+ INTRINSIC(0), NATIVE(1),
+ // EGL Values
+ EGL_CONFIG(10),
+ // X11 Values
+ X11_XVISUAL(20), X11_FBCONFIG(21),
+ // Windows Values
+ WIN32_PFD(30);
+
+ public final int id;
+
+ VIDType(int id){
+ this.id = id;
+ }
+ }
+
+ /**
+ * Returns the native visual ID of the given <code>type</code>
+ * if supported, or {@link #VID_UNDEFINED} if not supported.
+ * <p>
+ * Depending on the native windowing system, <code>type</code> is handled as follows:
+ * <ul>
+ * <li>X11 throws NativeWindowException on <code>EGL_CONFIG</code>, <code>WIN32_PFD</code>
+ * <ul>
+ * <li><code>INTRINSIC</code>: <i>X11 XVisual ID</i></li>
+ * <li><code>NATIVE</code>: <i>X11 XVisual ID</i></li>
+ * <li><code>X11_XVISUAL</code>: <i>X11 XVisual ID</i></li>
+ * <li><code>X11_FBCONFIG</code>: <code>VID_UNDEFINED</code></li>
+ * </ul></li>
+ * <li>X11/GL throws NativeWindowException on <code>EGL_CONFIG</code>, <code>WIN32_PFD</code>
+ * <ul>
+ * <li><code>INTRINSIC</code>: <i>X11 XVisual ID</i></li>
+ * <li><code>NATIVE</code>: <i>X11 XVisual ID</i></li>
+ * <li><code>X11_XVISUAL</code>: <i>X11 XVisual ID</i></li>
+ * <li><code>X11_FBCONFIG</code>: <i>X11 FBConfig ID</i> or <code>VID_UNDEFINED</code></li>
+ * </ul></li>
+ * <li>Windows/GL throws NativeWindowException on <code>EGL_CONFIG</code>, <code>X11_XVISUAL</code>, <code>X11_FBCONFIG</code>
+ * <ul>
+ * <li><code>INTRINSIC</code>: <i>Win32 PIXELFORMATDESCRIPTOR ID</i></li>
+ * <li><code>NATIVE</code>: <i>Win32 PIXELFORMATDESCRIPTOR ID</i></li>
+ * <li><code>WIN32_PFD</code>: <i>Win32 PIXELFORMATDESCRIPTOR ID</i></li>
+ * </ul></li>
+ * <li>EGL/GL throws NativeWindowException on <code>X11_XVISUAL</code>, <code>X11_FBCONFIG</code>, <code>WIN32_PFD</code>
+ * <ul>
+ * <li><code>INTRINSIC</code>: <i>EGL Config ID</i></li>
+ * <li><code>NATIVE</code>: <i>EGL NativeVisual ID</i> (<i>X11 XVisual ID</i>, <i>Win32 PIXELFORMATDESCRIPTOR ID</i>, ...)</li>
+ * <li><code>EGL_CONFIG</code>: <i>EGL Config ID</i></li>
+ * </ul></li>
+ * </ul>
+ * </p>
+ * Note: <code>INTRINSIC</code> and <code>NATIVE</code> are always handled,
+ * but may result in {@link #VID_UNDEFINED}. The latter is true if
+ * the native value are actually undefined or the corresponding object is not
+ * mapped to a native visual object.
+ *
+ * @throws NativeWindowException if <code>type</code> is neither
+ * <code>INTRINSIC</code> nor <code>NATIVE</code>
+ * and does not match the native implementation.
+ */
+ int getVisualID(VIDType type) throws NativeWindowException ;
+
+ /**
+ * {@link #getVisualID(VIDType)} result indicating an undefined value,
+ * which could be cause by an unsupported query.
+ * <p>
+ * We assume the const value <code>0</code> doesn't reflect a valid native visual ID
+ * and is interpreted as <i>no value</i> on all platforms.
+ * This is currently true for Android, X11 and Windows.
+ * </p>
+ */
+ static final int VID_UNDEFINED = 0;
+
+ /** Comparing {@link VIDType#NATIVE} */
+ public static class VIDComparator implements Comparator<VisualIDHolder> {
+ private VIDType type;
+
+ public VIDComparator(VIDType type) {
+ this.type = type;
+ }
+
+ public int compare(VisualIDHolder vid1, VisualIDHolder vid2) {
+ final int id1 = vid1.getVisualID(type);
+ final int id2 = vid2.getVisualID(type);
+
+ if(id1 > id2) {
+ return 1;
+ } else if(id1 < id2) {
+ return -1;
+ }
+ return 0;
+ }
+ }
+}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
deleted file mode 100644
index 45a3db838..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package javax.media.nativewindow.awt;
-
-import javax.media.nativewindow.*;
-
-import java.awt.Component;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import java.awt.image.ColorModel;
-import javax.media.nativewindow.AbstractGraphicsConfiguration;
-
-import jogamp.nativewindow.Debug;
-
-/** A wrapper for an AWT GraphicsConfiguration allowing it to be
- handled in a toolkit-independent manner. */
-
-public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable {
- private GraphicsConfiguration config;
- AbstractGraphicsConfiguration encapsulated;
-
- public AWTGraphicsConfiguration(AWTGraphicsScreen screen,
- CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
- GraphicsConfiguration config, AbstractGraphicsConfiguration encapsulated) {
- super(screen, capsChosen, capsRequested);
- this.config = config;
- this.encapsulated=encapsulated;
- }
-
- private AWTGraphicsConfiguration(AWTGraphicsScreen screen, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
- GraphicsConfiguration config) {
- super(screen, capsChosen, capsRequested);
- this.config = config;
- this.encapsulated=null;
- }
-
- /**
- * @param capsChosen if null, <code>capsRequested</code> is copied and aligned
- * with the graphics Capabilities of the AWT Component to produce the chosen Capabilities.
- * Otherwise the <code>capsChosen</code> is used.
- */
- public static AWTGraphicsConfiguration create(Component awtComp, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) {
- final GraphicsConfiguration awtGfxConfig = awtComp.getGraphicsConfiguration();
- if(null==awtGfxConfig) {
- throw new NativeWindowException("AWTGraphicsConfiguration.create: Null AWT GraphicsConfiguration @ "+awtComp);
- }
- final GraphicsDevice awtGraphicsDevice = awtGfxConfig.getDevice();
- if(null==awtGraphicsDevice) {
- throw new NativeWindowException("AWTGraphicsConfiguration.create: Null AWT GraphicsDevice @ "+awtGfxConfig);
- }
-
- // Create Device/Screen
- final AWTGraphicsDevice awtDevice = new AWTGraphicsDevice(awtGraphicsDevice, AbstractGraphicsDevice.DEFAULT_UNIT);
- final AWTGraphicsScreen awtScreen = new AWTGraphicsScreen(awtDevice);
-
- if(null==capsChosen) {
- GraphicsConfiguration gc = awtGraphicsDevice.getDefaultConfiguration();
- capsChosen = AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capsRequested, gc);
- }
- final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(awtDevice);
- final AbstractGraphicsConfiguration config = factory.chooseGraphicsConfiguration(capsChosen, capsRequested, null, awtScreen);
- if(config instanceof AWTGraphicsConfiguration) {
- return (AWTGraphicsConfiguration) config;
- }
- // System.err.println("Info: AWTGraphicsConfiguration.create: Expected AWTGraphicsConfiguration got: "+config.getClass()+" w/ factory "+factory.getClass()+" - Unable to encapsulate native GraphicsConfiguration.");
- return new AWTGraphicsConfiguration(awtScreen, capsChosen, capsRequested, awtGfxConfig);
- }
-
- // open access to superclass method
- public void setChosenCapabilities(CapabilitiesImmutable capsChosen) {
- super.setChosenCapabilities(capsChosen);
- }
-
- @Override
- public Object clone() {
- return super.clone();
- }
-
- /** Return the AWT {@link GraphicsConfiguration}. */
- public GraphicsConfiguration getAWTGraphicsConfiguration() {
- return config;
- }
-
- @Override
- public AbstractGraphicsConfiguration getNativeGraphicsConfiguration() {
- return (null!=encapsulated)?encapsulated:this;
- }
-
- /**
- * Sets up the Capabilities' RGBA size based on the given GraphicsConfiguration's ColorModel.
- *
- * @param capabilities the Capabilities object whose red, green, blue, and alpha bits will be set
- * @param gc the GraphicsConfiguration from which to derive the RGBA bit depths
- * @return the passed Capabilities
- */
- public static CapabilitiesImmutable setupCapabilitiesRGBABits(CapabilitiesImmutable capabilitiesIn, GraphicsConfiguration gc) {
- Capabilities capabilities = (Capabilities) capabilitiesIn.cloneMutable();
-
- ColorModel cm = gc.getColorModel();
- if(null==cm) {
- throw new NativeWindowException("Could not determine AWT ColorModel");
- }
- int cmBitsPerPixel = cm.getPixelSize();
- int bitsPerPixel = 0;
- int[] bitesPerComponent = cm.getComponentSize();
- if(bitesPerComponent.length>=3) {
- capabilities.setRedBits(bitesPerComponent[0]);
- bitsPerPixel += bitesPerComponent[0];
- capabilities.setGreenBits(bitesPerComponent[1]);
- bitsPerPixel += bitesPerComponent[1];
- capabilities.setBlueBits(bitesPerComponent[2]);
- bitsPerPixel += bitesPerComponent[2];
- }
- if(bitesPerComponent.length>=4) {
- capabilities.setAlphaBits(bitesPerComponent[3]);
- bitsPerPixel += bitesPerComponent[3];
- } else {
- capabilities.setAlphaBits(0);
- }
- if(Debug.debugAll()) {
- if(cmBitsPerPixel!=bitsPerPixel) {
- System.err.println("AWT Colormodel bits per components/pixel mismatch: "+bitsPerPixel+" != "+cmBitsPerPixel);
- }
- }
- return capabilities;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName()+"[" + getScreen() +
- ",\n\tchosen " + capabilitiesChosen+
- ",\n\trequested " + capabilitiesRequested+
- ",\n\t" + config +
- ",\n\tencapsulated "+encapsulated+"]";
- }
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsDevice.java
deleted file mode 100644
index 8ebe37626..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsDevice.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package javax.media.nativewindow.awt;
-
-import javax.media.nativewindow.*;
-import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
-import javax.media.nativewindow.AbstractGraphicsDevice;
-
-/** A wrapper for an AWT GraphicsDevice allowing it to be
- handled in a toolkit-independent manner. */
-public class AWTGraphicsDevice extends DefaultGraphicsDevice implements Cloneable {
- private GraphicsDevice device;
-
- public AWTGraphicsDevice(GraphicsDevice device, int unitID) {
- super(NativeWindowFactory.TYPE_AWT, device.getIDstring(), unitID);
- this.device = device;
- }
-
- public static AWTGraphicsDevice createDefault() {
- GraphicsDevice awtDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
- return new AWTGraphicsDevice(awtDevice, AbstractGraphicsDevice.DEFAULT_UNIT);
- }
-
- @Override
- public Object clone() {
- return super.clone();
- }
-
- public GraphicsDevice getGraphicsDevice() {
- return device;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", awtDevice "+device+", handle 0x"+Long.toHexString(getHandle())+"]";
- }
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsScreen.java
deleted file mode 100644
index 2978d7868..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsScreen.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package javax.media.nativewindow.awt;
-
-import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
-import javax.media.nativewindow.*;
-
-/** A wrapper for an AWT GraphicsDevice (screen) allowing it to be
- handled in a toolkit-independent manner. */
-
-public class AWTGraphicsScreen extends DefaultGraphicsScreen implements Cloneable {
-
- public AWTGraphicsScreen(AWTGraphicsDevice device) {
- super(device, findScreenIndex(device.getGraphicsDevice()));
- }
-
- public static GraphicsDevice getScreenDevice(int index) {
- if(index<0) return null;
- GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
- GraphicsDevice[] gs = ge.getScreenDevices();
- if(index<gs.length) {
- return gs[index];
- }
- return null;
- }
-
- public static int findScreenIndex(GraphicsDevice awtDevice) {
- if(null==awtDevice) return -1;
- GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
- GraphicsDevice[] gs = ge.getScreenDevices();
- for (int j = 0; j < gs.length; j++) {
- if(gs[j] == awtDevice) return j;
- }
- return -1;
- }
-
- public static AbstractGraphicsScreen createScreenDevice(GraphicsDevice awtDevice, int unitID) {
- return new AWTGraphicsScreen(new AWTGraphicsDevice(awtDevice, unitID));
- }
-
- public static AbstractGraphicsScreen createScreenDevice(int index, int unitID) {
- return createScreenDevice(getScreenDevice(index), unitID);
- }
-
- public static AbstractGraphicsScreen createDefault() {
- return new AWTGraphicsScreen(AWTGraphicsDevice.createDefault());
- }
-
- public Object clone() {
- return super.clone();
- }
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTWindowClosingProtocol.java b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTWindowClosingProtocol.java
deleted file mode 100644
index e7db942e4..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTWindowClosingProtocol.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package javax.media.nativewindow.awt;
-
-import java.awt.Component;
-import java.awt.Window;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import javax.media.nativewindow.WindowClosingProtocol;
-import jogamp.nativewindow.awt.AWTMisc;
-
-public class AWTWindowClosingProtocol implements WindowClosingProtocol {
-
- private Component comp;
- private Runnable closingOperation;
- private volatile boolean closingListenerSet = false;
- private Object closingListenerLock = new Object();
- private int defaultCloseOperation = DISPOSE_ON_CLOSE;
- private boolean defaultCloseOperationSetByUser = false;
-
- public AWTWindowClosingProtocol(Component comp, Runnable closingOperation) {
- this.comp = comp;
- this.closingOperation = closingOperation;
- }
-
- class WindowClosingAdapter extends WindowAdapter {
- @Override
- public void windowClosing(WindowEvent e) {
- int op = AWTWindowClosingProtocol.this.getDefaultCloseOperation();
-
- if( DISPOSE_ON_CLOSE == op ) {
- // we have to issue this call right away,
- // otherwise the window gets destroyed
- closingOperation.run();
- }
- }
- }
- WindowListener windowClosingAdapter = new WindowClosingAdapter();
-
- final boolean addClosingListenerImpl() {
- Window w = AWTMisc.getWindow(comp);
- if(null!=w) {
- w.addWindowListener(windowClosingAdapter);
- return true;
- }
- return false;
- }
-
- /**
- * Adds this closing listener to the components Window if exist and only one time.<br>
- * Hence you may call this method every time to ensure it has been set,
- * ie in case the Window parent is not available yet.
- *
- * @return
- */
- public final boolean addClosingListenerOneShot() {
- if(!closingListenerSet) { // volatile: ok
- synchronized(closingListenerLock) {
- if(!closingListenerSet) {
- closingListenerSet=addClosingListenerImpl();
- return closingListenerSet;
- }
- }
- }
- return false;
- }
-
- public final boolean removeClosingListener() {
- if(closingListenerSet) { // volatile: ok
- synchronized(closingListenerLock) {
- if(closingListenerSet) {
- Window w = AWTMisc.getWindow(comp);
- if(null!=w) {
- w.removeWindowListener(windowClosingAdapter);
- closingListenerSet = false;
- return true;
- }
- }
- }
- }
- return false;
- }
-
- /**
- *
- * @return the user set close operation if set by {@link #setDefaultCloseOperation(int) setDefaultCloseOperation(int)},
- * otherwise return the AWT/Swing close operation value translated to
- * a {@link WindowClosingProtocol} value .
- */
- public final int getDefaultCloseOperation() {
- int op = -1;
- synchronized(closingListenerLock) {
- if(defaultCloseOperationSetByUser) {
- op = defaultCloseOperation;
- }
- }
- if(0 <= op) {
- return op;
- }
- // User didn't determine the behavior, use underlying AWT behavior
- return AWTMisc.getNWClosingOperation(comp);
- }
-
- public final int setDefaultCloseOperation(int op) {
- synchronized(closingListenerLock) {
- int _op = defaultCloseOperation;
- defaultCloseOperation = op;
- defaultCloseOperationSetByUser = true;
- return _op;
- }
- }
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/egl/EGLGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/egl/EGLGraphicsDevice.java
deleted file mode 100644
index 2dfd9f0ee..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/egl/EGLGraphicsDevice.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-
-package javax.media.nativewindow.egl;
-
-import javax.media.nativewindow.*;
-
-/** Encapsulates a graphics device on EGL platforms.
- */
-
-public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneable {
- boolean closeDisplay = false;
-
- /**
- * Note that this is not an open connection, ie no native display handle exist.
- * This constructor exist to setup a default device connection/unit.<br>
- */
- public EGLGraphicsDevice(String connection, int unitID) {
- super(NativeWindowFactory.TYPE_EGL, connection, unitID);
- }
-
- /** Constructs a new EGLGraphicsDevice corresponding to the given EGL display handle. */
- public EGLGraphicsDevice(long eglDisplay, String connection, int unitID) {
- super(NativeWindowFactory.TYPE_EGL, connection, unitID, eglDisplay);
- }
-
- public Object clone() {
- return super.clone();
- }
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/macosx/MacOSXGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/macosx/MacOSXGraphicsDevice.java
deleted file mode 100644
index 02c63758f..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/macosx/MacOSXGraphicsDevice.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-
-package javax.media.nativewindow.macosx;
-
-import javax.media.nativewindow.*;
-
-/** Encapsulates a graphics device on MacOSX platforms.
- */
-
-public class MacOSXGraphicsDevice extends DefaultGraphicsDevice implements Cloneable {
- /** Constructs a new MacOSXGraphicsDevice */
- public MacOSXGraphicsDevice(int unitID) {
- super(NativeWindowFactory.TYPE_MACOSX, AbstractGraphicsDevice.DEFAULT_CONNECTION, unitID);
- }
-
- public Object clone() {
- return super.clone();
- }
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/windows/WindowsGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/windows/WindowsGraphicsDevice.java
deleted file mode 100644
index 5d0129e0d..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/windows/WindowsGraphicsDevice.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-
-package javax.media.nativewindow.windows;
-
-import javax.media.nativewindow.*;
-
-/**
- * Encapsulates a graphics device on Windows platforms.<br>
- */
-public class WindowsGraphicsDevice extends DefaultGraphicsDevice implements Cloneable {
- /** Constructs a new WindowsGraphicsDevice */
- public WindowsGraphicsDevice(int unitID) {
- this(AbstractGraphicsDevice.DEFAULT_CONNECTION, unitID);
- }
-
- public WindowsGraphicsDevice(String connection, int unitID) {
- super(NativeWindowFactory.TYPE_WINDOWS, connection, unitID);
- }
-
- public Object clone() {
- return super.clone();
- }
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java
deleted file mode 100644
index 74439336d..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-
-package javax.media.nativewindow.x11;
-
-import javax.media.nativewindow.CapabilitiesImmutable;
-
-import jogamp.nativewindow.MutableGraphicsConfiguration;
-import jogamp.nativewindow.x11.XVisualInfo;
-
-/** Encapsulates a graphics configuration, or OpenGL pixel format, on
- X11 platforms. Objects of this type are returned from {@link
- javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration
- GraphicsConfigurationFactory.chooseGraphicsConfiguration()} on X11
- platforms when toolkits other than the AWT are being used. */
-
-public class X11GraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable {
- private XVisualInfo info;
-
- public X11GraphicsConfiguration(X11GraphicsScreen screen,
- CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
- XVisualInfo info) {
- super(screen, capsChosen, capsRequested);
- this.info = info;
- }
-
- @Override
- public Object clone() {
- return super.clone();
- }
-
- public XVisualInfo getXVisualInfo() {
- return info;
- }
-
- protected void setXVisualInfo(XVisualInfo info) {
- this.info = info;
- }
-
- public long getVisualID() {
- return (null!=info)?info.getVisualid():0;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName()+"["+getScreen()+", visualID 0x" + Long.toHexString(getVisualID()) +
- ",\n\tchosen " + capabilitiesChosen+
- ",\n\trequested " + capabilitiesRequested+
- "]";
- }
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java
deleted file mode 100644
index 73c8cfd52..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsDevice.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-
-package javax.media.nativewindow.x11;
-
-import jogamp.nativewindow.Debug;
-import jogamp.nativewindow.x11.X11Lib;
-import jogamp.nativewindow.x11.X11Util;
-import javax.media.nativewindow.DefaultGraphicsDevice;
-import javax.media.nativewindow.NativeWindowException;
-import javax.media.nativewindow.NativeWindowFactory;
-import javax.media.nativewindow.ToolkitLock;
-
-/** Encapsulates a graphics device on X11 platforms.
- */
-
-public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneable {
- public static final boolean DEBUG = Debug.debug("GraphicsDevice");
- final boolean closeDisplay;
-
- /** Constructs a new X11GraphicsDevice corresponding to the given connection and default
- * {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#getDefaultToolkitLock(String)}.<br>
- * Note that this is not an open connection, ie no native display handle exist.
- * This constructor exist to setup a default device connection.
- * @see DefaultGraphicsDevice#DefaultGraphicsDevice(String, String, int)
- */
- public X11GraphicsDevice(String connection, int unitID) {
- super(NativeWindowFactory.TYPE_X11, connection, unitID);
- closeDisplay = false;
- }
-
- /** Constructs a new X11GraphicsDevice corresponding to the given native display handle and default
- * {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#createDefaultToolkitLock(String, long)}.
- * @see DefaultGraphicsDevice#DefaultGraphicsDevice(String, String, int, long)
- */
- public X11GraphicsDevice(long display, int unitID, boolean owner) {
- // FIXME: derive unitID from connection could be buggy, one DISPLAY for all screens for example..
- super(NativeWindowFactory.TYPE_X11, X11Lib.XDisplayString(display), unitID, display);
- if(0==display) {
- throw new NativeWindowException("null display");
- }
- closeDisplay = owner;
- }
-
- /**
- * @param display the Display connection
- * @param locker custom {@link javax.media.nativewindow.ToolkitLock}, eg to force null locking in NEWT
- * @see DefaultGraphicsDevice#DefaultGraphicsDevice(String, String, int, long, ToolkitLock)
- */
- public X11GraphicsDevice(long display, int unitID, ToolkitLock locker, boolean owner) {
- super(NativeWindowFactory.TYPE_X11, X11Lib.XDisplayString(display), unitID, display, locker);
- if(0==display) {
- throw new NativeWindowException("null display");
- }
- closeDisplay = owner;
- }
-
- public Object clone() {
- return super.clone();
- }
-
- public boolean close() {
- // FIXME: shall we respect the unitID ?
- if(closeDisplay && 0 != handle) {
- if(DEBUG) {
- System.err.println(Thread.currentThread().getName() + " - X11GraphicsDevice.close(): "+this);
- }
- X11Util.closeDisplay(handle);
- }
- return super.close();
- }
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
deleted file mode 100644
index ed59861ca..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-
-package javax.media.nativewindow.x11;
-
-import javax.media.nativewindow.*;
-
-import jogamp.nativewindow.x11.X11Lib;
-import jogamp.nativewindow.x11.X11Util;
-
-/** Encapsulates a screen index on X11
- platforms. Objects of this type are passed to {@link
- javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration
- GraphicsConfigurationFactory.chooseGraphicsConfiguration()} on X11
- platforms when toolkits other than the AWT are being used. */
-
-public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneable {
-
- /** Constructs a new X11GraphicsScreen corresponding to the given native screen index. */
- public X11GraphicsScreen(X11GraphicsDevice device, int screen) {
- super(device, fetchScreen(device, screen));
- }
-
- public static AbstractGraphicsScreen createScreenDevice(long display, int screenIdx, boolean owner) {
- if(0==display) throw new NativeWindowException("display is null");
- return new X11GraphicsScreen(new X11GraphicsDevice(display, AbstractGraphicsDevice.DEFAULT_UNIT, owner), screenIdx);
- }
-
- public long getDefaultVisualID() {
- // It still could be an AWT hold handle ..
- long display = getDevice().getHandle();
- int scrnIdx = X11Lib.DefaultScreen(display);
- return X11Lib.DefaultVisualID(display, scrnIdx);
- }
-
- private static int fetchScreen(X11GraphicsDevice device, int screen) {
- // It still could be an AWT hold handle ..
- if(X11Util.XineramaIsEnabled(device.getHandle())) {
- screen = 0; // Xinerama -> 1 screen
- }
- return screen;
- }
-
- public Object clone() {
- return super.clone();
- }
-}