From 7eaeacc4148f0ec6146e5cc8db010a7414a7b419 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 16 Oct 2011 20:40:02 +0200 Subject: NEWT/OSX: Adding 'fake' lockSurface based on [view canDraw]. Can't use lockFocus(), deadlocks since we render separate to focus mgmt. --- src/newt/native/MacWindow.m | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/newt/native') diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 871370b0d..6564fe430 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -342,6 +342,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_createWindow0 // Immediately re-position the window based on an upper-left coordinate system setFrameTopLeftPoint(parentWindow, myWindow, x, y); + + // force surface creation + [myView lockFocus]; + [myView unlockFocus]; + + // visible on front [myWindow orderFront: myWindow]; NS_DURING @@ -364,6 +370,34 @@ NS_ENDHANDLER return (jlong) ((intptr_t) myWindow); } +/* + * Class: Java_jogamp_newt_driver_macosx_MacWindow + * Method: lockSurface0 + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_lockSurface0 + (JNIEnv *env, jclass clazz, jlong window) +{ + NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); + NSView * mView = [mWin contentView]; + return [mView canDraw] == YES ? JNI_TRUE : JNI_FALSE; + // return [mView lockFocusIfCanDraw] == YES ? JNI_TRUE : JNI_FALSE; +} + +/* + * Class: Java_jogamp_newt_driver_macosx_MacWindow + * Method: unlockSurface0 + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_unlockSurface0 + (JNIEnv *env, jclass clazz, jlong window) +{ + /** deadlocks, since we render independent of focus + NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); + NSView * mView = [mWin contentView]; + [mView unlockFocus]; */ +} + /* * Class: jogamp_newt_driver_macosx_MacWindow * Method: requestFocus0 -- cgit v1.2.3