aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/javax/media
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-03-06 07:27:29 +0100
committerSven Gothel <[email protected]>2012-03-06 07:27:29 +0100
commit28ca3652c7c3c73cc3c41ad84b3f1efdad98add5 (patch)
tree20c687ec4b4ef1be7ff3548c96e1913889e3be8b /src/nativewindow/classes/javax/media
parent9124f3fade3f923b581c6e7b871d049b431bbd78 (diff)
NativeWindow public-spec to public-impl reorg (javax.media.nativewindow.<impl> -> com.jogamp.nativewindow.<impl>) 1/2
Diffstat (limited to 'src/nativewindow/classes/javax/media')
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java84
-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
11 files changed, 84 insertions, 907 deletions
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..20d3ad6dc
--- /dev/null
+++ b/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java
@@ -0,0 +1,84 @@
+/**
+ * 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 jogamp.nativewindow;
+
+/**
+ * Specifies query to the native capabilities identification.
+ * Semantics may differ depending on the native windowing system,
+ * see {@link #getVisualID(int)}.
+ */
+public interface NativeVisualID {
+
+ public enum NVIDType {
+ GEN_ID(0), NATIVE_ID(1),
+ EGL_ConfigID(2), EGL_NativeVisualID(3), X11_XVisualID(4), X11_FBConfigID(5), WIN32_PFDID(6);
+
+ public final int id;
+
+ NVIDType(int id){
+ this.id = id;
+ }
+ }
+
+ /**
+ * Returns the native identification of the given <code>type</code>.
+ * <p>
+ * Depending on the native windowing system, this might be
+ * <ul>
+ * <li>X11
+ * <ul>
+ * <li>GEN_ID: X11_XVisualID</li>
+ * <li>NATIVE_ID: X11_XVisualID</li>
+ * <li>X11_XVisualID</li>
+ * </ul></li>
+ * <li>X11/GL
+ * <ul>
+ * <li>GEN_ID: X11_XVisualID</li>
+ * <li>NATIVE_ID: X11_XVisualID</li>
+ * <li>X11_XVisualID</li>
+ * <li>X11FBConfigID</li>
+ * </ul></li>
+ * <li>Windows/GL
+ * <ul>
+ * <li>GEN_ID: WIN32_PFDID</li>
+ * <li>NATIVE_ID: WIN32_PFDID</li>
+ * <li>WIN32_PFDID</li>
+ * </ul></li>
+ * <li>EGL/GL
+ * <ul>
+ * <li>GEN_ID: EGL_ConfigID</li>
+ * <li>NATIVE_ID: EGL_NativeVisualID (X11_XVisualID, WIN32_PFDID, ..)</li>
+ * <li>EGL_ConfigID</li>
+ * <li>EGL_NativeVisualID</li>
+ * </ul></li>
+ * </ul>
+ * </p>
+ */
+ int getVisualID(NVIDType type);
+}
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();
- }
-}