aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native/NewtMacWindow.m
diff options
context:
space:
mode:
authorChristopher Campbell <[email protected]>2009-05-26 22:29:17 +0000
committerChristopher Campbell <[email protected]>2009-05-26 22:29:17 +0000
commit8be32669ddc283c9b1b71a98391a711d526eab52 (patch)
tree88d8a0a1a9f97ced98f8ac7bdc574ea7c68a3ab1 /src/newt/native/NewtMacWindow.m
parent90c95605aa73985289600ad1f70d5ae29e69dcfc (diff)
Newt: implemented simple window focus management for Mac OS X
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1917 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/newt/native/NewtMacWindow.m')
-rw-r--r--src/newt/native/NewtMacWindow.m30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m
index 75d0a8e62..d225381d4 100644
--- a/src/newt/native/NewtMacWindow.m
+++ b/src/newt/native/NewtMacWindow.m
@@ -40,6 +40,7 @@ static jmethodID sendMouseEventID = NULL;
static jmethodID sendKeyEventID = NULL;
static jmethodID sizeChangedID = NULL;
static jmethodID positionChangedID = NULL;
+static jmethodID focusChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
static jmethodID windowDestroyedID = NULL;
@@ -54,9 +55,10 @@ static JNIEnv* env = NULL;
sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)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 (sendMouseEventID && sendKeyEventID && sizeChangedID && positionChangedID && windowDestroyedID && windowDestroyNotifyID) {
+ if (sendMouseEventID && sendKeyEventID && sizeChangedID && positionChangedID && focusChangedID && windowDestroyedID && windowDestroyNotifyID) {
return YES;
}
return NO;
@@ -315,4 +317,30 @@ static jint mods2JavaMods(NSUInteger mods)
// Will be called by Window.java (*env)->CallVoidMethod(env, javaWindowObject, windowDestroyedID);
}
+- (void) windowDidBecomeKey: (NSNotification *) notification
+{
+ if (env == NULL) {
+ return;
+ }
+
+ if (javaWindowObject == NULL) {
+ return;
+ }
+
+ (*env)->CallVoidMethod(env, javaWindowObject, focusChangedID, JNI_TRUE);
+}
+
+- (void) windowDidResignKey: (NSNotification *) notification
+{
+ if (env == NULL) {
+ return;
+ }
+
+ if (javaWindowObject == NULL) {
+ return;
+ }
+
+ (*env)->CallVoidMethod(env, javaWindowObject, focusChangedID, JNI_FALSE);
+}
+
@end