diff options
author | Sven Gothel <[email protected]> | 2020-01-06 18:16:47 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-01-06 18:16:47 +0100 |
commit | abbc95745b69dcd7f5f84c7a56bf32947c23e74d (patch) | |
tree | 2ff465c56ef5c5ab31b27ffa2b212865b21cb173 /src/nativewindow/native/macosx/OSXmisc.m | |
parent | 8ab8412568d362b0bf65a40d727ba052a519ea3d (diff) |
Bug 1421: OSXUtil: Add GetLocation(..), simply returning the view's frame position
Diffstat (limited to 'src/nativewindow/native/macosx/OSXmisc.m')
-rw-r--r-- | src/nativewindow/native/macosx/OSXmisc.m | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 091b1a67e..6c13d9c05 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -180,6 +180,42 @@ static NSScreen * OSXUtil_getNSScreenByCGDirectDisplayID(CGDirectDisplayID displ /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil + * Method: getLocation0 + * Signature: (J)Lcom/jogamp/nativewindow/util/Point; + */ +JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetLocation0 + (JNIEnv *env, jclass unused, jlong winOrView) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + /** + * return location in 0/0 top-left space, + * OSX is 0/0 bottom-left space naturally + */ + NSObject *nsObj = (NSObject*) (intptr_t) winOrView; + NSWindow* win = NULL; + NSView* view = NULL; + + if( [nsObj isKindOfClass:[NSWindow class]] ) { + win = (NSWindow*) nsObj; + view = [win contentView]; + } else if( nsObj != NULL && [nsObj isKindOfClass:[NSView class]] ) { + view = (NSView*) nsObj; + win = [view window]; + } else { + NativewindowCommon_throwNewRuntimeException(env, "neither win nor view %p\n", nsObj); + } + NSRect viewFrame = [view frame]; + + jobject res = (*env)->NewObject(env, pointClz, pointCstr, (jint)viewFrame.origin.x, (jint)viewFrame.origin.y); + + [pool release]; + + return res; +} + +/* + * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: getLocationOnScreen0 * Signature: (JII)Lcom/jogamp/nativewindow/util/Point; */ |