Windows: Pulled DefWindowProc calling to java side

This commit is contained in:
Elias Naur 2007-12-13 09:29:36 +00:00
parent de1520d80f
commit 4bf0703eb1
3 changed files with 30 additions and 27 deletions

View File

@ -57,7 +57,7 @@ public final class Sys {
private static final String VERSION = "1.1.3";
/** Current version of the JNI library */
static final int JNI_VERSION = 11;
static final int JNI_VERSION = 12;
/** The implementation instance to delegate platform specific behavior to */
private final static SysImplementation implementation;

View File

@ -627,12 +627,14 @@ final class WindowsDisplay implements DisplayImplementation {
private static native void clientToScreen(long hwnd, IntBuffer point);
private static boolean handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
private static int 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 false;
return defWindowProc(hwnd, msg, wParam, lParam);
}
private static native int defWindowProc(long hwnd, int msg, long wParam, long lParam);
private void checkCursorState() {
updateCursor();
@ -656,7 +658,7 @@ final class WindowsDisplay implements DisplayImplementation {
checkCursorState();
}
private boolean doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
private int doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
switch (msg) {
// disable screen saver and monitor power down messages which wreak havoc
case WM_ACTIVATE:
@ -669,7 +671,7 @@ final class WindowsDisplay implements DisplayImplementation {
appActivate(false);
break;
}
return true;
return 0;
case WM_SIZE:
switch ((int)wParam) {
case SIZE_RESTORED:
@ -680,39 +682,39 @@ final class WindowsDisplay implements DisplayImplementation {
setMinimized(true);
break;
}
return false;
return defWindowProc(hwnd, msg, wParam, lParam);
case WM_MOUSEMOVE:
int xPos = (int)(short)(lParam & 0xFFFF);
int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF));
handleMouseMoved(xPos, yPos, millis);
checkCursorState();
return true;
return 0;
case WM_MOUSEWHEEL:
int dwheel = (int)(short)((wParam >> 16) & 0xFFFF);
handleMouseScrolled(dwheel, millis);
return true;
return 0;
case WM_LBUTTONDOWN:
handleMouseButton(0, 1, millis);
return true;
return 0;
case WM_LBUTTONUP:
handleMouseButton(0, 0, millis);
return true;
return 0;
case WM_RBUTTONDOWN:
handleMouseButton(1, 1, millis);
return true;
return 0;
case WM_RBUTTONUP:
handleMouseButton(1, 0, millis);
return true;
return 0;
case WM_MBUTTONDOWN:
handleMouseButton(2, 1, millis);
return true;
return 0;
case WM_MBUTTONUP:
handleMouseButton(2, 0, millis);
return true;
return 0;
case WM_SYSCHAR:
case WM_CHAR:
handleChar(wParam, lParam, millis);
return true;
return 0;
case WM_SYSKEYUP:
/* Fall through */
case WM_KEYUP:
@ -730,29 +732,29 @@ final class WindowsDisplay implements DisplayImplementation {
/* Fall through */
case WM_KEYDOWN:
handleKeyButton(wParam, lParam, millis);
return false;
return defWindowProc(hwnd, msg, wParam, lParam);
case WM_QUIT:
close_requested = true;
return true;
return 0;
case WM_SYSCOMMAND:
switch ((int)(wParam & 0xfff0)) {
case SC_KEYMENU:
case SC_MOUSEMENU:
case SC_SCREENSAVE:
case SC_MONITORPOWER:
return true;
return 0;
case SC_CLOSE:
close_requested = true;
return true;
return 0;
default:
break;
}
return false;
return defWindowProc(hwnd, msg, wParam, lParam);
case WM_PAINT:
is_dirty = true;
return false;
return defWindowProc(hwnd, msg, wParam, lParam);
default:
return false;
return defWindowProc(hwnd, msg, wParam, lParam);
}
}

View File

@ -117,15 +117,16 @@ static LRESULT CALLBACK lwjglWindowProc(HWND hWnd,
}
if (display_class_global != NULL) {
message_time = GetMessageTime();
handleMessage_method = (*env)->GetStaticMethodID(env, display_class_global, "handleMessage", "(JIJJJ)Z");
handleMessage_method = (*env)->GetStaticMethodID(env, display_class_global, "handleMessage", "(JIJJJ)I");
if (handleMessage_method != NULL)
if ((*env)->CallStaticBooleanMethod(env, display_class_global, handleMessage_method, (jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)message_time))
return 0;
return (*env)->CallStaticIntMethod(env, display_class_global, handleMessage_method, (jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)message_time);
}
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
// default action
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) {
return DefWindowProc((HWND)(INT_PTR)hWnd, msg, wParam, lParam);
}
/*