diff options
author | Sven Gothel <[email protected]> | 2010-12-12 07:51:06 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-12-12 07:51:06 +0100 |
commit | 48f6568ebffdd557651460fb5f3f7f4abbca2440 (patch) | |
tree | 2cbd9cc815ab54fcd61fccae17e7d75ca6cc6d51 /make/config | |
parent | f3512c700b2b3161eb773e77d0d41567acb710be (diff) |
Windows RegisterClass: Use new RegisteredClassFactory (window class), Misc.
This solves the issue when an applet is started/stop and started again,
or another applet runs in the same JVM.
Also soves the issue for multiple JVMs.
RegisteredClassFactory can be instanced to manage one shared window class,
currently in use for GDI's dummy window and NEWT.
A class base name and a window proc handle must be passed in the factory cstr.
Before registering, the class is tested if already exists,
eg another applet in the same JVM.
If registration fails, the class name will iterate until successful or MAX_INT reached,
eg if multiple JVMs are running.
Added NativeWindow Common Native Code.
Diffstat (limited to 'make/config')
-rw-r--r-- | make/config/nativewindow/win32-CustomJavaCode.java | 56 | ||||
-rw-r--r-- | make/config/nativewindow/win32-lib.cfg | 5 |
2 files changed, 48 insertions, 13 deletions
diff --git a/make/config/nativewindow/win32-CustomJavaCode.java b/make/config/nativewindow/win32-CustomJavaCode.java index 0c1a3a402..5d0c82998 100644 --- a/make/config/nativewindow/win32-CustomJavaCode.java +++ b/make/config/nativewindow/win32-CustomJavaCode.java @@ -1,22 +1,50 @@ - static { - NWJNILibLoader.loadNativeWindow("win32"); - - if( !initIDs0() ) { - throw new NativeWindowException("GDI: Could not initialized native stub"); - } - } + private static final boolean DEBUG = Debug.debug("GDI"); + + private static final String dummyWindowClassNameBase = "_dummyWindow_clazz" ; + private static RegisteredClassFactory dummyWindowClassFactory; + private static boolean isInit = false; - public static synchronized void initSingleton() { - } private static native boolean initIDs0(); + private static native long getDummyWndProc0(); - private static Object createDummyWindowSync = new Object(); + public static synchronized void initSingleton(boolean firstX11ActionOnProcess) { + if(!isInit) { + NWJNILibLoader.loadNativeWindow("win32"); + + if( !initIDs0() ) { + throw new NativeWindowException("GDI: Could not initialized native stub"); + } + + if(DEBUG) { + System.out.println("GDI.isFirstX11ActionOnProcess: "+firstX11ActionOnProcess); + } + + dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0()); + isInit = true; + } + } + + private static RegisteredClass dummyWindowClass = null; + private static Object dummyWindowSync = new Object(); public static long CreateDummyWindow(int x, int y, int width, int height) { - synchronized(createDummyWindowSync) { - return CreateDummyWindow0(x, y, width, height); + synchronized(dummyWindowSync) { + dummyWindowClass = dummyWindowClassFactory.getSharedClass(); + return CreateDummyWindow0(dummyWindowClass.getHandle(), dummyWindowClass.getName(), dummyWindowClass.getName(), x, y, width, height); + } + } + + public static boolean DestroyDummyWindow(long hwnd) { + boolean res; + synchronized(dummyWindowSync) { + if( null == dummyWindowClass ) { + throw new InternalError("GDI Error ("+dummyWindowClassFactory.getSharedRefCount()+"): SharedClass is null"); + } + res = DestroyWindow(hwnd); + dummyWindowClassFactory.releaseSharedClass(); } + return res; } public static Point GetRelativeLocation(long src_win, long dest_win, int src_x, int src_y) { @@ -24,3 +52,7 @@ } private static native Object GetRelativeLocation0(long src_win, long dest_win, int src_x, int src_y); + public static native boolean CreateWindowClass(long hInstance, String clazzName, long wndProc); + public static native boolean DestroyWindowClass(long hInstance, String className); + static native long CreateDummyWindow0(long hInstance, String className, String windowName, int x, int y, int width, int height); + diff --git a/make/config/nativewindow/win32-lib.cfg b/make/config/nativewindow/win32-lib.cfg index e140ed3aa..0ba7d63bc 100644 --- a/make/config/nativewindow/win32-lib.cfg +++ b/make/config/nativewindow/win32-lib.cfg @@ -22,7 +22,10 @@ Opaque long void ** Import javax.media.nativewindow.util.Point Import javax.media.nativewindow.NativeWindowException +Import javax.media.nativewindow.windows.RegisteredClass +Import javax.media.nativewindow.windows.RegisteredClassFactory Import com.jogamp.nativewindow.impl.NWJNILibLoader +import com.jogamp.nativewindow.impl.Debug CustomCCode #define WIN32_LEAN_AND_MEAN CustomCCode #include <windows.h> @@ -33,7 +36,7 @@ CustomCCode #include <stddef.h> Include ../intptr.cfg -CustomCCode extern HWND CreateDummyWindow0( int x, int y, int width, int height ) ; +CustomCCode extern HINSTANCE GetApplicationHandle(); IncludeAs CustomJavaCode GDI win32-CustomJavaCode.java |