summaryrefslogtreecommitdiffstats
path: root/src/nativewindow
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-09-28 00:20:50 +0200
committerSven Gothel <[email protected]>2013-09-28 00:20:50 +0200
commita2a057406ff5d21499860e8fef6ba88f07d9bf95 (patch)
tree8d226729f2f4b8be2527635f84fdc5c051c4e5e3 /src/nativewindow
parentebb62e74f9e0dc87d7632cf16ca1bc7554ffcadc (diff)
Bug 816: Clarify JAWT_OSX_CALAYER_QUIRK_* semantics, add JAWT_OSX_CALAYER_QUIRK_LAYOUT
Diffstat (limited to 'src/nativewindow')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java49
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java2
-rw-r--r--src/nativewindow/native/macosx/NativeWindowProtocols.h7
-rw-r--r--src/nativewindow/native/macosx/OSXmisc.m15
4 files changed, 58 insertions, 15 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
index b663f90b7..b20007d53 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
@@ -113,11 +113,12 @@ public class JAWTUtil {
/**
* CALayer size needs to be set using the AWT component size.
* <p>
- * As of today, we have to overwrite the CALayer size
- * w/ the AWT component one since programmatic resize leads to differences.
+ * AWT's super-calayer, i.e. the AWT's own component CALayer,
+ * does not layout our root-calayer in respect to this component's
+ * position and size, at least when resizing programmatically.
* </p>
* <p>
- * Hence this flag is always enabled.
+ * As of today, this flag is enabled for all known AWT versions.
* </p>
* <p>
* Sync w/ NativeWindowProtocols.h
@@ -128,17 +129,18 @@ public class JAWTUtil {
/**
* CALayer position needs to be set to zero.
* <p>
- * Normally we have to set the root-calayer's position to 0/0
- * and leave client-calayer's position in it's desired place.
- * With pre AWT 1.7.0_40, the client-calayer's position has to
- * be set to zero as well.
+ * AWT's super-calayer, i.e. the AWT's own component CALayer,
+ * has a broken layout and needs it's sub-layers to be located at position 0/0.
+ * </p>
+ * <p>
+ * See <code>http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7172187</code>.
* </p>
* <p>
* Further more a re-layout seems to be required in this case,
* i.e. a programmatic forced resize +1 and it's inverted resize -1.
* </p>
* <p>
- * Hence this flag is enabled w/ AWT < 1.7.0_40.
+ * This flag is enabled w/ AWT < 1.7.0_40.
* </p>
* <p>
* Sync w/ NativeWindowProtocols.h
@@ -146,6 +148,34 @@ public class JAWTUtil {
*/
public static final int JAWT_OSX_CALAYER_QUIRK_POSITION = 1 << 1;
+ /**
+ * CALayer position needs to be derived from AWT position
+ * in relation to super CALayer.
+ * <p>
+ * AWT's super-calayer, i.e. the AWT's own component CALayer,
+ * does not layout our root-calayer in respect to this component's
+ * position and size, at least when resizing programmatically.
+ * </p>
+ * <p>
+ * CALayer position has origin 0/0 at bottom/left,
+ * where AWT component has origin 0/0 at top/left.
+ * </p>
+ * <p>
+ * The super-calayer bounds exclude the frame's heavyweight border/insets.
+ * </p>
+ * <p>
+ * This flags also sets {@link #JAWT_OSX_CALAYER_QUIRK_SIZE},
+ * i.e. they are related.
+ * </p>
+ * <p>
+ * As of today, this flag is enabled for w/ AWT >= 1.7.0_40.
+ * </p>
+ * <p>
+ * Sync w/ NativeWindowProtocols.h
+ * </p>
+ */
+ public static final int JAWT_OSX_CALAYER_QUIRK_LAYOUT = 1 << 2;
+
/**
* Returns bitfield of required JAWT OSX CALayer quirks to mediate AWT impl. bugs.
* <p>
@@ -157,6 +187,7 @@ public class JAWTUtil {
* <ul>
* <li>{@link #JAWT_OSX_CALAYER_QUIRK_SIZE} (always)</li>
* <li>{@link #JAWT_OSX_CALAYER_QUIRK_POSITION} if JVM < 1.7.0_40</li>
+ * <li>{@link #JAWT_OSX_CALAYER_QUIRK_LAYOUT} if JVM >= 1.7.0_40</li>
* </ul>
* </p>
*/
@@ -171,6 +202,8 @@ public class JAWTUtil {
final int c = Platform.JAVA_VERSION_NUMBER.compareTo(Platform.Version17);
if( c < 0 || c == 0 && Platform.JAVA_VERSION_UPDATE < 40 ) {
res |= JAWT_OSX_CALAYER_QUIRK_POSITION;
+ } else {
+ res |= JAWT_OSX_CALAYER_QUIRK_LAYOUT;
}
}
return res;
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
index 6d08078b6..0d81274ca 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
@@ -110,6 +110,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
// AWT position is top-left w/ insets, where CALayer position is bottom/left from root CALayer w/o insets.
// Determine p0: components location on screen w/o insets.
// CALayer position will be determined in native code.
+ // See: {@link JAWTWindow#JAWT_OSX_CALAYER_QUIRK_LAYOUT}
final Point p0 = new Point();
final Component outterComp = getLocationOnScreenNonBlocking(p0, component);
final java.awt.Insets ins = AWTMisc.getInsets(outterComp);
@@ -131,6 +132,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
// AWT position is top-left w/ insets, where CALayer position is bottom/left from root CALayer w/o insets.
// Determine p0: components location on screen w/o insets.
// CALayer position will be determined in native code.
+ // See: {@link JAWTWindow#JAWT_OSX_CALAYER_QUIRK_LAYOUT}
final Point p0 = new Point();
final Component outterComp = getLocationOnScreenNonBlocking(p0, component);
final java.awt.Insets ins = AWTMisc.getInsets(outterComp);
diff --git a/src/nativewindow/native/macosx/NativeWindowProtocols.h b/src/nativewindow/native/macosx/NativeWindowProtocols.h
index 73c8e65c5..98e864f8b 100644
--- a/src/nativewindow/native/macosx/NativeWindowProtocols.h
+++ b/src/nativewindow/native/macosx/NativeWindowProtocols.h
@@ -41,6 +41,13 @@
*/
#define NW_DEDICATEDFRAME_QUIRK_POSITION ( 1 << 1 )
+/**
+ * CALayer position needs to be derived from AWT position.
+ * in relation to super CALayer.
+ * See detailed description in JAWTUtil.java and sync w/ changed.
+ */
+#define NW_DEDICATEDFRAME_QUIRK_LAYOUT ( 1 << 2 )
+
#import <Foundation/NSGeometry.h>
@protocol NWDedicatedFrame
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index fa40c871f..e3844455a 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -451,13 +451,14 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0
- (void)fixCALayerLayout: (CALayer*) subLayer x:(jint)x y:(jint)y width:(jint)width height:(jint)height caLayerQuirks:(jint)caLayerQuirks force:(jboolean) force
{
+ int loutQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_LAYOUT & caLayerQuirks );
{
CALayer* superLayer = [self superlayer];
CGRect superFrame = [superLayer frame];
CGRect lFrame = [self frame];
int posQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & caLayerQuirks ) && ( lFrame.origin.x!=0 || lFrame.origin.y!=0 );
int sizeQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & caLayerQuirks ) && ( lFrame.size.width!=width || lFrame.size.height!=height );
- if( !posQuirk ) {
+ if( !posQuirk || loutQuirk ) {
// Use root layer position, sub-layer will be on 0/0,
// Given AWT position is location on screen w/o insets and top/left origin!
fixedFrame.origin.x = x;
@@ -475,12 +476,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0
fixedFrame.size.width = width;
fixedFrame.size.height = height;
}
- DBG_PRINT("CALayer::FixCALayerLayout0.0: Quirks [%d, pos %d, size %d], Super %p frame %lf/%lf %lfx%lf, Root %p frame %lf/%lf %lfx%lf, usr %d/%d %dx%d -> %lf/%lf %lfx%lf\n",
- caLayerQuirks, posQuirk, sizeQuirk,
+ DBG_PRINT("CALayer::FixCALayerLayout0.0: Quirks [%d, pos %d, size %d, lout %d], Super %p frame %lf/%lf %lfx%lf, Root %p frame %lf/%lf %lfx%lf, usr %d/%d %dx%d -> %lf/%lf %lfx%lf\n",
+ caLayerQuirks, posQuirk, sizeQuirk, loutQuirk,
superLayer, superFrame.origin.x, superFrame.origin.y, superFrame.size.width, superFrame.size.height,
self, lFrame.origin.x, lFrame.origin.y, lFrame.size.width, lFrame.size.height,
x, y, width, height, fixedFrame.origin.x, fixedFrame.origin.y, fixedFrame.size.width, fixedFrame.size.height);
- if( posQuirk || sizeQuirk ) {
+ if( posQuirk || sizeQuirk || loutQuirk ) {
fixedFrameSet = 1;
[super setFrame: fixedFrame];
}
@@ -501,10 +502,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0
_w = width;
_h = height;
}
- DBG_PRINT("CALayer::FixCALayerLayout1.0: Quirks [%d, pos %d, size %d], SubL %p frame %lf/%lf %lfx%lf, usr %dx%d -> %lf/%lf %lfx%lf\n",
- caLayerQuirks, posQuirk, sizeQuirk, subLayer, lFrame.origin.x, lFrame.origin.y, lFrame.size.width, lFrame.size.height,
+ DBG_PRINT("CALayer::FixCALayerLayout1.0: Quirks [%d, pos %d, size %d, lout %d], SubL %p frame %lf/%lf %lfx%lf, usr %dx%d -> %lf/%lf %lfx%lf\n",
+ caLayerQuirks, posQuirk, sizeQuirk, loutQuirk, subLayer, lFrame.origin.x, lFrame.origin.y, lFrame.size.width, lFrame.size.height,
width, height, _x, _y, _w, _h);
- if( force || posQuirk || sizeQuirk ) {
+ if( force || posQuirk || sizeQuirk || loutQuirk ) {
lFrame.origin.x = _x;
lFrame.origin.y = _y;
lFrame.size.width = _w;