diff options
Diffstat (limited to 'src/nativewindow')
-rw-r--r-- | src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java | 47 | ||||
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java | 11 |
2 files changed, 27 insertions, 31 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 64781e418..3b71555b4 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -38,6 +38,8 @@ import java.util.*; import com.jogamp.common.util.*; import com.jogamp.common.jvm.JVMUtil; +import com.jogamp.common.os.Platform; + import jogamp.nativewindow.*; import java.lang.reflect.Constructor; import java.lang.reflect.Method; @@ -73,9 +75,7 @@ public abstract class NativeWindowFactory { private static Map/*<Class, NativeWindowFactory>*/ registeredFactories; private static Class nativeWindowClass; private static String nativeWindowingTypePure; - private static String nativeOSNamePure; private static String nativeWindowingTypeCustom; - private static String nativeOSNameCustom; private static boolean isAWTAvailable; public static final String AWTComponentClassName = "java.awt.Component" ; public static final String JAWTUtilClassName = "jogamp.nativewindow.jawt.JAWTUtil" ; @@ -98,17 +98,22 @@ public abstract class NativeWindowFactory { protected NativeWindowFactory() { } - private static String _getNativeWindowingType(String osNameLowerCase) { - if (osNameLowerCase.startsWith("kd")) { - return TYPE_EGL; - } else if (osNameLowerCase.startsWith("wind")) { - return TYPE_WINDOWS; - } else if (osNameLowerCase.startsWith("mac os x") || - osNameLowerCase.startsWith("darwin")) { + private static String _getNativeWindowingType() { + switch(Platform.OS_TYPE) { + case ANDROID: + throw new RuntimeException(Platform.OS_TYPE+" n/a yet"); + case MACOS: return TYPE_MACOSX; - } else if (osNameLowerCase.equals("awt")) { - return TYPE_AWT; - } else { + case WINDOWS: + return TYPE_WINDOWS; + case OPENKODE: + return TYPE_EGL; + + case LINUX: + case FREEBSD: + case SUNOS: + case HPUX: + default: return TYPE_X11; } } @@ -170,14 +175,12 @@ public abstract class NativeWindowFactory { // Gather the windowing OS first AccessControlContext acc = AccessController.getContext(); - nativeOSNamePure = Debug.getProperty("os.name", false, acc); - nativeWindowingTypePure = _getNativeWindowingType(nativeOSNamePure.toLowerCase()); - nativeOSNameCustom = Debug.getProperty("nativewindow.ws.name", true, acc); - if(null==nativeOSNameCustom||nativeOSNameCustom.length()==0) { - nativeOSNameCustom = nativeOSNamePure; + nativeWindowingTypePure = _getNativeWindowingType(); + String tmp = Debug.getProperty("nativewindow.ws.name", true, acc); + if(null==tmp || tmp.length()==0) { nativeWindowingTypeCustom = nativeWindowingTypePure; } else { - nativeWindowingTypeCustom = nativeOSNameCustom; + nativeWindowingTypeCustom = tmp; } final ClassLoader cl = NativeWindowFactory.class.getClassLoader(); @@ -268,14 +271,6 @@ public abstract class NativeWindowFactory { /** * @param useCustom if false return the native value, if true return a custom value if set, otherwise fallback to the native value. - * @return the native OS name - */ - public static String getNativeOSName(boolean useCustom) { - return useCustom?nativeOSNameCustom:nativeOSNamePure; - } - - /** - * @param useCustom if false return the native value, if true return a custom value if set, otherwise fallback to the native value. * @return a define native window type, like {@link #TYPE_X11}, .. */ public static String getNativeWindowType(boolean useCustom) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java index 3db8f32d2..e3322ac45 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java @@ -32,6 +32,7 @@ package jogamp.nativewindow; +import com.jogamp.common.os.Platform; import com.jogamp.common.util.*; import java.lang.reflect.*; @@ -73,21 +74,21 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory { private NativeWindow getAWTNativeWindow(Object winObj, AbstractGraphicsConfiguration config) { if (nativeWindowConstructor == null) { try { - String osType = getNativeWindowType(true); + String windowingType = getNativeWindowType(true); String windowClassName = null; // We break compile-time dependencies on the AWT here to // make it easier to run this code on mobile devices - if (osType.equals(TYPE_WINDOWS)) { + if (windowingType.equals(TYPE_WINDOWS)) { windowClassName = "jogamp.nativewindow.jawt.windows.WindowsJAWTWindow"; - } else if (osType.equals(TYPE_MACOSX)) { + } else if (windowingType.equals(TYPE_MACOSX)) { windowClassName = "jogamp.nativewindow.jawt.macosx.MacOSXJAWTWindow"; - } else if (osType.equals(TYPE_X11)) { + } else if (windowingType.equals(TYPE_X11)) { // Assume Linux, Solaris, etc. Should probably test for these explicitly. windowClassName = "jogamp.nativewindow.jawt.x11.X11JAWTWindow"; } else { - throw new IllegalArgumentException("OS " + getNativeOSName(false) + " not yet supported"); + throw new IllegalArgumentException("OS " + Platform.getOS() + " not yet supported"); } nativeWindowConstructor = ReflectionUtil.getConstructor( |