diff options
author | Sven Gothel <[email protected]> | 2011-10-16 20:40:02 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-10-16 20:40:02 +0200 |
commit | 7eaeacc4148f0ec6146e5cc8db010a7414a7b419 (patch) | |
tree | ce239b697fda34b0307da7eaa82358912ef01b59 /src | |
parent | 32b643624ad6d7533bb45143b717c68d6ea878e7 (diff) |
NEWT/OSX: Adding 'fake' lockSurface based on [view canDraw]. Can't use lockFocus(), deadlocks since we render separate to focus mgmt.
Diffstat (limited to 'src')
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java | 25 | ||||
-rw-r--r-- | src/newt/native/MacWindow.m | 34 |
2 files changed, 53 insertions, 6 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java index 8886cf630..695a03e40 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java @@ -34,17 +34,18 @@ package jogamp.newt.driver.macosx; -import javax.media.nativewindow.*; - -import com.jogamp.newt.event.*; - -import jogamp.newt.*; - +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; +import jogamp.newt.WindowImpl; + +import com.jogamp.newt.event.KeyEvent; + public class MacWindow extends WindowImpl { // Window styles @@ -172,6 +173,16 @@ public class MacWindow extends WindowImpl { } @Override + protected int lockSurfaceImpl() { + return lockSurface0(getWindowHandle()) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY; + } + + @Override + protected void unlockSurfaceImpl() { + unlockSurface0(getWindowHandle()); + } + + @Override public final long getSurfaceHandle() { return surfaceHandle; } @@ -443,6 +454,8 @@ public class MacWindow extends WindowImpl { boolean opaque, boolean fullscreen, int windowStyle, int backingStoreType, int screen_idx, long view); + private native boolean lockSurface0(long window); + private native void unlockSurface0(long window); private native void requestFocus0(long window, boolean force); /** in case of a child window, it actually only issues orderBack(..) */ private native void orderOut0(long window); 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 @@ -365,6 +371,34 @@ NS_ENDHANDLER } /* + * 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 * Signature: (JZ)V |