diff options
author | Sven Gothel <[email protected]> | 2012-08-18 14:52:32 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-08-18 14:52:32 +0200 |
commit | c5835a2e19a84cb08957d6c742e4334d578c3c66 (patch) | |
tree | 2d7b50355cbbf3a4e19ab5922f8d478316e75110 /src/nativewindow/classes/com/jogamp | |
parent | a694cadca4ab72481e777222f412f006f973f77e (diff) |
NativeWindowFactory.getNativeWindowType(..): Return canonical string representation allowing proper use of ref. comparison '==', instead of 'String.equals()'
Also make NativeWindowFactory's instances of nativeWindowingTypePure and nativeWindowingTypeCustom static final.
Diffstat (limited to 'src/nativewindow/classes/com/jogamp')
-rw-r--r-- | src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index ba07d97dc..1cc796086 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -83,7 +83,9 @@ public class SWTAccessor { static { Field f = null; - if(NativeWindowFactory.TYPE_MACOSX != NativeWindowFactory.getNativeWindowType(false) ) { + final String nwt = NativeWindowFactory.getNativeWindowType(false); + + if(NativeWindowFactory.TYPE_MACOSX != nwt ) { try { f = Control.class.getField(str_handle); } catch (Exception ex) { @@ -124,7 +126,7 @@ public class SWTAccessor { Class<?> c=null; Method m1=null, m2=null, m3=null, m4=null, m5=null; Class<?> handleType = swt_uses_long_handles ? long.class : int.class ; - if( NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false) ) { + if( NativeWindowFactory.TYPE_X11 == nwt ) { try { c = ReflectionUtil.getClass(str_OS_gtk_class, false, SWTAccessor.class.getClassLoader()); m1 = c.getDeclaredMethod(str_gtk_widget_realize, handleType); @@ -210,33 +212,36 @@ public class SWTAccessor { long displayHandle = callStaticMethodL2L(OS_gdk_x11_drawable_get_xdisplay, widgedHandle); return new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, false); } - if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) ) { + final String nwt = NativeWindowFactory.getNativeWindowType(false); + if( NativeWindowFactory.TYPE_WINDOWS == nwt ) { return new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } - if( NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) { + if( NativeWindowFactory.TYPE_MACOSX == nwt ) { return new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); } - throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false)); + throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); } public static AbstractGraphicsScreen getScreen(AbstractGraphicsDevice device, int screen) { if( null != OS_gtk_class ) { return new X11GraphicsScreen((X11GraphicsDevice)device, screen); - } - if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) || - NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) { + } + final String nwt = NativeWindowFactory.getNativeWindowType(false); + if( NativeWindowFactory.TYPE_WINDOWS == nwt || + NativeWindowFactory.TYPE_MACOSX == nwt ) { return new DefaultGraphicsScreen(device, screen); } - throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false)); + throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); } public static int getNativeVisualID(AbstractGraphicsDevice device, long windowHandle) { if( null != OS_gtk_class ) { return X11Lib.GetVisualIDFromWindow(device.getHandle(), windowHandle); } - if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) || - NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) { + final String nwt = NativeWindowFactory.getNativeWindowType(false); + if( NativeWindowFactory.TYPE_WINDOWS == nwt || + NativeWindowFactory.TYPE_MACOSX == nwt ) { return VisualIDHolder.VID_UNDEFINED; } - throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false)); + throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); } public static long getWindowHandle(Control swtControl) { @@ -245,11 +250,12 @@ public class SWTAccessor { long widgedHandle = callStaticMethodL2L(OS_GTK_WIDGET_WINDOW, handle); return callStaticMethodL2L(OS_gdk_x11_drawable_get_xid, widgedHandle); } - if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) || - NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) { + final String nwt = NativeWindowFactory.getNativeWindowType(false); + if( NativeWindowFactory.TYPE_WINDOWS == nwt || + NativeWindowFactory.TYPE_MACOSX == nwt ) { return handle; } - throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false)); + throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); } public static long newGC(final Control swtControl, final GCData gcData) { |