aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java16
-rw-r--r--src/nativewindow/native/macosx/NativeWindowProtocols.h34
-rw-r--r--src/nativewindow/native/macosx/OSXmisc.m33
4 files changed, 65 insertions, 20 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
index b25836d3c..3ec54ca78 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
@@ -125,7 +125,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
if(DEBUG) {
System.err.println("JAWTWindow.fixSurfaceLayerLayout: "+toHexString(osl) + ", bounds "+bounds+", "+w+"x"+h);
}
- OSXUtil.FixCALayerPosition(rootSurfaceLayerHandle, osl, w, h);
+ OSXUtil.FixCALayerLayout(rootSurfaceLayerHandle, osl, w, h);
}
protected void detachSurfaceLayerImpl(final long layerHandle) {
diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
index 5ff451cc0..aa44e2d64 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
@@ -173,10 +173,14 @@ public class OSXUtil implements ToolkitProperties {
}
/**
- * Fix root and sub CALayer position to 0/0 on the main-thread w/o blocking.
+ * Fix root and sub CALayer position to 0/0 and size 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.
+ * If the sub CALayer implements the Objective-C NativeWindow protocol NWDedicatedSize (e.g. JOGL's MyNSOpenGLLayer),
+ * the dedicated size is passed to the layer, which propagates it appropriately.
+ * </p>
+ * <p>
+ * On OSX/Java7 our root CALayer's frame position and size gets corrupted by its NSView,
+ * hence we have created the NWDedicatedSize protocol.
* </p>
*
* @param rootCALayer the root surface layer, maybe null.
@@ -184,13 +188,13 @@ public class OSXUtil implements ToolkitProperties {
* @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) {
+ public static void FixCALayerLayout(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);
+ FixCALayerLayout0(rootCALayer, subCALayer, width, height);
}
});
}
@@ -346,7 +350,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 FixCALayerLayout0(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);
diff --git a/src/nativewindow/native/macosx/NativeWindowProtocols.h b/src/nativewindow/native/macosx/NativeWindowProtocols.h
new file mode 100644
index 000000000..b91a50dfd
--- /dev/null
+++ b/src/nativewindow/native/macosx/NativeWindowProtocols.h
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2013 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+#import <Foundation/NSGeometry.h>
+
+@protocol NWDedicatedSize
+- (void)setDedicatedSize:(CGSize)size;
+@end
+
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index 28e63e875..c74d6cc58 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -33,6 +33,7 @@
#include <unistd.h>
#include <AppKit/AppKit.h>
#import <QuartzCore/QuartzCore.h>
+#import "NativeWindowProtocols.h"
#include "NativewindowCommon.h"
#include "jogamp_nativewindow_macosx_OSXUtil.h"
@@ -335,6 +336,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0
- (oneway void)release;
- (void)dealloc;
#endif
+- (id<CAAction>)actionForKey:(NSString *)key ;
@end
@@ -378,6 +380,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0
#endif
+- (id<CAAction>)actionForKey:(NSString *)key
+{
+ DBG_PRINT("MyCALayer::actionForKey.0 %p key %s -> NIL\n", self, [key UTF8String]);
+ return nil;
+ // return [super actionForKey: key];
+}
@end
@@ -478,10 +486,10 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0
/*
* Class: Java_jogamp_nativewindow_macosx_OSXUtil
- * Method: FixCALayerPosition0
+ * Method: FixCALayerLayout0
* Signature: (JJII)V
*/
-JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_FixCALayerPosition0
+JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_FixCALayerLayout0
(JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint width, jint height)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -493,38 +501,37 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_FixCALayerPositio
if( NULL != rootLayer ) {
CGRect lRect = [rootLayer frame];
- DBG_PRINT("CALayer::FixCALayerPosition0.0: Root Origin %p exp 0/0 %dx%d frame0: %lf/%lf %lfx%lf\n",
- rootLayer, width, height, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height);
if(lRect.origin.x!=0 || lRect.origin.y!=0 || lRect.size.width!=width || lRect.size.height!=height) {
+ DBG_PRINT("CALayer::FixCALayerLayout0.0: Root %p exp 0/0 %dx%d -> frame0: %lf/%lf %lfx%lf\n",
+ rootLayer, (int)width, (int)height, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height);
lRect.origin.x = 0;
lRect.origin.y = 0;
lRect.size.width = width;
lRect.size.height = height;
[rootLayer setFrame: lRect];
- DBG_PRINT("CALayer::FixCALayerPosition0.1: Root Origin %p frame*: %lf/%lf %lfx%lf\n",
- rootLayer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height);
}
}
if( NULL != subLayer ) {
CGRect lRect = [subLayer frame];
- DBG_PRINT("CALayer::FixCALayerPosition0.0: SubL %p exp 0/0 %dx%d frame0: %lf/%lf %lfx%lf\n",
- subLayer, width, height, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height);
if(lRect.origin.x!=0 || lRect.origin.y!=0 || lRect.size.width!=width || lRect.size.height!=height) {
+ DBG_PRINT("CALayer::FixCALayerLayout0.0: SubL %p exp 0/0 %dx%d -> frame0: %lf/%lf %lfx%lf\n",
+ subLayer, (int)width, (int)height, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height);
lRect.origin.x = 0;
lRect.origin.y = 0;
lRect.size.width = width;
lRect.size.height = height;
- [subLayer setFrame: lRect];
- DBG_PRINT("CALayer::FixCALayerPosition0.1: SubL Origin %p frame*: %lf/%lf %lfx%lf\n",
- subLayer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height);
+ if( [subLayer conformsToProtocol:@protocol(NWDedicatedSize)] ) {
+ CALayer <NWDedicatedSize> * subLayerDS = (CALayer <NWDedicatedSize> *) subLayer;
+ [subLayerDS setDedicatedSize: lRect.size];
+ } else {
+ [subLayer setFrame: lRect];
+ }
}
}
[CATransaction commit];
[pool release];
- DBG_PRINT("CALayer::FixCALayerPosition0.X: root %p (refcnt %d) .sub %p (refcnt %d)\n",
- rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]);
}
/*