diff options
Diffstat (limited to 'src/newt/native')
-rw-r--r-- | src/newt/native/KDWindow.c | 16 | ||||
-rw-r--r-- | src/newt/native/NewtMacWindow.m | 53 |
2 files changed, 35 insertions, 34 deletions
diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c index 82f2ba7df..b67b8dbd3 100644 --- a/src/newt/native/KDWindow.c +++ b/src/newt/native/KDWindow.c @@ -96,8 +96,8 @@ static jmethodID windowCreatedID = NULL; static jmethodID sizeChangedID = NULL; static jmethodID windowDestroyNotifyID = NULL; static jmethodID windowDestroyedID = NULL; -static jmethodID enqueueMouseEventID = NULL; -static jmethodID enqueueKeyEventID = NULL; +static jmethodID sendMouseEventID = NULL; +static jmethodID sendKeyEventID = NULL; /** * Display @@ -180,13 +180,13 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_opengl_kd_KDDisplay_DispatchMes // time = ev->timestamp if(KD_INPUT_POINTER_SELECT==ptr->index) { DBG_PRINT( "event mouse click: src: %p, s:%d, (%d,%d)\n", userData, ptr->select, ptr->x, ptr->y); - (*env)->CallVoidMethod(env, javaWindow, enqueueMouseEventID, + (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, (ptr->select==0) ? (jint) EVENT_MOUSE_RELEASED : (jint) EVENT_MOUSE_PRESSED, (jint) 0, (jint) ptr->x, (jint) ptr->y, 1, 0); } else { DBG_PRINT( "event mouse: src: %d, s:%p, i:0x%X (%d,%d)\n", userData, ptr->select, ptr->index, ptr->x, ptr->y); - (*env)->CallVoidMethod(env, javaWindow, enqueueMouseEventID, (jint) EVENT_MOUSE_MOVED, + (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, 0, (jint) ptr->x, (jint) ptr->y, 0, 0); } @@ -213,14 +213,14 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_opengl_kd_KDWindow_initIDs sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V"); windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V"); - enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(IIIIII)V"); - enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(IIIC)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); + sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); if (windowCreatedID == NULL || sizeChangedID == NULL || windowDestroyNotifyID == NULL || windowDestroyedID == NULL || - enqueueMouseEventID == NULL || - enqueueKeyEventID == NULL) { + sendMouseEventID == NULL || + sendKeyEventID == NULL) { DBG_PRINT( "initIDs failed\n" ); return JNI_FALSE; } diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index ae658b908..da31a686e 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -109,8 +109,8 @@ jint GetDeltaY(NSEvent *event, jint javaMods) { @end -static jmethodID enqueueMouseEventID = NULL; -static jmethodID enqueueKeyEventID = NULL; +static jmethodID sendMouseEventID = NULL; +static jmethodID sendKeyEventID = NULL; static jmethodID insetsChangedID = NULL; static jmethodID sizeChangedID = NULL; static jmethodID positionChangedID = NULL; @@ -122,15 +122,15 @@ static jmethodID windowDestroyedID = NULL; + (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz { - enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(IIIIII)V"); - enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(IIIC)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); + sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)V"); insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(IIII)V"); positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(II)V"); focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(Z)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V"); windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V"); - if (enqueueMouseEventID && enqueueKeyEventID && sizeChangedID && insetsChangedID && + if (sendMouseEventID && sendKeyEventID && sizeChangedID && insetsChangedID && positionChangedID && focusChangedID && windowDestroyedID && windowDestroyNotifyID) { return YES; @@ -206,7 +206,7 @@ static jint mods2JavaMods(NSUInteger mods) return javaMods; } -- (void) enqueueKeyEvent: (NSEvent*) event eventType: (jint) evType +- (void) sendKeyEvent: (NSEvent*) event eventType: (jint) evType { NSView* nsview = [self contentView]; if( ! [nsview isMemberOfClass:[NewtView class]] ) { @@ -229,23 +229,23 @@ static jint mods2JavaMods(NSUInteger mods) // Note: the key code in the NSEvent does not map to anything we can use jchar keyChar = (jchar) [chars characterAtIndex: i]; - (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, + (*env)->CallVoidMethod(env, javaWindowObject, sendKeyEventID, evType, javaMods, keyCode, keyChar); } } - (void) keyDown: (NSEvent*) theEvent { - [self enqueueKeyEvent: theEvent eventType: EVENT_KEY_PRESSED]; + [self sendKeyEvent: theEvent eventType: EVENT_KEY_PRESSED]; } - (void) keyUp: (NSEvent*) theEvent { - [self enqueueKeyEvent: theEvent eventType: EVENT_KEY_RELEASED]; - [self enqueueKeyEvent: theEvent eventType: EVENT_KEY_TYPED]; + [self sendKeyEvent: theEvent eventType: EVENT_KEY_RELEASED]; + [self sendKeyEvent: theEvent eventType: EVENT_KEY_TYPED]; } -- (void) enqueueMouseEvent: (NSEvent*) event eventType: (jint) evType +- (void) sendMouseEvent: (NSEvent*) event eventType: (jint) evType { NSView* nsview = [self contentView]; if( ! [nsview isMemberOfClass:[NewtView class]] ) { @@ -302,7 +302,7 @@ static jint mods2JavaMods(NSUInteger mods) // ignore 0 increment wheel scroll events return; } - (*env)->CallVoidMethod(env, javaWindowObject, enqueueMouseEventID, + (*env)->CallVoidMethod(env, javaWindowObject, sendMouseEventID, evType, javaMods, (jint) location.x, (jint) (contentRect.size.height - location.y), @@ -311,70 +311,70 @@ static jint mods2JavaMods(NSUInteger mods) - (void) mouseEntered: (NSEvent*) theEvent { - [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_ENTERED]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_ENTERED]; } - (void) mouseExited: (NSEvent*) theEvent { - [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_EXITED]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_EXITED]; } - (void) mouseMoved: (NSEvent*) theEvent { - [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; } - (void) scrollWheel: (NSEvent*) theEvent { - [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_WHEEL_MOVED]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_WHEEL_MOVED]; } - (void) mouseDown: (NSEvent*) theEvent { - [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; } - (void) mouseDragged: (NSEvent*) theEvent { // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java - [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; } - (void) mouseUp: (NSEvent*) theEvent { - [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; } - (void) rightMouseDown: (NSEvent*) theEvent { - [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; } - (void) rightMouseDragged: (NSEvent*) theEvent { // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java - [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; } - (void) rightMouseUp: (NSEvent*) theEvent { - [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; } - (void) otherMouseDown: (NSEvent*) theEvent { - [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; } - (void) otherMouseDragged: (NSEvent*) theEvent { // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java - [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; } - (void) otherMouseUp: (NSEvent*) theEvent { - [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; } - (void)windowDidResize: (NSNotification*) notification @@ -442,7 +442,8 @@ static jint mods2JavaMods(NSUInteger mods) } (*env)->CallVoidMethod(env, javaWindowObject, windowDestroyNotifyID); - (*env)->CallVoidMethod(env, javaWindowObject, windowDestroyedID); // No OSX hook for DidClose, so do it here + // Can't issue call here - locked window state, done from Java method + // (*env)->CallVoidMethod(env, javaWindowObject, windowDestroyedID); // No OSX hook for DidClose, so do it here // EOL .. (*env)->DeleteGlobalRef(env, javaWindowObject); |