From 3b02a219b1b9e446e87df1beb7da4266f74824fa Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 5 Oct 2013 13:44:43 +0200 Subject: 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. --- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/nativewindow/classes/com/jogamp') 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. *

- * @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); } } -- cgit v1.2.3