summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java18
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java19
-rw-r--r--src/newt/classes/com/jogamp/newt/NewtFactory.java13
3 files changed, 40 insertions, 10 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
index 7be747ff5..fca132f3f 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java
@@ -30,6 +30,8 @@ package com.jogamp.nativewindow.swt;
import com.jogamp.common.os.Platform;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import org.eclipse.swt.graphics.GCData;
import org.eclipse.swt.widgets.Control;
@@ -70,7 +72,7 @@ public class SWTAccessor {
static final String str_OS_gtk_class = "org.eclipse.swt.internal.gtk.OS";
static final Class<?> OS_gtk_class;
static final Method OS_gtk_widget_realize;
- static final Method OS_gtk_widget_unrealize;
+ static final Method OS_gtk_widget_unrealize; // optional (removed in SWT 4.3)
static final Method OS_GTK_WIDGET_WINDOW;
static final Method OS_gdk_x11_drawable_get_xdisplay;
static final Method OS_gdk_x11_drawable_get_xid;
@@ -83,6 +85,12 @@ public class SWTAccessor {
static {
Field f = null;
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ NativeWindowFactory.initSingleton(); // last resort ..
+ return null;
+ } } );
+
final String nwt = NativeWindowFactory.getNativeWindowType(false);
if(NativeWindowFactory.TYPE_MACOSX != nwt ) {
@@ -127,14 +135,18 @@ public class SWTAccessor {
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 == nwt ) {
+ // mandatory
try {
c = ReflectionUtil.getClass(str_OS_gtk_class, false, SWTAccessor.class.getClassLoader());
m1 = c.getDeclaredMethod(str_gtk_widget_realize, handleType);
- m2 = c.getDeclaredMethod(str_gtk_widget_unrealize, handleType);
m3 = c.getDeclaredMethod(str_GTK_WIDGET_WINDOW, handleType);
m4 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xdisplay, handleType);
m5 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xid, handleType);
} catch (Exception ex) { throw new NativeWindowException(ex); }
+ // optional
+ try {
+ m2 = c.getDeclaredMethod(str_gtk_widget_unrealize, handleType);
+ } catch (Exception ex) { }
}
OS_gtk_class = c;
OS_gtk_widget_realize = m1;
@@ -197,7 +209,7 @@ public class SWTAccessor {
public void run() {
if(realize) {
callStaticMethodL2V(OS_gtk_widget_realize, handle);
- } else {
+ } else if(null != OS_gtk_widget_unrealize) {
callStaticMethodL2V(OS_gtk_widget_unrealize, handle);
}
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
index 179610b25..d7f28a986 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
@@ -148,8 +148,18 @@ public abstract class NativeWindowFactory {
}
static {
- Platform.initSingleton();
- DEBUG = Debug.debug("NativeWindow");
+ final boolean[] _DEBUG = new boolean[] { false };
+ final String[] _tmp = new String[] { null };
+
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Platform.initSingleton(); // last resort ..
+ _DEBUG[0] = Debug.debug("NativeWindow");
+ _tmp[0] = Debug.getProperty("nativewindow.ws.name", true);
+ return null;
+ } } ) ;
+
+ DEBUG = _DEBUG[0];
if(DEBUG) {
System.err.println(Thread.currentThread().getName()+" - Info: NativeWindowFactory.<init>");
// Thread.dumpStack();
@@ -157,11 +167,10 @@ public abstract class NativeWindowFactory {
// Gather the windowing TK first
nativeWindowingTypePure = _getNativeWindowingType();
- final String tmp = Debug.getProperty("nativewindow.ws.name", true);
- if(null==tmp || tmp.length()==0) {
+ if(null==_tmp[0] || _tmp[0].length()==0) {
nativeWindowingTypeCustom = nativeWindowingTypePure;
} else {
- nativeWindowingTypeCustom = tmp.intern(); // canonical representation
+ nativeWindowingTypeCustom = _tmp[0].intern(); // canonical representation
}
}
diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java
index 1bf47f4aa..b3e904310 100644
--- a/src/newt/classes/com/jogamp/newt/NewtFactory.java
+++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java
@@ -34,6 +34,9 @@
package com.jogamp.newt;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.AbstractGraphicsScreen;
@@ -41,6 +44,8 @@ import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.NativeWindowFactory;
+import com.jogamp.common.os.Platform;
+
import jogamp.newt.Debug;
import jogamp.newt.DisplayImpl;
import jogamp.newt.ScreenImpl;
@@ -54,8 +59,12 @@ public class NewtFactory {
// Work-around for initialization order problems on Mac OS X
// between native Newt and (apparently) Fmod
static {
- NativeWindowFactory.initSingleton(); // last resort ..
- WindowImpl.init(NativeWindowFactory.getNativeWindowType(true));
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ NativeWindowFactory.initSingleton(); // last resort ..
+ WindowImpl.init(NativeWindowFactory.getNativeWindowType(true));
+ return null;
+ } } );
}
public static Class<?> getCustomClass(String packageName, String classBaseName) {