summaryrefslogtreecommitdiffstats
path: root/src/nativewindow
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-01-05 03:38:15 +0100
committerSven Gothel <[email protected]>2014-01-05 03:38:15 +0100
commit49e9ce7e641cb6923d9907ad66f667b3d3490e49 (patch)
treec69329073846a434cc1395b524fd3f3aa407b9b1 /src/nativewindow
parentd58713b37858c009bc45c28676e512c52a0b5555 (diff)
Bug 935: NEWT Windows Window-Icon: Use WNDCLASSEX w/ Small/Big Default Icons (NativeWindow GDI / NEWT )
.. this allows using the icon definition of WNDCLASSEX instead of setting them at CreateWindow0(..). - NativeWindow GDIUtil/RegisteredFactory uses WNDCLASSEX and Small/Big Defailt Icons
Diffstat (limited to 'src/nativewindow')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java8
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java7
-rw-r--r--src/nativewindow/native/win32/GDImisc.c13
3 files changed, 19 insertions, 9 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java
index a872e63d8..720ff9bdb 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java
@@ -59,7 +59,9 @@ public class GDIUtil implements ToolkitProperties {
if( !initIDs0() ) {
throw new NativeWindowException("GDI: Could not initialized native stub");
}
- dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0(), true /* useDummyDispatchThread */);
+ dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0(),
+ true /* useDummyDispatchThread */,
+ 0 /* iconSmallHandle */, 0 /* iconBigHandle */);
if(DEBUG) {
System.out.println("GDI.initSingleton() dummyWindowClassFactory "+dummyWindowClassFactory);
}
@@ -128,7 +130,9 @@ public class GDIUtil implements ToolkitProperties {
private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI
- static native boolean CreateWindowClass0(long hInstance, String clazzName, long wndProc);
+ /** Creates WNDCLASSEX instance */
+ static native boolean CreateWindowClass0(long hInstance, String clazzName, long wndProc, long iconSmallHandle, long iconBigHandle);
+ /** Destroys WNDCLASSEX instance */
static native boolean DestroyWindowClass0(long hInstance, String className, long dispThreadCtx);
static native long CreateDummyDispatchThread0();
diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java
index ee41fe192..c4b4d145c 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java
@@ -50,6 +50,7 @@ public class RegisteredClassFactory {
private final String classBaseName;
private final long wndProc;
private final boolean useDummyDispatchThread;
+ private final long iconSmallHandle, iconBigHandle;
private RegisteredClass sharedClass = null;
private int classIter = 0;
@@ -92,10 +93,12 @@ public class RegisteredClassFactory {
/** Application handle. */
public static long getHInstance() { return hInstance; }
- public RegisteredClassFactory(String classBaseName, long wndProc, boolean useDummyDispatchThread) {
+ public RegisteredClassFactory(String classBaseName, long wndProc, boolean useDummyDispatchThread, long iconSmallHandle, long iconBigHandle) {
this.classBaseName = classBaseName;
this.wndProc = wndProc;
this.useDummyDispatchThread = useDummyDispatchThread;
+ this.iconSmallHandle = iconSmallHandle;
+ this.iconBigHandle = iconBigHandle;
synchronized(registeredFactories) {
registeredFactories.add(this);
}
@@ -114,7 +117,7 @@ public class RegisteredClassFactory {
// Retry with next clazz name, this could happen if more than one JVM is running
clazzName = classBaseName + classIter;
classIter++;
- registered = GDIUtil.CreateWindowClass0(hInstance, clazzName, wndProc);
+ registered = GDIUtil.CreateWindowClass0(hInstance, clazzName, wndProc, iconSmallHandle, iconBigHandle);
}
if( !registered ) {
throw new NativeWindowException("Error: Could not create WindowClass: "+clazzName);
diff --git a/src/nativewindow/native/win32/GDImisc.c b/src/nativewindow/native/win32/GDImisc.c
index 25b98acf3..e28f68e7d 100644
--- a/src/nativewindow/native/win32/GDImisc.c
+++ b/src/nativewindow/native/win32/GDImisc.c
@@ -237,11 +237,12 @@ Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyDispatchThread0
*/
JNIEXPORT jboolean JNICALL
Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass0
- (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jClazzName, jlong wndProc)
+ (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jClazzName, jlong wndProc,
+ jlong iconSmallHandle, jlong iconBigHandle)
{
HINSTANCE hInstance = (HINSTANCE) (intptr_t) jHInstance;
const TCHAR* clazzName = NULL;
- WNDCLASS wc;
+ WNDCLASSEX wc;
jboolean res;
#ifdef UNICODE
@@ -251,23 +252,25 @@ Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass0
#endif
ZeroMemory( &wc, sizeof( wc ) );
- if( GetClassInfo( hInstance, clazzName, &wc ) ) {
+ if( GetClassInfoEx( hInstance, clazzName, &wc ) ) {
// registered already
res = JNI_TRUE;
} else {
// register now
ZeroMemory( &wc, sizeof( wc ) );
+ wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW ;
wc.lpfnWndProc = (WNDPROC) (intptr_t) wndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
- wc.hIcon = NULL;
+ wc.hIcon = (HICON) (intptr_t) iconBigHandle;
wc.hCursor = NULL;
wc.hbrBackground = NULL; // no background paint - GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = clazzName;
- res = ( 0 != RegisterClass( &wc ) ) ? JNI_TRUE : JNI_FALSE ;
+ wc.hIconSm = (HICON) (intptr_t) iconSmallHandle;
+ res = ( 0 != RegisterClassEx( &wc ) ) ? JNI_TRUE : JNI_FALSE ;
}
#ifdef UNICODE