diff options
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java | 52 | ||||
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java | 59 |
2 files changed, 44 insertions, 67 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java index 2e9ab5485..f9eee67f3 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java @@ -28,41 +28,12 @@ package jogamp.nativewindow.x11; -import jogamp.nativewindow.NativeVisualID; -import java.util.Comparator; - import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; -public class X11Capabilities extends Capabilities implements NativeVisualID { - final XVisualInfo xVisualInfo; // maybe null if !onscreen - - /** Comparing xvisual id only */ - public static class XVisualIDComparator implements Comparator { - public int compare(Object o1, Object o2) { - if ( ! ( o1 instanceof NativeVisualID ) ) { - Class<?> c = (null != o1) ? o1.getClass() : null ; - throw new ClassCastException("arg1 not a NativeVisualID object: " + c); - } - if ( ! ( o2 instanceof NativeVisualID ) ) { - Class<?> c = (null != o2) ? o2.getClass() : null ; - throw new ClassCastException("arg2 not a NativeVisualID object: " + c); - } - - final NativeVisualID nvid1 = (NativeVisualID) o1; - final int id1 = nvid1.getVisualID(NativeVisualID.NVIDType.X11_XVisualID); - - final NativeVisualID nvid2 = (NativeVisualID) o2; - final int id2 = nvid2.getVisualID(NativeVisualID.NVIDType.X11_XVisualID); - - if(id1 > id2) { - return 1; - } else if(id1 < id2) { - return -1; - } - return 0; - } - } +public class X11Capabilities extends Capabilities { + final private XVisualInfo xVisualInfo; // maybe null if !onscreen public X11Capabilities(XVisualInfo xVisualInfo) { super(); @@ -82,20 +53,21 @@ public class X11Capabilities extends Capabilities implements NativeVisualID { } final public XVisualInfo getXVisualInfo() { return xVisualInfo; } - final public int getXVisualID() { return (null!=xVisualInfo) ? (int) xVisualInfo.getVisualid() : 0; } + final public int getXVisualID() { return (null!=xVisualInfo) ? (int) xVisualInfo.getVisualid() : VisualIDHolder.VID_UNDEFINED; } final public boolean hasXVisualInfo() { return null!=xVisualInfo; } - final public int getVisualID(NVIDType type) { + @Override + final public int getVisualID(VIDType type) throws NativeWindowException { switch(type) { - case GEN_ID: - case NATIVE_ID: + case INTRINSIC: + case NATIVE: // fall through intended - case X11_XVisualID: + case X11_XVISUAL: return getXVisualID(); - case X11_FBConfigID: - // fall through intended + case X11_FBCONFIG: + return VisualIDHolder.VID_UNDEFINED; default: - throw new IllegalArgumentException("Invalid type <"+type+">"); + throw new NativeWindowException("Invalid type <"+type+">"); } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java index 5dc143559..697be9f93 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java @@ -42,17 +42,18 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ToolkitLock; -import javax.media.nativewindow.awt.AWTGraphicsConfiguration; -import javax.media.nativewindow.awt.AWTGraphicsDevice; -import javax.media.nativewindow.awt.AWTGraphicsScreen; -import javax.media.nativewindow.x11.X11GraphicsDevice; -import javax.media.nativewindow.x11.X11GraphicsScreen; +import javax.media.nativewindow.VisualIDHolder.VIDType; + +import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import com.jogamp.nativewindow.x11.X11GraphicsScreen; -import jogamp.nativewindow.NativeVisualID; -import jogamp.nativewindow.NativeVisualID.NVIDType; import jogamp.nativewindow.jawt.x11.X11SunJDKReflection; import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.X11Util; @@ -60,7 +61,7 @@ import jogamp.nativewindow.x11.X11Util; public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFactory { public static void registerFactory() { - GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, new X11AWTGraphicsConfigurationFactory()); + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.awt.AWTGraphicsDevice.class, new X11AWTGraphicsConfigurationFactory()); } private X11AWTGraphicsConfigurationFactory() { } @@ -138,17 +139,19 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac // ie. returned by GLCanvas's getGraphicsConfiguration() befor call by super.addNotify(). // final GraphicsConfiguration[] configs = device.getConfigurations(); - int visualID = ((NativeVisualID) aConfig.getChosenCapabilities()).getVisualID(NVIDType.NATIVE_ID); - for (int i = 0; i < configs.length; i++) { - GraphicsConfiguration gc = configs[i]; - if (gc != null) { - if (X11SunJDKReflection.graphicsConfigurationGetVisualID(gc) == visualID) { - if(DEBUG) { - System.err.println("Found matching AWT visual: 0x"+Integer.toHexString(visualID) +" -> "+aConfig); + int visualID = aConfig.getVisualID(VIDType.NATIVE); + if(VisualIDHolder.VID_UNDEFINED != visualID) { + for (int i = 0; i < configs.length; i++) { + GraphicsConfiguration gc = configs[i]; + if (gc != null) { + if (X11SunJDKReflection.graphicsConfigurationGetVisualID(gc) == visualID) { + if(DEBUG) { + System.err.println("Found matching AWT visual: 0x"+Integer.toHexString(visualID) +" -> "+aConfig); + } + return new AWTGraphicsConfiguration(awtScreen, + aConfig.getChosenCapabilities(), aConfig.getRequestedCapabilities(), + gc, aConfig); } - return new AWTGraphicsConfiguration(awtScreen, - aConfig.getChosenCapabilities(), aConfig.getRequestedCapabilities(), - gc, aConfig); } } } @@ -160,16 +163,18 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac if (aConfig == null) { throw new NativeWindowException("Unable to choose a GraphicsConfiguration (2): "+capsChosen+",\n\t"+chooser+"\n\t"+x11Screen); } - visualID = ((NativeVisualID) aConfig.getChosenCapabilities()).getVisualID(NVIDType.NATIVE_ID); - for (int i = 0; i < configs.length; i++) { - gc = configs[i]; - if (X11SunJDKReflection.graphicsConfigurationGetVisualID(gc) == visualID) { - if(DEBUG) { - System.err.println("Found matching default AWT visual: 0x"+Integer.toHexString(visualID) +" -> "+aConfig); + visualID = aConfig.getVisualID(VIDType.NATIVE); + if(VisualIDHolder.VID_UNDEFINED != visualID) { + for (int i = 0; i < configs.length; i++) { + gc = configs[i]; + if (X11SunJDKReflection.graphicsConfigurationGetVisualID(gc) == visualID) { + if(DEBUG) { + System.err.println("Found matching default AWT visual: 0x"+Integer.toHexString(visualID) +" -> "+aConfig); + } + return new AWTGraphicsConfiguration(awtScreen, + aConfig.getChosenCapabilities(), aConfig.getRequestedCapabilities(), + gc, aConfig); } - return new AWTGraphicsConfiguration(awtScreen, - aConfig.getChosenCapabilities(), aConfig.getRequestedCapabilities(), - gc, aConfig); } } |