summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java21
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java47
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java7
-rw-r--r--src/nativewindow/native/macosx/OSXmisc.m22
4 files changed, 57 insertions, 40 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index 53eb985b2..d9f36901b 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -115,23 +115,28 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
this.isApplet = false;
this.offscreenSurfaceLayer = 0;
this.component.addComponentListener(new ComponentListener() {
+ private boolean visible = component.isVisible();
@Override
public void componentResized(ComponentEvent e) {
- layoutSurfaceLayerIfEnabled();
+ layoutSurfaceLayerIfEnabled(visible);
}
@Override
public void componentMoved(ComponentEvent e) {
- layoutSurfaceLayerIfEnabled();
+ layoutSurfaceLayerIfEnabled(visible);
}
@Override
public void componentShown(ComponentEvent e) {
- layoutSurfaceLayerIfEnabled();
+ visible = true;
+ layoutSurfaceLayerIfEnabled(visible);
}
@Override
- public void componentHidden(ComponentEvent e) { }
+ public void componentHidden(ComponentEvent e) {
+ visible = false;
+ layoutSurfaceLayerIfEnabled(visible);
+ }
});
}
@@ -247,14 +252,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
* Call this method if any parent or ancestor's layout has been changed,
* which could affects the layout of this surface.
* </p>
- * @see #isOffscreenLayerSurfaceEnabled()
+ * @see #isOffscreenLayerSurfaceEnabled()
* @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false
*/
- protected void layoutSurfaceLayerImpl(long layerHandle) {}
+ protected void layoutSurfaceLayerImpl(long layerHandle, boolean visible) {}
- private final void layoutSurfaceLayerIfEnabled() throws NativeWindowException {
+ private final void layoutSurfaceLayerIfEnabled(boolean visible) throws NativeWindowException {
if( isOffscreenLayerSurfaceEnabled() && 0 != offscreenSurfaceLayer ) {
- layoutSurfaceLayerImpl(offscreenSurfaceLayer);
+ layoutSurfaceLayerImpl(offscreenSurfaceLayer, visible);
}
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
index 2eff1bc09..b712f6a1a 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
@@ -135,34 +135,33 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
}
@Override
- protected void layoutSurfaceLayerImpl(long layerHandle) {
+ protected void layoutSurfaceLayerImpl(long layerHandle, boolean visible) {
final int caLayerQuirks = JAWTUtil.getOSXCALayerQuirks();
- if( 0 != caLayerQuirks ) {
- // 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 detailed description in {@link JAWTUtil#JAWT_OSX_CALAYER_QUIRK_LAYOUT}
- final Point p0 = new Point();
- final Component outterComp = getLocationOnScreenNonBlocking(p0, component);
- final java.awt.Insets outterInsets = AWTMisc.getInsets(outterComp, true);
- final Point p1 = (Point)p0.cloneMutable();
- p1.translate(-outterComp.getX(), -outterComp.getY());
+ // 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 detailed description in {@link JAWTUtil#JAWT_OSX_CALAYER_QUIRK_LAYOUT}
+ final Point p0 = new Point();
+ final Component outterComp = getLocationOnScreenNonBlocking(p0, component);
+ final java.awt.Insets outterInsets = AWTMisc.getInsets(outterComp, true);
+ final Point p1 = (Point)p0.cloneMutable();
+ p1.translate(-outterComp.getX(), -outterComp.getY());
+ if( null != outterInsets ) {
+ p1.translate(-outterInsets.left, -outterInsets.top);
+ }
+
+ if( DEBUG ) {
+ final java.awt.Point pA0 = component.getLocationOnScreen();
+ final Point pA1 = new Point(pA0.x, pA0.y);
+ pA1.translate(-outterComp.getX(), -outterComp.getY());
if( null != outterInsets ) {
- p1.translate(-outterInsets.left, -outterInsets.top);
- }
-
- if( DEBUG ) {
- final java.awt.Point pA0 = component.getLocationOnScreen();
- final Point pA1 = new Point(pA0.x, pA0.y);
- pA1.translate(-outterComp.getX(), -outterComp.getY());
- if( null != outterInsets ) {
- pA1.translate(-outterInsets.left, -outterInsets.top);
- }
- System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(layerHandle) + ", [ins "+outterInsets+"], pA "+pA0+" -> "+pA1+
- ", p0 "+p0+" -> "+p1+", bounds "+bounds);
+ pA1.translate(-outterInsets.left, -outterInsets.top);
}
- OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, p1.getX(), p1.getY(), getWidth(), getHeight(), caLayerQuirks);
+ System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(layerHandle) + ", quirks "+caLayerQuirks+", visible "+visible+
+ ", [ins "+outterInsets+"], pA "+pA0+" -> "+pA1+
+ ", p0 "+p0+" -> "+p1+", bounds "+bounds);
}
+ OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, visible, p1.getX(), p1.getY(), getWidth(), getHeight(), caLayerQuirks);
}
@Override
diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
index 2112131ed..b27affa7e 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
@@ -186,15 +186,16 @@ public class OSXUtil implements ToolkitProperties {
*
* @param rootCALayer the root surface layer, maybe null.
* @param subCALayer the client surface layer, maybe null.
+ * @param visible TODO
* @param width the expected width
* @param height the expected height
* @param caLayerQuirks TODO
*/
- public static void FixCALayerLayout(final long rootCALayer, final long subCALayer, final int x, final int y, final int width, final int height, final int caLayerQuirks) {
+ public static void FixCALayerLayout(final long rootCALayer, final long subCALayer, final boolean visible, final int x, final int y, final int width, final int height, final int caLayerQuirks) {
if( 0==rootCALayer && 0==subCALayer ) {
return;
}
- FixCALayerLayout0(rootCALayer, subCALayer, x, y, width, height, caLayerQuirks);
+ FixCALayerLayout0(rootCALayer, subCALayer, visible, x, y, width, height, caLayerQuirks);
}
/**
@@ -358,7 +359,7 @@ public class OSXUtil implements ToolkitProperties {
private static native long GetNSWindow0(long nsView);
private static native long CreateCALayer0(int width, int height);
private static native void AddCASublayer0(long rootCALayer, long subCALayer, int x, int y, int width, int height, int caLayerQuirks);
- private static native void FixCALayerLayout0(long rootCALayer, long subCALayer, int x, int y, int width, int height, int caLayerQuirks);
+ private static native void FixCALayerLayout0(long rootCALayer, long subCALayer, boolean visible, int x, int y, int width, int height, int caLayerQuirks);
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/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index e3844455a..889e1efd3 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -346,7 +346,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0
- (id<CAAction>)actionForKey:(NSString *)key ;
- (void)layoutSublayers;
- (void)setFrame:(CGRect) frame;
-- (void)fixCALayerLayout: (CALayer*) subLayer x:(jint)x y:(jint)y width:(jint)width height:(jint)height caLayerQuirks:(jint)caLayerQuirks force:(jboolean) force;
+- (void)fixCALayerLayout: (CALayer*) subLayer visible:(BOOL)visible x:(jint)x y:(jint)y width:(jint)width height:(jint)height caLayerQuirks:(jint)caLayerQuirks force:(jboolean) force;
@end
@@ -449,13 +449,25 @@ 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
+- (void)fixCALayerLayout: (CALayer*) subLayer visible:(BOOL)visible 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];
+ if( visible ) {
+ // Setting opacity should not be required, otherwise we should save the opacity value.
+ // [subLayer setOpacity: 1.0];
+ // [self setOpacity: 1.0];
+ [self setHidden: NO];
+ [subLayer setHidden: NO];
+ } else {
+ [subLayer setHidden: YES];
+ [self setHidden: YES];
+ // [subLayer setOpacity: 0.0];
+ // [self setOpacity: 0.0];
+ }
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 || loutQuirk ) {
@@ -596,7 +608,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0
[subLayer setNeedsDisplayOnBoundsChange: YES];
if( 0 != caLayerQuirks ) {
- [rootLayer fixCALayerLayout: subLayer x:x y:y width:width height:height caLayerQuirks:caLayerQuirks force:JNI_TRUE];
+ [rootLayer fixCALayerLayout: subLayer visible:1 x:x y:y width:width height:height caLayerQuirks:caLayerQuirks force:JNI_TRUE];
}
[CATransaction commit];
@@ -612,7 +624,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0
* Signature: (JJIII)V
*/
JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_FixCALayerLayout0
- (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint x, jint y, jint width, jint height, jint caLayerQuirks)
+ (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jboolean visible, jint x, jint y, jint width, jint height, jint caLayerQuirks)
{
if( 0 != caLayerQuirks ) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -625,7 +637,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_FixCALayerLayout0
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
- [rootLayer fixCALayerLayout: subLayer x:x y:y width:width height:height caLayerQuirks:caLayerQuirks force:JNI_FALSE];
+ [rootLayer fixCALayerLayout: subLayer visible:(BOOL)visible x:x y:y width:width height:height caLayerQuirks:caLayerQuirks force:JNI_FALSE];
[CATransaction commit];