summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java11
-rw-r--r--src/newt/classes/jogamp/newt/awt/event/NewtFactoryAWT.java11
2 files changed, 21 insertions, 1 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
index c8ce13b40..41f79c98f 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
@@ -102,6 +102,16 @@ public abstract class JAWTWindow implements NativeWindow {
}
validateNative();
}
+
+ /**
+ * Implementors shall ensure that all native handles are valid, eg. the {@link javax.media.nativewindow.awt.AWTGraphicsDevice AWTGraphicsDevice}'s
+ * subtype via {@link javax.media.nativewindow.awt.AWTGraphicsDevice#setSubType(String, long) awtGraphicsDevice.setSubType(NativeWindowFactory.TYPE_X11, displayHandle)}.
+ * <p>
+ * This method may be called several times,
+ * hence the implementation shall check for valid values 1st and bail out early if satisfied.
+ * </p>
+ * @throws NativeWindowException
+ */
protected abstract void validateNative() throws NativeWindowException;
protected synchronized void invalidate() {
@@ -164,6 +174,7 @@ public abstract class JAWTWindow implements NativeWindow {
protected abstract int lockSurfaceImpl() throws NativeWindowException;
public final int lockSurface() throws NativeWindowException {
+ validateNative();
surfaceLock.lock();
int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ?
diff --git a/src/newt/classes/jogamp/newt/awt/event/NewtFactoryAWT.java b/src/newt/classes/jogamp/newt/awt/event/NewtFactoryAWT.java
index 1d11887fb..9b812d22a 100644
--- a/src/newt/classes/jogamp/newt/awt/event/NewtFactoryAWT.java
+++ b/src/newt/classes/jogamp/newt/awt/event/NewtFactoryAWT.java
@@ -76,10 +76,19 @@ public class NewtFactoryAWT extends NewtFactory {
if(! ( nw instanceof JAWTWindow ) ) {
throw new NativeWindowException("Not an AWT NativeWindow: "+nw);
}
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("NewtFactoryAWT.updateGraphicsConfiguration: (pre) "+awtComp+" -> "+nw);
+ }
final AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration) nw.getGraphicsConfiguration();
awtConfig.updateGraphicsConfiguration(awtComp);
+ // lockSurface() re-issues JAWTWindow's native validation
+ if( NativeSurface.LOCK_SURFACE_NOT_READY >= nw.lockSurface() ) {
+ throw new NativeWindowException("could not lock "+nw);
+ }
+ nw.unlockSurface();
+
if(DEBUG_IMPLEMENTATION) {
- System.err.println("NewtFactoryAWT.updateGraphicsConfiguration: "+awtComp+" -> "+nw);
+ System.err.println("NewtFactoryAWT.updateGraphicsConfiguration: (post) "+awtComp+" -> "+nw);
}
}