summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow/classes')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java18
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java9
2 files changed, 22 insertions, 5 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index cffe495f7..d4b927cf1 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -81,6 +81,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
protected long drawable;
protected Rectangle bounds;
protected Insets insets;
+ private long offscreenSurfaceLayer;
private long drawable_old;
@@ -106,6 +107,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
invalidate();
this.component = windowObject;
this.isApplet = false;
+ this.offscreenSurfaceLayer = 0;
}
@Override
@@ -196,6 +198,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
System.err.println("JAWTWindow.attachSurfaceHandle(): 0x"+Long.toHexString(layerHandle) + ", bounds "+bounds);
}
attachSurfaceLayerImpl(layerHandle);
+ offscreenSurfaceLayer = layerHandle;
} finally {
unlockSurface();
}
@@ -206,25 +209,34 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
* {@inheritDoc}
*/
@Override
- public final void detachSurfaceLayer(final long layerHandle) throws NativeWindowException {
+ public final void detachSurfaceLayer() throws NativeWindowException {
if( !isOffscreenLayerSurfaceEnabled() ) {
throw new java.lang.UnsupportedOperationException("Not an offscreen layer surface");
}
+ if( 0 == offscreenSurfaceLayer) {
+ throw new NativeWindowException("No offscreen layer attached: "+this);
+ }
int lockRes = lockSurface();
if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
throw new NativeWindowException("Could not lock (offscreen layer): "+this);
}
try {
if(DEBUG) {
- System.err.println("JAWTWindow.detachSurfaceHandle(): 0x"+Long.toHexString(layerHandle));
+ System.err.println("JAWTWindow.detachSurfaceHandle(): 0x"+Long.toHexString(offscreenSurfaceLayer));
}
- detachSurfaceLayerImpl(layerHandle);
+ detachSurfaceLayerImpl(offscreenSurfaceLayer);
+ offscreenSurfaceLayer = 0;
} finally {
unlockSurface();
}
}
protected abstract void detachSurfaceLayerImpl(final long layerHandle);
+ @Override
+ public final boolean isSurfaceLayerAttached() {
+ return 0 != offscreenSurfaceLayer;
+ }
+
//
// SurfaceUpdateListener
//
diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java
index dd36509ba..f7dbc6c27 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java
@@ -42,7 +42,12 @@ public interface OffscreenLayerSurface {
* Detaches a previously attached offscreen layer from this offscreen layer surface.
* @see #attachSurfaceLayer(long)
* @see #isOffscreenLayerSurfaceEnabled()
- * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false
+ * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false
+ * or no surface layer is attached.
*/
- public void detachSurfaceLayer(final long layerHandle) throws NativeWindowException;
+ public void detachSurfaceLayer() throws NativeWindowException;
+
+ /** Returns true if a surface layer is attached, otherwise false. */
+ public boolean isSurfaceLayerAttached();
+
}