aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native/NewtCommon.c
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-25 04:38:59 +0200
committerSven Gothel <[email protected]>2011-09-25 04:38:59 +0200
commite5ab975727134d8249277f4df707b2b14a7788f3 (patch)
tree296ff9712f24df60c6840f169313ec87c2bfeff0 /src/newt/native/NewtCommon.c
parentb72bedc93e4dca6d3c55cae0cc811cb4baac13e0 (diff)
NEWT/JOGL: MacOSX Update
Feature related: - Added always-on-top - Added translucency - Child Window Position - AWT parent: manual traverse up the tree and calc position on screen (Problem: the parent view rect is not at the proper position, but covers the whole frame) EDTUtil related: - Works now w/ AWT ot headless (again) - OSX native JNI callbacks gathering JNIEnv properly and attaches/detaches thread. - AWT case: using AWT-Event which properly dispatches our cocoa events - MainThread (headless) case: Fork off thread w/ main class and kick off NSApp run(). This leads to same behavior as w/ AWT case. - Using DefaultEDTUtil - Cleanup MainThread (implements EDTUtil) - Currently not used as EDTUtil (osx), just as launcher - Removed EDTUtil impl code, reuse DefaultEDTUtil - Cleanup AWTEDTUtil (implements EDTUtil) - Currently not used as EDTUtil (osx)
Diffstat (limited to 'src/newt/native/NewtCommon.c')
-rw-r--r--src/newt/native/NewtCommon.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/newt/native/NewtCommon.c b/src/newt/native/NewtCommon.c
index f44d71901..3713cfd6c 100644
--- a/src/newt/native/NewtCommon.c
+++ b/src/newt/native/NewtCommon.c
@@ -53,3 +53,30 @@ jchar* NewtCommon_GetNullTerminatedStringChars(JNIEnv* env, jstring str)
return strChars;
}
+JNIEnv* NewtCommon_GetJNIEnv(JavaVM * jvmHandle, int jvmVersion, int * shallBeDetached) {
+ JNIEnv* curEnv = NULL;
+ JNIEnv* newEnv = NULL;
+ int envRes;
+
+ // retrieve this thread's JNIEnv curEnv - or detect it's detached
+ envRes = (*jvmHandle)->GetEnv(jvmHandle, (void **) &curEnv, jvmVersion) ;
+ if( JNI_EDETACHED == envRes ) {
+ // detached thread - attach to JVM
+ if( JNI_OK != ( envRes = (*jvmHandle)->AttachCurrentThread(jvmHandle, (void**) &newEnv, NULL) ) ) {
+ fprintf(stderr, "JNIEnv: can't attach thread: %d\n", envRes);
+ return NULL;
+ }
+ curEnv = newEnv;
+ } else if( JNI_OK != envRes ) {
+ // oops ..
+ fprintf(stderr, "can't GetEnv: %d\n", envRes);
+ return NULL;
+ }
+ if (curEnv==NULL) {
+ fprintf(stderr, "env is NULL\n");
+ return NULL;
+ }
+ *shallBeDetached = NULL != newEnv;
+ return curEnv;
+}
+