diff options
author | Sven Gothel <[email protected]> | 2010-09-03 00:06:03 +0300 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-09-03 00:06:03 +0300 |
commit | 340b1ceb07907be113e33c54d084e53ddc93e368 (patch) | |
tree | 2839cd761cbe52ee39151ef24f5c7c4ddca36b5d /src/newt/native/WindowsWindow.c | |
parent | 1b2f7ebe62ce661eb32cc9caf74c6c49c8c5f15a (diff) |
NEWT: Focus Fix + Cleanup
Issueing 'requestFocus' via the native EDT dispatch loop may cause a deadlock,
due to a possible implicite AWT requestFocus call (NewtCanvasAWT).
Approach:
RequestFocus issued directly,
by Window.requestFocus() and the native EDT dispatch loop,
is queued for later execution by EDT.
This shall decouple a possible native windowing TK resource collision.
- X11Windows.c: Add missing 'reparented' param for requestFocus
to force requestFocus after reparenting.
- AWTWindow.java: Add requestFocusImpl()
+++
NEWT: Cleanup
- Remove Event Type Bits in:
- EventListener.h
- NEWTEventListener.java
- Remove InputEvent 'consume' status
-
Diffstat (limited to 'src/newt/native/WindowsWindow.c')
-rw-r--r-- | src/newt/native/WindowsWindow.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index cda6a4086..6b8f2b73f 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -91,7 +91,6 @@ #include "com_jogamp_newt_impl_windows_WindowsWindow.h" -#include "EventListener.h" #include "MouseEvent.h" #include "InputEvent.h" #include "KeyEvent.h" @@ -117,9 +116,12 @@ static jmethodID visibleChangedID = NULL; static jmethodID windowDestroyNotifyID = NULL; static jmethodID windowDestroyedID = NULL; static jmethodID windowRepaintID = NULL; +static jmethodID enqueueMouseEventID = NULL; static jmethodID sendMouseEventID = NULL; +static jmethodID enqueueKeyEventID = NULL; static jmethodID sendKeyEventID = NULL; static jmethodID focusActionID = NULL; +static jmethodID enqueueRequestFocusID = NULL; static RECT* UpdateInsets(JNIEnv *env, HWND hwnd, jobject window); @@ -806,7 +808,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, case WM_LBUTTONDOWN: DBG_PRINT("*** WindowsWindow: LBUTTONDOWN\n"); - NewtWindows_requestFocus ( env, window, wnd, FALSE ); // request focus on this window, if not already .. + (*env)->CallVoidMethod(env, window, enqueueRequestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, GetModifiers(), @@ -826,7 +828,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, case WM_MBUTTONDOWN: DBG_PRINT("*** WindowsWindow: MBUTTONDOWN\n"); - NewtWindows_requestFocus ( env, window, wnd, FALSE ); // request focus on this window, if not already .. + (*env)->CallVoidMethod(env, window, enqueueRequestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, GetModifiers(), @@ -846,7 +848,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, case WM_RBUTTONDOWN: DBG_PRINT("*** WindowsWindow: RBUTTONDOWN\n"); - NewtWindows_requestFocus ( env, window, wnd, FALSE ); // request focus on this window, if not already .. + (*env)->CallVoidMethod(env, window, enqueueRequestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, GetModifiers(), @@ -1075,8 +1077,11 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V"); windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V"); windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(IIII)V"); + enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V"); sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); + enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V"); sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); + enqueueRequestFocusID = (*env)->GetMethodID(env, clazz, "enqueueRequestFocus", "(Z)V"); focusActionID = (*env)->GetMethodID(env, clazz, "focusAction", "()Z"); if (insetsChangedID == NULL || @@ -1087,10 +1092,12 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI windowDestroyNotifyID == NULL || windowDestroyedID == NULL || windowRepaintID == NULL || + enqueueMouseEventID == NULL || sendMouseEventID == NULL || + enqueueKeyEventID == NULL || sendKeyEventID == NULL || - focusActionID == NULL) - { + focusActionID == NULL || + enqueueRequestFocusID == NULL) { return JNI_FALSE; } BuildDynamicKeyMapTable(); |