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"; private static final String VERSION = "1.1.3";
/** Current version of the JNI library */ /** 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 */ /** The implementation instance to delegate platform specific behavior to */
private final static SysImplementation implementation; private final static SysImplementation implementation;

View File

@ -627,13 +627,15 @@ final class WindowsDisplay implements DisplayImplementation {
private static native void clientToScreen(long hwnd, IntBuffer point); 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) if (current_display != null)
return current_display.doHandleMessage(hwnd, msg, wParam, lParam, millis); return current_display.doHandleMessage(hwnd, msg, wParam, lParam, millis);
else 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() { private void checkCursorState() {
updateCursor(); updateCursor();
updateClipping(); updateClipping();
@ -656,7 +658,7 @@ final class WindowsDisplay implements DisplayImplementation {
checkCursorState(); 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) { switch (msg) {
// disable screen saver and monitor power down messages which wreak havoc // disable screen saver and monitor power down messages which wreak havoc
case WM_ACTIVATE: case WM_ACTIVATE:
@ -669,7 +671,7 @@ final class WindowsDisplay implements DisplayImplementation {
appActivate(false); appActivate(false);
break; break;
} }
return true; return 0;
case WM_SIZE: case WM_SIZE:
switch ((int)wParam) { switch ((int)wParam) {
case SIZE_RESTORED: case SIZE_RESTORED:
@ -680,39 +682,39 @@ final class WindowsDisplay implements DisplayImplementation {
setMinimized(true); setMinimized(true);
break; break;
} }
return false; return defWindowProc(hwnd, msg, wParam, lParam);
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
int xPos = (int)(short)(lParam & 0xFFFF); int xPos = (int)(short)(lParam & 0xFFFF);
int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF)); int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF));
handleMouseMoved(xPos, yPos, millis); handleMouseMoved(xPos, yPos, millis);
checkCursorState(); checkCursorState();
return true; return 0;
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
int dwheel = (int)(short)((wParam >> 16) & 0xFFFF); int dwheel = (int)(short)((wParam >> 16) & 0xFFFF);
handleMouseScrolled(dwheel, millis); handleMouseScrolled(dwheel, millis);
return true; return 0;
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
handleMouseButton(0, 1, millis); handleMouseButton(0, 1, millis);
return true; return 0;
case WM_LBUTTONUP: case WM_LBUTTONUP:
handleMouseButton(0, 0, millis); handleMouseButton(0, 0, millis);
return true; return 0;
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
handleMouseButton(1, 1, millis); handleMouseButton(1, 1, millis);
return true; return 0;
case WM_RBUTTONUP: case WM_RBUTTONUP:
handleMouseButton(1, 0, millis); handleMouseButton(1, 0, millis);
return true; return 0;
case WM_MBUTTONDOWN: case WM_MBUTTONDOWN:
handleMouseButton(2, 1, millis); handleMouseButton(2, 1, millis);
return true; return 0;
case WM_MBUTTONUP: case WM_MBUTTONUP:
handleMouseButton(2, 0, millis); handleMouseButton(2, 0, millis);
return true; return 0;
case WM_SYSCHAR: case WM_SYSCHAR:
case WM_CHAR: case WM_CHAR:
handleChar(wParam, lParam, millis); handleChar(wParam, lParam, millis);
return true; return 0;
case WM_SYSKEYUP: case WM_SYSKEYUP:
/* Fall through */ /* Fall through */
case WM_KEYUP: case WM_KEYUP:
@ -730,29 +732,29 @@ final class WindowsDisplay implements DisplayImplementation {
/* Fall through */ /* Fall through */
case WM_KEYDOWN: case WM_KEYDOWN:
handleKeyButton(wParam, lParam, millis); handleKeyButton(wParam, lParam, millis);
return false; return defWindowProc(hwnd, msg, wParam, lParam);
case WM_QUIT: case WM_QUIT:
close_requested = true; close_requested = true;
return true; return 0;
case WM_SYSCOMMAND: case WM_SYSCOMMAND:
switch ((int)(wParam & 0xfff0)) { switch ((int)(wParam & 0xfff0)) {
case SC_KEYMENU: case SC_KEYMENU:
case SC_MOUSEMENU: case SC_MOUSEMENU:
case SC_SCREENSAVE: case SC_SCREENSAVE:
case SC_MONITORPOWER: case SC_MONITORPOWER:
return true; return 0;
case SC_CLOSE: case SC_CLOSE:
close_requested = true; close_requested = true;
return true; return 0;
default: default:
break; break;
} }
return false; return defWindowProc(hwnd, msg, wParam, lParam);
case WM_PAINT: case WM_PAINT:
is_dirty = true; is_dirty = true;
return false; return defWindowProc(hwnd, msg, wParam, lParam);
default: 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) { if (display_class_global != NULL) {
message_time = GetMessageTime(); 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 (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 (*env)->CallStaticIntMethod(env, display_class_global, handleMessage_method, (jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)message_time);
return 0;
} }
} }
return DefWindowProc(hWnd, msg, wParam, lParam);
}
// default action JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_defWindowProc(JNIEnv *env, jclass unused, jlong hWnd, jint msg, jlong wParam, jlong lParam) {
return DefWindowProc(hWnd, msg, wParam, lParam); return DefWindowProc((HWND)(INT_PTR)hWnd, msg, wParam, lParam);
} }
/* /*