summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-10-05 13:44:43 +0200
committerSven Gothel <[email protected]>2013-10-05 13:44:43 +0200
commit3b02a219b1b9e446e87df1beb7da4266f74824fa (patch)
tree3d8f55bbaeb8deeb666fd7735141f5f6afbbe68e /src/nativewindow/classes
parent61e47c5683ef038d8684bce56714ae0a514dd697 (diff)
Bug 729: OSX CALayer shall honor the Component's visibility state
A once visible CALayer (GLCanvas) must be able to become invisible w/o destruction, e.g. as required by CardLayout's switching cards. See unit test for Bug 532: 'TestAWTCardLayoutAnimatorStartStopBug532' Out native 'fixCALayerLayout(..)' takes the visible state as tracked by JAWTWindow's ComponentListener and sets our CALayer (root and sub) hidden state accordingly. Now MacOSXJAWTWindow's layoutSurfaceLayerImpl(..) always calls down to 'fixCALayerLayout(..)' due to update the visibility state.
Diffstat (limited to 'src/nativewindow/classes')
-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
3 files changed, 40 insertions, 35 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);