diff options
author | Sven Gothel <[email protected]> | 2014-01-05 03:38:15 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-01-05 03:38:15 +0100 |
commit | 49e9ce7e641cb6923d9907ad66f667b3d3490e49 (patch) | |
tree | c69329073846a434cc1395b524fd3f3aa407b9b1 /src/newt | |
parent | d58713b37858c009bc45c28676e512c52a0b5555 (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/newt')
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java | 26 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java | 30 | ||||
-rw-r--r-- | src/newt/native/WindowsWindow.c | 9 |
3 files changed, 27 insertions, 38 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index 1e9c78a5d..a4db50165 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -54,16 +54,38 @@ import javax.media.nativewindow.util.Point; import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.IOUtil; import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; +import com.jogamp.newt.NewtFactory; public class DisplayDriver extends DisplayImpl { private static final String newtClassBaseName = "_newt_clazz" ; + private static final long[] defaultIconHandles; private static RegisteredClassFactory sharedClassFactory; static { NEWTJNILibLoader.loadNEWT(); - - sharedClassFactory = new RegisteredClassFactory(newtClassBaseName, WindowDriver.getNewtWndProc0(), false /* useDummyDispatchThread */); + { + long[] _defaultIconHandle = { 0, 0 }; + if( PNGIcon.isAvailable() ) { + try { + final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; + final IOUtil.ClassResources iconRes = NewtFactory.getWindowIcons(); + { + final ByteBuffer icon_data_small = PNGIcon.singleToRGBAImage(iconRes, 0, true /* toBGRA */, width, height, data_size); + _defaultIconHandle[0] = DisplayDriver.createBGRA8888Icon0(icon_data_small, width[0], height[0], false, 0, 0); + } + { + final ByteBuffer icon_data_big = PNGIcon.singleToRGBAImage(iconRes, iconRes.resourceCount()-1, true /* toBGRA */, width, height, data_size); + _defaultIconHandle[1] = DisplayDriver.createBGRA8888Icon0(icon_data_big, width[0], height[0], false, 0, 0); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + defaultIconHandles = _defaultIconHandle; + } + sharedClassFactory = new RegisteredClassFactory(newtClassBaseName, WindowDriver.getNewtWndProc0(), + false /* useDummyDispatchThread */, defaultIconHandles[0], defaultIconHandles[1]); if (!WindowDriver.initIDs0(RegisteredClassFactory.getHInstance())) { throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs"); diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index c8d7c65cc..a48fe2f62 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -40,7 +40,6 @@ import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.GDIUtil; import jogamp.newt.PointerIconImpl; import jogamp.newt.WindowImpl; -import jogamp.newt.driver.PNGIcon; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.GraphicsConfigurationFactory; @@ -51,39 +50,16 @@ import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; import com.jogamp.common.os.Platform; -import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.VersionNumber; -import com.jogamp.newt.NewtFactory; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseEvent.PointerType; public class WindowDriver extends WindowImpl { - private static final long[] defaultIconHandles; static { DisplayDriver.initSingleton(); - { - long[] _defaultIconHandle = { 0, 0 }; - if( PNGIcon.isAvailable() ) { - try { - final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; - final IOUtil.ClassResources iconRes = NewtFactory.getWindowIcons(); - { - final ByteBuffer icon_data_small = PNGIcon.singleToRGBAImage(iconRes, 0, true /* toBGRA */, width, height, data_size); - _defaultIconHandle[0] = DisplayDriver.createBGRA8888Icon0(icon_data_small, width[0], height[0], false, 0, 0); - } - { - final ByteBuffer icon_data_big = PNGIcon.singleToRGBAImage(iconRes, iconRes.resourceCount()-1, true /* toBGRA */, width, height, data_size); - _defaultIconHandle[1] = DisplayDriver.createBGRA8888Icon0(icon_data_big, width[0], height[0], false, 0, 0); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - defaultIconHandles = _defaultIconHandle; - } } private long hmon; @@ -169,8 +145,7 @@ public class WindowDriver extends WindowImpl { ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; final long _windowHandle = CreateWindow0(DisplayDriver.getHInstance(), display.getWindowClassName(), display.getWindowClassName(), winVer.getMajor(), winVer.getMinor(), - getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags, - defaultIconHandles[0], defaultIconHandles[1]); + getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags); if ( 0 == _windowHandle ) { throw new NativeWindowException("Error creating window"); } @@ -393,8 +368,7 @@ public class WindowDriver extends WindowImpl { protected static native boolean initIDs0(long hInstance); private native long CreateWindow0(long hInstance, String wndClassName, String wndName, int winMajor, int winMinor, - long parentWindowHandle, int x, int y, int width, int height, boolean autoPosition, int flags, - long iconSmallHandle, long iconBigHandle); + long parentWindowHandle, int x, int y, int width, int height, boolean autoPosition, int flags); private native long MonitorFromWindow0(long windowHandle); private native void reconfigureWindow0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height, int flags); diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 8671ee2e0..f193df2b6 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -2014,8 +2014,7 @@ static void NewtWindow_setVisiblePosSize(HWND hwnd, BOOL atop, BOOL visible, JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindow0 (JNIEnv *env, jobject obj, jlong hInstance, jstring jWndClassName, jstring jWndName, jint winMajor, jint winMinor, - jlong parent, jint jx, jint jy, jint defaultWidth, jint defaultHeight, jboolean autoPosition, jint flags, - jlong iconSmallHandle, jlong iconBigHandle) + jlong parent, jint jx, jint jy, jint defaultWidth, jint defaultHeight, jboolean autoPosition, jint flags) { HWND parentWindow = (HWND) (intptr_t) parent; const TCHAR* wndClassName = NULL; @@ -2104,12 +2103,6 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo RECT rc; RECT * insets; - if( 0 != iconSmallHandle ) { - SendMessage(window, WM_SETICON, ICON_SMALL, (LPARAM) iconSmallHandle ); - } - if( 0 != iconBigHandle ) { - SendMessage(window, WM_SETICON, ICON_BIG, (LPARAM) iconBigHandle ); - } ShowWindow(window, SW_SHOW); // send insets before visibility, allowing java code a proper sync point! |