From d8fa00d35a49f4faf5f04aeb7e2bba4e972965f5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 9 Nov 2011 01:11:40 +0100 Subject: OS X Layered View: Part3 JAWTWindow/MacOSXJAWTWindow (Java/Native) JAWTWindow: - Add comment about caller of cstr, since it uses reflection - Field 'config' is of type AWTGraphicsConfiguration, validate and type it - Impl. NativeSurfaceHolder/NativeWindowHolder 'hooks' MacOSXJAWTWindow: - Use agnostic JAWTUtil.isJAWTVersionUsingOffscreenLayer() to determine 'isOffscreenLayeredSurface'. We may promote this notion to JAWTWindow, which already holds 'isApplet' - lockSurface() case 'isOffscreenLayeredSurface': - Create dummy NSWindow (OSXUtil) for getWindowHandle() - Fix chosen caps: offscreen --- src/nativewindow/native/macosx/OSXmisc.m | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'src/nativewindow/native/macosx/OSXmisc.m') diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 55ec83279..16a4ed148 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -169,6 +169,59 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyNSView0 [pool release]; } +/* + * Class: Java_jogamp_nativewindow_macosx_OSXUtil + * Method: CreateNSWindow0 + * Signature: (IIIIZ)J + */ +JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 + (JNIEnv *env, jclass unused, jint x, jint y, jint width, jint height) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NSRect rect = NSMakeRect(x, y, width, height); + + // Allocate the window + NSWindow* myWindow = [[NSWindow alloc] initWithContentRect: rect + styleMask: NSBorderlessWindowMask + backing: NSBackingStoreBuffered + defer: YES]; + [myWindow setReleasedWhenClosed: YES]; // default + [myWindow setPreservesContentDuringLiveResize: YES]; + + // invisible .. + [myWindow setOpaque: NO]; + [myWindow setBackgroundColor: [NSColor clearColor]]; + + // force surface creation + // [myView lockFocus]; + // [myView unlockFocus]; + + [pool release]; + + return (jlong) ((intptr_t) myWindow); +} + +/* + * Class: Java_jogamp_nativewindow_macosx_OSXUtil + * Method: DestroyNSWindow0 + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyNSWindow0 + (JNIEnv *env, jclass unused, jlong nsWindow) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NSWindow* mWin = (NSWindow*) ((intptr_t) nsWindow); + NSView* mView = [mWin contentView]; + + if(NULL!=mView) { + [mWin setContentView: nil]; + [mView release]; + } + [mWin orderOut: mWin]; + [mWin close]; // performs release! + [pool release]; +} + /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: attachJAWTSurfaceLayer -- cgit v1.2.3