diff --git a/build.xml b/build.xml index d48f8d15..e0cb53b4 100644 --- a/build.xml +++ b/build.xml @@ -284,7 +284,7 @@ - + @@ -293,7 +293,7 @@ - + @@ -301,7 +301,7 @@ - + @@ -310,17 +310,17 @@ - + - + - + @@ -330,7 +330,7 @@ - + @@ -342,7 +342,7 @@ - + @@ -350,7 +350,7 @@ - + diff --git a/platform_build/build-generator.xml b/platform_build/build-generator.xml index cbb3c9a2..e288ad31 100644 --- a/platform_build/build-generator.xml +++ b/platform_build/build-generator.xml @@ -1,5 +1,7 @@ + + @@ -20,7 +22,7 @@ - + diff --git a/platform_build/windows_ant/build.xml b/platform_build/windows_ant/build.xml index b0c305b2..bca66433 100644 --- a/platform_build/windows_ant/build.xml +++ b/platform_build/windows_ant/build.xml @@ -6,8 +6,8 @@ - - + + diff --git a/src/java/org/lwjgl/opengl/Display.java b/src/java/org/lwjgl/opengl/Display.java index e875529e..2e9c6584 100644 --- a/src/java/org/lwjgl/opengl/Display.java +++ b/src/java/org/lwjgl/opengl/Display.java @@ -58,6 +58,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Arrays; import java.util.HashSet; +import javax.swing.*; public final class Display { @@ -121,6 +122,12 @@ public final class Display { private static float r, g, b; private static final ComponentListener component_listener = new ComponentAdapter() { + public void componentMoved(ComponentEvent e) { + synchronized ( GlobalLock.lock ) { + parent_resized = true; + } + } + public void componentResized(ComponentEvent e) { synchronized ( GlobalLock.lock ) { parent_resized = true; @@ -298,6 +305,7 @@ public final class Display { throw new LWJGLException("Parent.isDisplayable() must be true"); if ( tmp_parent != null ) { tmp_parent.addComponentListener(component_listener); + SwingUtilities.windowForComponent(parent).addComponentListener(component_listener); } DisplayMode mode = getEffectiveMode(); display_impl.createWindow(drawable, mode, tmp_parent, getWindowX(), getWindowY()); @@ -335,6 +343,7 @@ public final class Display { } if ( parent != null ) { parent.removeComponentListener(component_listener); + SwingUtilities.windowForComponent(parent).removeComponentListener(component_listener); } releaseDrawable(); @@ -401,7 +410,7 @@ public final class Display { /** * An accurate sync method that will attempt to run at a constant frame rate. * It should be called once every frame. - * + * * @param fps - the desired frame rate, in frames per second */ public static void sync(int fps) { @@ -1257,7 +1266,7 @@ public final class Display { * @return this method will return the x position (top-left) of the Display window. * * If running in fullscreen mode it will return 0. - * If Display.setParent(Canvas parent) is being used, the x position of + * If Display.setParent(Canvas parent) is being used, the x position of * the parent will be returned. */ public static int getX() { @@ -1272,12 +1281,12 @@ public final class Display { return display_impl.getX(); } - + /** * @return this method will return the y position (top-left) of the Display window. * * If running in fullscreen mode it will return 0. - * If Display.setParent(Canvas parent) is being used, the y position of + * If Display.setParent(Canvas parent) is being used, the y position of * the parent will be returned. */ public static int getY() { @@ -1292,7 +1301,7 @@ public final class Display { return display_impl.getY(); } - + /** * @return this method will return the width of the Display window. * diff --git a/src/java/org/lwjgl/opengl/WindowsDisplay.java b/src/java/org/lwjgl/opengl/WindowsDisplay.java index 2986109f..30929433 100644 --- a/src/java/org/lwjgl/opengl/WindowsDisplay.java +++ b/src/java/org/lwjgl/opengl/WindowsDisplay.java @@ -38,8 +38,9 @@ package org.lwjgl.opengl; * @author elias_naur */ +import java.awt.*; +import java.lang.reflect.Method; import java.nio.*; -import java.awt.Canvas; import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; @@ -49,6 +50,8 @@ import org.lwjgl.input.Cursor; import org.lwjgl.input.Mouse; import org.lwjgl.opengles.EGL; +import javax.swing.*; + final class WindowsDisplay implements DisplayImplementation { private static final int GAMMA_LENGTH = 256; @@ -150,9 +153,9 @@ final class WindowsDisplay implements DisplayImplementation { private static final int WS_THICKFRAME = 0x00040000; private static final int WS_MAXIMIZEBOX = 0x00010000; - + private static final int HTCLIENT = 0x01; - + private static final int MK_XBUTTON1 = 0x0020; private static final int MK_XBUTTON2 = 0x0040; private static final int XBUTTON1 = 0x0001; @@ -199,6 +202,15 @@ final class WindowsDisplay implements DisplayImplementation { private boolean trackingMouse; private boolean mouseInside; + static { + try { + final Method windowProc = WindowsDisplay.class.getDeclaredMethod("handleMessage", long.class, int.class, long.class, long.class, long.class); + setWindowProc(windowProc); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } + } + WindowsDisplay() { current_display = this; } @@ -212,7 +224,7 @@ final class WindowsDisplay implements DisplayImplementation { maximized = false; this.parent = parent; hasParent = parent != null; - long parent_hwnd = parent != null ? getHwnd(parent) : 0; + long parent_hwnd = parent != null ? nGetParent(getHwnd(parent)) : 0; this.hwnd = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), Display.isFullscreen() || isUndecorated(), parent != null, parent_hwnd); this.resizable=false; if (hwnd == 0) { @@ -233,6 +245,8 @@ final class WindowsDisplay implements DisplayImplementation { ((DrawableGLES)drawable).initialize(hwnd, hdc, EGL.EGL_WINDOW_BIT, (org.lwjgl.opengles.PixelFormat)drawable.getPixelFormat()); } peer_info.initDC(getHwnd(), getHdc()); + if ( parent != null ) + reshape(0, 0, mode.getWidth(), mode.getHeight()); showWindow(getHwnd(), SW_SHOWDEFAULT); updateWidthAndHeight(); @@ -275,6 +289,8 @@ final class WindowsDisplay implements DisplayImplementation { } } + private static native long nGetParent(long hWnd); + public void destroyWindow() { nReleaseDC(hwnd, hdc); nDestroyWindow(hwnd); @@ -496,9 +512,6 @@ final class WindowsDisplay implements DisplayImplementation { public void update() { nUpdate(); - if (parent != null && parent.isFocusOwner()) { - setFocus(getHwnd()); - } if (redoMakeContextCurrent) { redoMakeContextCurrent = false; /** @@ -518,6 +531,15 @@ final class WindowsDisplay implements DisplayImplementation { private static native void nUpdate(); public void reshape(int x, int y, int width, int height) { + if ( parent != null ) { + // Translate canvas location to screen coordinates + Point p = new Point(); + + SwingUtilities.convertPointToScreen(p, parent); + + x += p.getX(); + y += p.getY(); + } nReshape(getHwnd(), x, y, width, height, Display.isFullscreen() || isUndecorated(), parent != null); } private static native void nReshape(long hwnd, int x, int y, int width, int height, boolean undecorated, boolean child); @@ -780,10 +802,6 @@ final class WindowsDisplay implements DisplayImplementation { nReleaseCapture(); } } - - if (parent != null && !isFocused) { - setFocus(getHwnd()); - } } private boolean shouldGrab() { @@ -833,14 +851,16 @@ final class WindowsDisplay implements DisplayImplementation { private static native void clientToScreen(long hwnd, IntBuffer point); - private static int handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { + private static native void setWindowProc(Method windowProc); + + private static long handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { if (current_display != null) return current_display.doHandleMessage(hwnd, msg, wParam, lParam, millis); else return defWindowProc(hwnd, msg, wParam, lParam); } - private static native int defWindowProc(long hwnd, int msg, long wParam, long lParam); + private static native long defWindowProc(long hwnd, int msg, long wParam, long lParam); private void checkCursorState() { updateClipping(); @@ -863,7 +883,12 @@ final class WindowsDisplay implements DisplayImplementation { checkCursorState(); } - private int doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { + private long doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { + if ( hwnd != getHwnd() ) { + // Can happen at start-up + return defWindowProc(hwnd, msg, wParam, lParam); + } + switch (msg) { // disable screen saver and monitor power down messages which wreak havoc case WM_ACTIVATE: @@ -876,7 +901,7 @@ final class WindowsDisplay implements DisplayImplementation { appActivate(false); break; } - return 0; + return 0L; case WM_SIZE: switch ((int)wParam) { case SIZE_RESTORED: @@ -908,13 +933,13 @@ final class WindowsDisplay implements DisplayImplementation { } else { // let Windows handle cursors outside the client area for resizing, etc. return defWindowProc(hwnd, msg, wParam, lParam); - } + } case WM_KILLFOCUS: appActivate(false); - return 0; + return 0L; case WM_SETFOCUS: appActivate(true); - return 0; + return 0L; case WM_MOUSEMOVE: int xPos = (int)(short)(lParam & 0xFFFF); int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF)); @@ -924,29 +949,29 @@ final class WindowsDisplay implements DisplayImplementation { if(!trackingMouse) { trackingMouse = nTrackMouseEvent(hwnd); } - return 0; + return 0L; case WM_MOUSEWHEEL: int dwheel = (int)(short)((wParam >> 16) & 0xFFFF); handleMouseScrolled(dwheel, millis); - return 0; + return 0L; case WM_LBUTTONDOWN: handleMouseButton(0, 1, millis); - return 0; + return 0L; case WM_LBUTTONUP: handleMouseButton(0, 0, millis); - return 0; + return 0L; case WM_RBUTTONDOWN: handleMouseButton(1, 1, millis); - return 0; + return 0L; case WM_RBUTTONUP: handleMouseButton(1, 0, millis); - return 0; + return 0L; case WM_MBUTTONDOWN: handleMouseButton(2, 1, millis); - return 0; + return 0L; case WM_MBUTTONUP: handleMouseButton(2, 0, millis); - return 0; + return 0L; case WM_XBUTTONUP: if((wParam >> 16) == XBUTTON1) { handleMouseButton(3, 0, millis); @@ -964,7 +989,7 @@ final class WindowsDisplay implements DisplayImplementation { case WM_SYSCHAR: case WM_CHAR: handleChar(wParam, lParam, millis); - return 0; + return 0L; case WM_SYSKEYUP: /* Fall through */ case WM_KEYUP: @@ -985,17 +1010,17 @@ final class WindowsDisplay implements DisplayImplementation { return defWindowProc(hwnd, msg, wParam, lParam); case WM_QUIT: close_requested = true; - return 0; + return 0L; case WM_SYSCOMMAND: switch ((int)(wParam & 0xfff0)) { case SC_KEYMENU: case SC_MOUSEMENU: case SC_SCREENSAVE: case SC_MONITORPOWER: - return 0; + return 0L; case SC_CLOSE: close_requested = true; - return 0; + return 0L; default: break; } @@ -1015,7 +1040,7 @@ final class WindowsDisplay implements DisplayImplementation { handleMouseButton(captureMouse, 0, millis); captureMouse = -1; } - return 0; + return 0L; case WM_WINDOWPOSCHANGED: if(getWindowRect(hwnd, rect_buffer)) { rect.copyFromBuffer(rect_buffer); @@ -1024,12 +1049,12 @@ final class WindowsDisplay implements DisplayImplementation { } else { LWJGLUtil.log("WM_WINDOWPOSCHANGED: Unable to get window rect"); } - return defWindowProc(hwnd, msg, wParam, lParam); + return defWindowProc(hwnd, msg, wParam, lParam); default: return defWindowProc(hwnd, msg, wParam, lParam); } } - + private native boolean getWindowRect(long hwnd, IntBuffer rectBuffer); public int getX() { @@ -1056,8 +1081,8 @@ final class WindowsDisplay implements DisplayImplementation { public void setResizable(boolean resizable) { if(this.resizable != resizable) { - long style = getWindowLongPtr(hwnd, GWL_STYLE); - long styleex = getWindowLongPtr(hwnd, GWL_EXSTYLE); + int style = (int)getWindowLongPtr(hwnd, GWL_STYLE); + int styleex = (int)getWindowLongPtr(hwnd, GWL_EXSTYLE); // update frame style if(resizable && !Display.isFullscreen()) { @@ -1082,7 +1107,7 @@ final class WindowsDisplay implements DisplayImplementation { this.resizable = resizable; } - private native boolean adjustWindowRectEx(IntBuffer rectBuffer, long style, boolean menu, long styleex); + private native boolean adjustWindowRectEx(IntBuffer rectBuffer, int style, boolean menu, int styleex); public boolean wasResized() { if(resized) { diff --git a/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java b/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java index 13094175..19006c09 100644 --- a/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java +++ b/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java @@ -324,7 +324,7 @@ public class NativeMethodStubsGenerator { // Declare loop counters and allocate object array if ( !ptrLoopDeclared ) { - writer.println("\tunsigned int " + n + "_i;"); + writer.println("\tint " + n + "_i;"); writer.println("\tjobject " + n + "_object;"); ptrLoopDeclared = true; } @@ -336,7 +336,7 @@ public class NativeMethodStubsGenerator { // Declare loop counters and allocate string array if ( !strLoopDeclared ) { - writer.println("\tunsigned int " + n + "_i;"); + writer.println("\tint " + n + "_i;"); writer.println("\t" + arrayType + n + "_address;"); strLoopDeclared = true; } diff --git a/src/native/common/common_tools.c b/src/native/common/common_tools.c index 1ab695e6..13731e3d 100644 --- a/src/native/common/common_tools.c +++ b/src/native/common/common_tools.c @@ -227,11 +227,11 @@ jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *ustr) { const char *str = (const char *)ustr; if (str == NULL) return NULL; - return NewStringNativeWithLength(env, str, strlen(str)); + return NewStringNativeWithLength(env, str, (jsize)strlen(str)); } // creates locale specific string -jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length) { +jstring NewStringNativeWithLength(JNIEnv *env, const char *str, jsize length) { jclass jcls_str; jmethodID jmethod_str; jstring result; @@ -330,7 +330,7 @@ void ext_InitializeClass(JNIEnv *env, jclass clazz, ExtGetProcAddressPROC gpa, i } bool getBooleanProperty(JNIEnv *env, const char* propertyName) { - jstring property = NewStringNativeWithLength(env, propertyName, strlen(propertyName)); + jstring property = NewStringNativeWithLength(env, propertyName, (jsize)strlen(propertyName)); jclass org_lwjgl_LWJGLUtil_class; jmethodID getBoolean; if (property == NULL) diff --git a/src/native/common/common_tools.h b/src/native/common/common_tools.h index 1ac395e9..785fa506 100644 --- a/src/native/common/common_tools.h +++ b/src/native/common/common_tools.h @@ -75,18 +75,18 @@ static inline void * safeGetBufferAddress(JNIEnv *env, jobject buffer) { return NULL; } -static inline jobject safeNewBuffer(JNIEnv *env, void *p, int size) { +static inline jobject safeNewBuffer(JNIEnv *env, void *p, jlong capacity) { if (p != NULL) { #ifdef __cplusplus - return env->NewDirectByteBuffer(p, size); + return env->NewDirectByteBuffer(p, capacity); #else - return (*env)->NewDirectByteBuffer(env, p, size); + return (*env)->NewDirectByteBuffer(env, p, capacity); #endif } else return NULL; } -static inline jobject safeNewBufferCached(JNIEnv *env, void *p, int size, jobject old_buffer) { +static inline jobject safeNewBufferCached(JNIEnv *env, void *p, jlong size, jobject old_buffer) { if (old_buffer != NULL) { void *old_buffer_address = (*env)->GetDirectBufferAddress(env, old_buffer); jlong capacity = (*env)->GetDirectBufferCapacity(env, old_buffer); @@ -141,7 +141,7 @@ extern void printfDebugJava(JNIEnv *env, const char *format, ...); extern void printfDebug(const char *format, ...); extern bool getBooleanProperty(JNIEnv *env, const char* propertyName); extern char * GetStringNativeChars(JNIEnv *env, jstring jstr); -extern jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length); +extern jstring NewStringNativeWithLength(JNIEnv *env, const char *str, jsize length); extern jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *str); extern jobject NewReadOnlyDirectByteBuffer(JNIEnv* env, const void* address, jlong capacity); extern jobject newJavaManagedByteBuffer(JNIEnv *env, const int size); diff --git a/src/native/common/extcl.c b/src/native/common/extcl.c index 4ecf73b9..c87e068c 100644 --- a/src/native/common/extcl.c +++ b/src/native/common/extcl.c @@ -59,7 +59,7 @@ void extcl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMet ext_InitializeClass(env, clazz, &extcl_GetProcAddress, num_functions, functions); } -int extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch) { +size_t extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch) { if ( slice_pitch == 0 ) return region[1] * row_pitch; else diff --git a/src/native/common/extcl.h b/src/native/common/extcl.h index e6e6bc98..20f10f74 100644 --- a/src/native/common/extcl.h +++ b/src/native/common/extcl.h @@ -70,7 +70,7 @@ typedef void (CL_CALLBACK * cl_printf_callback)(cl_context context, cl_uint prin void* extcl_GetProcAddress(const char* function); void extcl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions); -int extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch); +size_t extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch); // -----------------[ Platform dependent functions ]----------------- diff --git a/src/native/common/org_lwjgl_openal_ALC10.c b/src/native/common/org_lwjgl_openal_ALC10.c index f93008ce..6764ef6a 100644 --- a/src/native/common/org_lwjgl_openal_ALC10.c +++ b/src/native/common/org_lwjgl_openal_ALC10.c @@ -83,7 +83,7 @@ static alcGetEnumValuePROC alcGetEnumValue; */ static jobject JNICALL Java_org_lwjgl_openal_ALC10_nalcGetString (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token) { char* alcString = (char*) alcGetString((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token); - int length; + size_t length; int i=1; if (alcString == NULL) { diff --git a/src/native/common/org_lwjgl_opencl_CallbackUtil.c b/src/native/common/org_lwjgl_opencl_CallbackUtil.c index eeb0e368..17d937db 100644 --- a/src/native/common/org_lwjgl_opencl_CallbackUtil.c +++ b/src/native/common/org_lwjgl_opencl_CallbackUtil.c @@ -67,7 +67,7 @@ static void CL_CALLBACK contextCallback(const char *errinfo, const void *private private_info_buffer = NewReadOnlyDirectByteBuffer(env, private_info, cb); (*env)->CallVoidMethod(env, (jobject)user_data, contextCallbackJ, - NewStringNativeWithLength(env, errinfo, strlen(errinfo)), + NewStringNativeWithLength(env, errinfo, (jsize)strlen(errinfo)), private_info_buffer ); } diff --git a/src/native/windows/display.c b/src/native/windows/display.c index 0324b40a..4639598d 100644 --- a/src/native/windows/display.c +++ b/src/native/windows/display.c @@ -203,7 +203,7 @@ jobject convertToNativeRamp(JNIEnv *env, jobject float_gamma_obj) { float scaledRampEntry; WORD rampEntry; const float *gammaRamp = (const float *)(*env)->GetDirectBufferAddress(env, float_gamma_obj); - jint gamma_ramp_length = (*env)->GetDirectBufferCapacity(env, float_gamma_obj); + jint gamma_ramp_length = (jint)(*env)->GetDirectBufferCapacity(env, float_gamma_obj); jobject native_ramp; WORD *native_ramp_buffer; diff --git a/src/native/windows/opengl/context.c b/src/native/windows/opengl/context.c index 74d6fc5d..61ba906b 100644 --- a/src/native/windows/opengl/context.c +++ b/src/native/windows/opengl/context.c @@ -118,7 +118,7 @@ void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool undec windowflags = WS_POPUP; } else if (child_window) { exstyle = 0; - windowflags = WS_CHILDWINDOW; + windowflags = WS_POPUP; } else { exstyle = WS_EX_APPWINDOW; windowflags = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU; diff --git a/src/native/windows/org_lwjgl_Sys.c b/src/native/windows/org_lwjgl_Sys.c index fbdeefc6..05f3edaf 100644 --- a/src/native/windows/org_lwjgl_Sys.c +++ b/src/native/windows/org_lwjgl_Sys.c @@ -90,7 +90,7 @@ JNIEXPORT jstring JNICALL Java_org_lwjgl_WindowsSysImplementation_nGetClipboard return NULL; } str = (const wchar_t *)clipboard_data; - ret = (*env)->NewString(env, str, wcslen(str)); + ret = (*env)->NewString(env, str, (jsize)wcslen(str)); } else if (textAvailable) { if (!OpenClipboard(NULL)) return NULL; @@ -104,7 +104,7 @@ JNIEXPORT jstring JNICALL Java_org_lwjgl_WindowsSysImplementation_nGetClipboard CloseClipboard(); return NULL; } - ret = NewStringNativeWithLength(env, (const char *) clipboard_data, strlen(clipboard_data)); + ret = NewStringNativeWithLength(env, (const char *) clipboard_data, (jsize)strlen(clipboard_data)); } else { return NULL; } diff --git a/src/native/windows/org_lwjgl_opengl_Display.c b/src/native/windows/org_lwjgl_opengl_Display.c index 53e43e00..4b9a8bd5 100644 --- a/src/native/windows/org_lwjgl_opengl_Display.c +++ b/src/native/windows/org_lwjgl_opengl_Display.c @@ -53,6 +53,9 @@ #define WINDOWCLASSNAME _T("LWJGL") +static jclass windowsDisplayClass; +static jmethodID javaWindowProc; + /* * WindowProc for the GL window. */ @@ -61,10 +64,12 @@ static LRESULT CALLBACK lwjglWindowProc(HWND hWnd, WPARAM wParam, LPARAM lParam) { + /* jclass display_class; jclass display_class_global; jmethodID handleMessage_method; LONG message_time; + */ JNIEnv *env = getThreadEnv(); if (env != NULL && !(*env)->ExceptionOccurred(env)) { /* @@ -80,6 +85,8 @@ static LRESULT CALLBACK lwjglWindowProc(HWND hWnd, * a window is created, where we are sure that the calling class' classloader has * LWJGL classes in it. */ + + /* display_class_global = (jclass)(LONG_PTR)GetWindowLongPtr(hWnd, GWLP_USERDATA); if (display_class_global == NULL) { display_class = (*env)->FindClass(env, "org/lwjgl/opengl/WindowsDisplay"); @@ -91,15 +98,27 @@ static LRESULT CALLBACK lwjglWindowProc(HWND hWnd, } if (display_class_global != NULL) { message_time = GetMessageTime(); - handleMessage_method = (*env)->GetStaticMethodID(env, display_class_global, "handleMessage", "(JIJJJ)I"); + handleMessage_method = (*env)->GetStaticMethodID(env, display_class_global, "handleMessage", "(JIJJJ)J"); if (handleMessage_method != NULL) - return (*env)->CallStaticIntMethod(env, display_class_global, handleMessage_method, (jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)message_time); + return (*env)->CallStaticLongMethod(env, display_class_global, handleMessage_method, (jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)message_time); + } + */ + + return (*env)->CallStaticLongMethod( + env, windowsDisplayClass, javaWindowProc, + (jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)GetMessageTime() + ); } return DefWindowProc(hWnd, msg, wParam, lParam); } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_defWindowProc(JNIEnv *env, jclass unused, jlong hWnd, jint msg, jlong wParam, jlong lParam) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowProc(JNIEnv *env, jclass clazz, jobject method) { + windowsDisplayClass = clazz; + javaWindowProc = (*env)->FromReflectedMethod(env, method); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_defWindowProc(JNIEnv *env, jclass unused, jlong hWnd, jint msg, jlong wParam, jlong lParam) { return DefWindowProc((HWND)(INT_PTR)hWnd, msg, wParam, lParam); } @@ -167,6 +186,10 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEn return (INT_PTR)hwnd; } +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nGetParent(JNIEnv *env, jclass clazz, jlong hwnd_ptr) { + return (INT_PTR)GetParent((HWND)(INT_PTR)hwnd_ptr); +} + JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReleaseDC(JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hdc_ptr) { HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; HDC hdc = (HDC)(INT_PTR)hdc_ptr; @@ -309,6 +332,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nGetVersion(JNIEn JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReshape(JNIEnv *env, jclass unused, jlong hwnd_ptr, jint x, jint y, jint width, jint height, jboolean undecorated, jboolean child) { HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + /* DWORD exstyle, windowflags; RECT clientSize; @@ -329,11 +353,11 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReshape(JNIEnv *env ); SetWindowPos(hwnd, HWND_TOP, x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, SWP_NOZORDER); + */ + SetWindowPos(hwnd, HWND_TOP, x, y, width, height, SWP_NOZORDER | SWP_NOACTIVATE); } static HICON createWindowIcon(JNIEnv *env, jint *pixels, jint width, jint height) { - unsigned char col; - unsigned char mask; BITMAPV5HEADER bitmapInfo; HBITMAP cursorMask; HBITMAP colorBitmap; @@ -345,8 +369,6 @@ static HICON createWindowIcon(JNIEnv *env, jint *pixels, jint width, jint height int imageSize; unsigned char *maskPixels; int widthInBytes; - int leftShift; - int maskPixelsOff; int scanlineWidth; HBITMAP colorDIB; @@ -475,7 +497,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getClientRect } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_adjustWindowRectEx - (JNIEnv *env, jclass unused, jobject rect_buffer, jlong style, jboolean menu, jlong styleex) { + (JNIEnv *env, jclass unused, jobject rect_buffer, jint style, jboolean menu, jint styleex) { jboolean result; RECT clientRect; copyBufferToRect(env, rect_buffer, &clientRect); diff --git a/src/native/windows/org_lwjgl_opengl_WindowsRegistry.c b/src/native/windows/org_lwjgl_opengl_WindowsRegistry.c index 2a9982fa..47616163 100644 --- a/src/native/windows/org_lwjgl_opengl_WindowsRegistry.c +++ b/src/native/windows/org_lwjgl_opengl_WindowsRegistry.c @@ -93,7 +93,7 @@ static jstring queryRegistrationKey(JNIEnv *env, HKEY root_key, LPCTSTR subkey, return NULL; } result[buf_size - 1] = '\0'; - java_result = NewStringNativeWithLength(env, result, strlen(result)); + java_result = NewStringNativeWithLength(env, result, (jsize)strlen(result)); free(result); return java_result; }