diff options
author | Sven Gothel <[email protected]> | 2013-02-20 21:51:40 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-02-20 21:51:40 +0100 |
commit | 14b278536e6f8de2ee6254796b89bd27d5419b72 (patch) | |
tree | 0f4ec76f215cbba178eb6732c1f2a9363df9d6d5 /src/nativewindow/classes/jogamp | |
parent | cf3ecdb670c0dfecd1394d5b9d5d5588c1bf71f3 (diff) |
OSX/Java7/CALayer + JAWT: Partially Fix AWT/NEWT CALayer 'out of sight' bug, where our CALayer is moved out of the visible area
- same erroneous behavior for GLCanvas and NewtCanvasAWT
- sized-frame: Set framesize and validate() it
- sized-component: Set component preferred size and call frame.pack()
- added workaround 'OffscreenLayerSurface.layoutSurfaceLayer()' to fix CALayer size, which snaps for:
- OK initial size before setVisible: sized-frame and sized-component
- OK resize w/ sized-frame
- OK manual frame resize
- Invisible: w/ sized-component after setVisible()
++
- CALayer-Sublayer (GL) has additional retain/release when added/removed
to be on safe side.
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 12 | ||||
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java | 30 |
2 files changed, 38 insertions, 4 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 9b06cce1a..b25836d3c 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -118,10 +118,20 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { OSXUtil.AddCASublayer(rootSurfaceLayerHandle, layerHandle); } + protected void layoutSurfaceLayerImpl() { + final long osl = getAttachedSurfaceLayer(); + final int w = getWidth(); + final int h = getHeight(); + if(DEBUG) { + System.err.println("JAWTWindow.fixSurfaceLayerLayout: "+toHexString(osl) + ", bounds "+bounds+", "+w+"x"+h); + } + OSXUtil.FixCALayerPosition(rootSurfaceLayerHandle, osl, w, h); + } + protected void detachSurfaceLayerImpl(final long layerHandle) { OSXUtil.RemoveCASublayer(rootSurfaceLayerHandle, layerHandle); } - + @Override public final long getWindowHandle() { return windowHandle; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index d85d1a84b..5ff451cc0 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -149,7 +149,7 @@ public class OSXUtil implements ToolkitProperties { } /** - * Attach a sub CALayer to the root CALayer on the main-thread. + * Attach a sub CALayer to the root CALayer on the main-thread w/ blocking. * <p> * Method will trigger a <code>display</code> * call to the CALayer hierarchy to enforce resource creation if required, e.g. an NSOpenGLContext. @@ -173,7 +173,30 @@ public class OSXUtil implements ToolkitProperties { } /** - * Detach a sub CALayer from the root CALayer on the main-thread. + * Fix root and sub CALayer position to 0/0 on the main-thread w/o blocking. + * <p> + * For an unknown reason, on OSX/Java7 our root CALayer's frame position gets corrupted + * and is moved out of 'sight' .. or oddly half way to the upper right corner. + * </p> + * + * @param rootCALayer the root surface layer, maybe null. + * @param subCALayer the client surface layer, maybe null. + * @param width the expected width + * @param height the expected height + */ + public static void FixCALayerPosition(final long rootCALayer, final long subCALayer, final int width, final int height) { + if( 0==rootCALayer && 0==subCALayer ) { + return; + } + RunOnMainThread(false, new Runnable() { + public void run() { + FixCALayerPosition0(rootCALayer, subCALayer, width, height); + } + }); + } + + /** + * Detach a sub CALayer from the root CALayer on the main-thread w/ blocking. */ public static void RemoveCASublayer(final long rootCALayer, final long subCALayer) { if(0==rootCALayer || 0==subCALayer) { @@ -186,7 +209,7 @@ public class OSXUtil implements ToolkitProperties { } /** - * Destroy a CALayer on the main-thread. + * Destroy a CALayer on the main-thread w/ blocking. * @see #CreateCALayer(int, int, int, int) */ public static void DestroyCALayer(final long caLayer) { @@ -323,6 +346,7 @@ public class OSXUtil implements ToolkitProperties { private static native long GetNSWindow0(long nsView); private static native long CreateCALayer0(int x, int y, int width, int height); private static native void AddCASublayer0(long rootCALayer, long subCALayer); + private static native void FixCALayerPosition0(long rootCALayer, long subCALayer, int width, int height); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); private static native void DestroyCALayer0(long caLayer); private static native void RunOnMainThread0(Runnable runnable); |