diff options
Diffstat (limited to 'src/nativewindow')
4 files changed, 42 insertions, 24 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 99b629d1a..3e5e629b6 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -43,6 +43,8 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration; import java.awt.Component; import java.awt.Container; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; import java.applet.Applet; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -110,6 +112,25 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, this.component = windowObject; this.isApplet = false; this.offscreenSurfaceLayer = 0; + this.component.addComponentListener(new ComponentListener() { + @Override + public void componentResized(ComponentEvent e) { + layoutSurfaceLayerIfEnabled(); + } + + @Override + public void componentMoved(ComponentEvent e) { + layoutSurfaceLayerIfEnabled(); + } + + @Override + public void componentShown(ComponentEvent e) { + layoutSurfaceLayerIfEnabled(); + } + + @Override + public void componentHidden(ComponentEvent e) { } + }); } protected synchronized void invalidate() { @@ -215,16 +236,27 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } protected abstract void attachSurfaceLayerImpl(final long layerHandle); - @Override - public void layoutSurfaceLayer() throws NativeWindowException { - if( !isOffscreenLayerSurfaceEnabled() ) { - throw new NativeWindowException("Not an offscreen layer surface"); - } - if( 0 != offscreenSurfaceLayer) { + /** + * Layout the offscreen layer according to the implementing class's constraints. + * <p> + * This method allows triggering a re-layout of the offscreen surface + * in case the implementation requires it. + * </p> + * <p> + * Call this method if any parent or ancestor's layout has been changed, + * which could affects the layout of this surface. + * </p> + * @see #isOffscreenLayerSurfaceEnabled() + * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false + */ + protected void layoutSurfaceLayerImpl() {} + + private final void layoutSurfaceLayerIfEnabled() throws NativeWindowException { + if( isOffscreenLayerSurfaceEnabled() && 0 != offscreenSurfaceLayer ) { layoutSurfaceLayerImpl(); } } - protected void layoutSurfaceLayerImpl() {} + @Override public final void detachSurfaceLayer() throws NativeWindowException { diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index df3f04f7f..8c02a68bb 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -42,21 +42,6 @@ public interface OffscreenLayerSurface { */ public void attachSurfaceLayer(final long layerHandle) throws NativeWindowException; - /** - * Layout the offscreen layer according to the implementing class's constraints. - * <p> - * This method allows triggering a re-layout of the offscreen surface - * in case the implementation requires it. - * </p> - * <p> - * Call this method if any parent or ancestor's layout has been changed, - * which could affects the layout of this surface. - * </p> - * @see #isOffscreenLayerSurfaceEnabled() - * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false - */ - public void layoutSurfaceLayer() throws NativeWindowException; - /** * Detaches a previously attached offscreen layer from this offscreen layer surface. * @see #attachSurfaceLayer(long) diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index c8f758165..758105713 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -117,7 +117,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } protected void attachSurfaceLayerImpl(final long layerHandle) { - OSXUtil.AddCASublayer(rootSurfaceLayerHandle, layerHandle); + OSXUtil.AddCASublayer(rootSurfaceLayerHandle, layerHandle, getWidth(), getHeight()); } protected void layoutSurfaceLayerImpl() { diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 59b42c249..1563a5a8b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -158,13 +158,14 @@ public class OSXUtil implements ToolkitProperties { * @see #CreateCALayer(int, int, int, int) * @see #RemoveCASublayer(long, long) */ - public static void AddCASublayer(final long rootCALayer, final long subCALayer) { + public static void AddCASublayer(final long rootCALayer, final long subCALayer, final int width, final int height) { if(0==rootCALayer || 0==subCALayer) { throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer)); } RunOnMainThread(false, new Runnable() { public void run() { AddCASublayer0(rootCALayer, subCALayer); + FixCALayerLayout0(rootCALayer, subCALayer, width, height); } }); } |