From 3ab518e90eb4cf82bcb8b990d337a5e4a531136b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 18 Aug 2012 11:46:01 +0200 Subject: GLProfile/NativeWindowFactory: Remove deprecated argument 'firstUIActionOnProcess' of initSingleton() method The notion of changing the threading behavior of native initialization was deprecated for over a year. The code still contained the bits and pieces, i.e. whether X11Util.initSingletion() is invoked before or after optional AWT initialization. This condition has been removed now and behavior is uniform, i.e. X11Util.initSingletion() is invoked after optional AWT initialization. - Removed GLProfile.initSingleton(boolean firstUIActionOnProcess), use remaining GLProfile.initSingleton() - Removed NativeWindowFactory.isFirstUIActionOnProcess() - Changed NativeWindowFactory.initSingleton(boolean firstUIActionOnProcess) to NativeWindowFactory.initSingleton() --- .../media/nativewindow/NativeWindowFactory.java | 46 ++++++---------------- 1 file changed, 11 insertions(+), 35 deletions(-) (limited to 'src/nativewindow/classes/javax/media') diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 6faa9890c..94f5d753c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -99,7 +99,6 @@ public abstract class NativeWindowFactory { private static Constructor x11JAWTToolkitLockConstructor; private static Class x11ToolkitLockClass; private static Constructor x11ToolkitLockConstructor; - private static boolean isFirstUIActionOnProcess; private static boolean requiresToolkitLock; /** Creates a new NativeWindowFactory instance. End users do not @@ -138,9 +137,7 @@ public abstract class NativeWindowFactory { static boolean initialized = false; - private static void initSingletonNativeImpl(final boolean firstUIActionOnProcess, final ClassLoader cl) { - isFirstUIActionOnProcess = firstUIActionOnProcess; - + private static void initSingletonNativeImpl(final ClassLoader cl) { final String clazzName; if( TYPE_X11.equals(nativeWindowingTypePure) ) { clazzName = X11UtilClassName; @@ -152,9 +149,7 @@ public abstract class NativeWindowFactory { clazzName = null; } if( null != clazzName ) { - ReflectionUtil.callStaticMethod(clazzName, "initSingleton", - new Class[] { boolean.class }, - new Object[] { new Boolean(firstUIActionOnProcess) }, cl ); + ReflectionUtil.callStaticMethod(clazzName, "initSingleton", null, null, cl ); final Boolean res = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "requiresToolkitLock", null, null, cl); requiresToolkitLock = res.booleanValue(); @@ -166,24 +161,13 @@ public abstract class NativeWindowFactory { /** * Static one time initialization of this factory.
* This initialization method must be called once by the program or utilizing modules! - *

- * The parameter firstUIActionOnProcess has an impact on concurrent locking: - *

- *

- * @param firstUIActionOnProcess Should be true if called before the first UI action of the running program, - * otherwise false. */ - public static synchronized void initSingleton(final boolean firstUIActionOnProcess) { + public static synchronized void initSingleton() { if(!initialized) { initialized = true; if(DEBUG) { - System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.initSingleton("+firstUIActionOnProcess+")"); + System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.initSingleton()"); } final ClassLoader cl = NativeWindowFactory.class.getClassLoader(); @@ -197,10 +181,6 @@ public abstract class NativeWindowFactory { nativeWindowingTypeCustom = tmp; } - if(firstUIActionOnProcess) { - // X11 initialization before possible AWT initialization - initSingletonNativeImpl(true, cl); - } isAWTAvailable = false; // may be set to true below if( Platform.AWT_AVAILABLE && @@ -248,10 +228,13 @@ public abstract class NativeWindowFactory { } } } - if(!firstUIActionOnProcess) { - // X11 initialization after possible AWT initialization - initSingletonNativeImpl(false, cl); - } + + // X11 initialization after possible AWT initialization + // This is performed post AWT initialization, allowing AWT to complete the same, + // which may have been triggered before NativeWindow initialization. + // This way behavior is more uniforms across configurations (Applet/RCP, applications, ..). + initSingletonNativeImpl(cl); + registeredFactories = Collections.synchronizedMap(new HashMap, NativeWindowFactory>()); // register our default factory -> NativeWindow @@ -276,7 +259,6 @@ public abstract class NativeWindowFactory { } if(DEBUG) { - System.err.println("NativeWindowFactory firstUIActionOnProcess "+firstUIActionOnProcess); System.err.println("NativeWindowFactory requiresToolkitLock "+requiresToolkitLock); System.err.println("NativeWindowFactory isAWTAvailable "+isAWTAvailable+", defaultFactory "+factory); } @@ -301,12 +283,6 @@ public abstract class NativeWindowFactory { } } - /** @return true if initialized with {@link #initSingleton(boolean) initSingleton(firstUIActionOnProcess==true)}, - otherwise false. */ - public static boolean isFirstUIActionOnProcess() { - return isFirstUIActionOnProcess; - } - /** @return true if the underlying toolkit requires locking, otherwise false. */ public static boolean requiresToolkitLock() { return requiresToolkitLock; -- cgit v1.2.3