aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-06-27 05:05:36 +0200
committerSven Gothel <[email protected]>2012-06-27 05:05:36 +0200
commita06e40cce89615eb8c4b080842997c9c3ad1130b (patch)
tree0bac563f3604662f8583b4f0da21b68ac53abd28 /src
parent4a0a5d69ffcb7592b092991ddb3761653c389ce6 (diff)
NativeSurface Cleanup (API Change) - Adapt to GlueGen Lock cleanup commit: 834b9e530e652b7ff7c5e222720bce3ad2b11c5f
- adapt to GlueGen Lock cleanup - remove isSurfaceLocked(), use 'null != getSurfaceLockOwner()' instead Misc: - remove unused priv./impl. methods - add @Override
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java6
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableImpl.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/GLPbufferImpl.java4
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java139
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java15
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java34
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java8
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java34
8 files changed, 134 insertions, 110 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 51201b3a9..ff1b65520 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -164,7 +164,7 @@ public abstract class GLContextImpl extends GLContext {
if(null!=read && drawable!=read && !isGLReadDrawableAvailable()) {
throw new GLException("GL Read Drawable not available");
}
- boolean lockHeld = lock.isOwner();
+ final boolean lockHeld = lock.isOwner(Thread.currentThread());
if(lockHeld) {
release();
}
@@ -224,8 +224,8 @@ public abstract class GLContextImpl extends GLContext {
if(TRACE_SWITCH) {
System.err.println(getThreadName() +": GLContext.ContextSwitch: - release() - force: "+force+", "+lock);
}
- if ( !lock.isOwner() ) {
- throw new GLException("Context not current on current thread "+Thread.currentThread().getName()+": "+this);
+ if ( !lock.isOwner(Thread.currentThread()) ) {
+ throw new GLException("Context not current on current thread "+Thread.currentThread().getName()+": "+this);
}
final boolean actualRelease = force || lock.getHoldCount() == 1 ;
try {
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
index 36f17e5a1..71624789d 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
@@ -199,10 +199,6 @@ public abstract class GLDrawableImpl implements GLDrawable {
surface.unlockSurface();
}
- public boolean isSurfaceLocked() {
- return surface.isSurfaceLocked();
- }
-
public String toString() {
return getClass().getSimpleName()+"[Realized "+isRealized()+
",\n\tFactory "+getFactory()+
diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
index 0f4f7f8e2..9a4cf1f94 100644
--- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
@@ -267,10 +267,6 @@ public class GLPbufferImpl implements GLPbuffer {
recurLock.unlock();
}
- public boolean isSurfaceLocked() {
- return recurLock.isLocked();
- }
-
public int getFloatingPointMode() {
if (floatMode == 0) {
throw new GLException("Pbuffer not initialized, or floating-point support not requested");
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index 02dd746a0..3437358de 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -1,22 +1,22 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* - Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* - Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
@@ -29,7 +29,7 @@
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
+ *
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
@@ -67,7 +67,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
// user properties
protected boolean shallUseOffscreenLayer = false;
-
+
// lifetime: forever
protected Component component;
private AWTGraphicsConfiguration config; // control access due to delegation
@@ -81,13 +81,13 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
protected long drawable;
protected Rectangle bounds;
protected Insets insets;
-
+
private long drawable_old;
-
+
/**
* Constructed by {@link jogamp.nativewindow.NativeWindowFactoryImpl#getNativeWindow(Object, AbstractGraphicsConfiguration)}
* via this platform's specialization (X11, OSX, Windows, ..).
- *
+ *
* @param comp
* @param config
*/
@@ -107,19 +107,22 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
this.component = windowObject;
this.isApplet = false;
}
-
+
+ @Override
public void setShallUseOffscreenLayer(boolean v) {
shallUseOffscreenLayer = v;
}
-
+
+ @Override
public final boolean getShallUseOffscreenLayer() {
return shallUseOffscreenLayer;
}
-
- public final boolean isOffscreenLayerSurfaceEnabled() {
+
+ @Override
+ public final boolean isOffscreenLayerSurfaceEnabled() {
return isOffscreenLayerSurface;
}
-
+
protected synchronized void invalidate() {
invalidateNative();
jawt = null;
@@ -136,7 +139,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
bounds.setY(jawtBounds.getY());
bounds.setWidth(jawtBounds.getWidth());
bounds.setHeight(jawtBounds.getHeight());
-
+
if(component instanceof Container) {
java.awt.Insets contInsets = ((Container)component).getInsets();
insets.setLeftWidth(contInsets.left);
@@ -148,16 +151,17 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
/** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */
public final RectangleImmutable getBounds() { return bounds; }
-
+
+ @Override
public final InsetsImmutable getInsets() { return insets; }
public final Component getAWTComponent() {
return component;
}
-
- /**
- * Returns true if the AWT component is parented to an {@link java.applet.Applet},
- * otherwise false. This information is valid only after {@link #lockSurface()}.
+
+ /**
+ * Returns true if the AWT component is parented to an {@link java.applet.Applet},
+ * otherwise false. This information is valid only after {@link #lockSurface()}.
*/
public final boolean isApplet() {
return isApplet;
@@ -168,10 +172,11 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
return jawt;
}
- /**
+ /**
* {@inheritDoc}
*/
- public final void attachSurfaceLayer(final long layerHandle) throws NativeWindowException {
+ @Override
+ public final void attachSurfaceLayer(final long layerHandle) throws NativeWindowException {
if( !isOffscreenLayerSurfaceEnabled() ) {
throw new NativeWindowException("Not an offscreen layer surface");
}
@@ -187,13 +192,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
} finally {
unlockSurface();
}
- }
+ }
protected abstract void attachSurfaceLayerImpl(final long layerHandle);
-
- /**
+
+ /**
* {@inheritDoc}
*/
- public final void detachSurfaceLayer(final long layerHandle) throws NativeWindowException {
+ @Override
+ public final void detachSurfaceLayer(final long layerHandle) throws NativeWindowException {
if( !isOffscreenLayerSurfaceEnabled() ) {
throw new java.lang.UnsupportedOperationException("Not an offscreen layer surface");
}
@@ -209,29 +215,33 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
} finally {
unlockSurface();
}
- }
+ }
protected abstract void detachSurfaceLayerImpl(final long layerHandle);
-
+
//
// SurfaceUpdateListener
//
+ @Override
public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
surfaceUpdatedHelper.addSurfaceUpdatedListener(l);
}
+ @Override
public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException {
surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l);
}
+ @Override
public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
surfaceUpdatedHelper.removeSurfaceUpdatedListener(l);
}
+ @Override
public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
surfaceUpdatedHelper.surfaceUpdated(updater, ns, when);
- }
-
+ }
+
//
// NativeSurface
//
@@ -243,14 +253,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
c = c.getParent();
}
}
-
+
/**
- * If JAWT offscreen layer is supported,
+ * If JAWT offscreen layer is supported,
* implementation shall respect {@link #getShallUseOffscreenLayer()}
* and may respect {@link #isApplet()}.
- *
+ *
* @return The JAWT instance reflecting offscreen layer support, etc.
- *
+ *
* @throws NativeWindowException
*/
protected abstract JAWT fetchJAWTImpl() throws NativeWindowException;
@@ -266,7 +276,8 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
}
// Thread.dumpStack();
}
-
+
+ @Override
public final int lockSurface() throws NativeWindowException {
surfaceLock.lock();
int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ?
@@ -282,7 +293,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
res = lockSurfaceImpl();
if(LOCK_SUCCESS == res && drawable_old != drawable) {
res = LOCK_SURFACE_CHANGED;
- if(DEBUG) {
+ if(DEBUG) {
System.err.println("JAWTWindow: surface change 0x"+Long.toHexString(drawable_old)+" -> 0x"+Long.toHexString(drawable));
// Thread.dumpStack();
}
@@ -303,6 +314,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
protected abstract void unlockSurfaceImpl() throws NativeWindowException;
+ @Override
public final void unlockSurface() {
surfaceLock.validateLocked();
drawable_old = drawable;
@@ -318,46 +330,51 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
surfaceLock.unlock();
}
+ @Override
public final boolean isSurfaceLockedByOtherThread() {
return surfaceLock.isLockedByOtherThread();
}
- public final boolean isSurfaceLocked() {
- return surfaceLock.isLocked();
- }
-
+ @Override
public final Thread getSurfaceLockOwner() {
return surfaceLock.getOwner();
}
+ @Override
public boolean surfaceSwap() {
return false;
}
+ @Override
public long getSurfaceHandle() {
return drawable;
}
-
+
public final AWTGraphicsConfiguration getPrivateGraphicsConfiguration() {
return config;
}
-
+
+ @Override
public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
return config.getNativeGraphicsConfiguration();
}
+ @Override
public final long getDisplayHandle() {
return getGraphicsConfiguration().getScreen().getDevice().getHandle();
}
+ @Override
public final int getScreenIndex() {
return getGraphicsConfiguration().getScreen().getIndex();
}
+ @Override
public int getWidth() {
return component.getWidth();
}
+ @Override
public int getHeight() {
return component.getHeight();
}
@@ -366,41 +383,47 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
// NativeWindow
//
+ @Override
public synchronized void destroy() {
- invalidate();
- component = null; // don't dispose the AWT component, since we are merely an immutable uplink
+ invalidate();
+ component = null; // don't dispose the AWT component, since we are merely an immutable uplink
}
+ @Override
public final NativeWindow getParent() {
return null;
}
+ @Override
public long getWindowHandle() {
return drawable;
}
-
+
+ @Override
public final int getX() {
return component.getX();
}
+ @Override
public final int getY() {
return component.getY();
}
-
+
/**
* {@inheritDoc}
- *
+ *
* <p>
- * This JAWT default implementation is currently still using
+ * This JAWT default implementation is currently still using
* a blocking implementation. It first attempts to retrieve the location
* via a native implementation. If this fails, it tries the blocking AWT implementation.
- * If the latter fails due to an external AWT tree-lock, the non block
+ * If the latter fails due to an external AWT tree-lock, the non block
* implementation {@link #getLocationOnScreenNonBlocking(Point, Component)} is being used.
* The latter simply traverse up to the AWT component tree and sums the rel. position.
* We have to determine whether the latter is good enough for all cases,
* currently only OS X utilizes the non blocking method per default.
- * </p>
+ * </p>
*/
+ @Override
public Point getLocationOnScreen(Point storage) {
Point los = getLocationOnScreenNative(storage);
if(null == los) {
@@ -421,7 +444,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
}
return los;
}
-
+
protected Point getLocationOnScreenNative(Point storage) {
int lockRes = lockSurface();
if(LOCK_SURFACE_NOT_READY == lockRes) {
@@ -442,12 +465,12 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
return d;
} finally {
unlockSurface();
- }
+ }
}
protected abstract Point getLocationOnScreenNativeImpl(int x, int y);
- protected static Point getLocationOnScreenNonBlocking(Point storage, Component comp) {
- int x = 0;
+ protected static Point getLocationOnScreenNonBlocking(Point storage, Component comp) {
+ int x = 0;
int y = 0;
while(null != comp) {
x += comp.getX();
@@ -460,11 +483,12 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
}
return new Point(x, y);
}
-
+
+ @Override
public boolean hasFocus() {
return component.hasFocus();
}
-
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -487,5 +511,4 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
return sb.toString();
}
-
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
index b7829cb6d..c58b34b18 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
@@ -104,15 +104,16 @@ public interface NativeSurface extends SurfaceUpdatedListener {
public void unlockSurface() throws NativeWindowException ;
/**
- * Return if surface is locked by another thread, ie not the current one
+ * Query if surface is locked by another thread, i.e. not the current one.
+ * <br>
+ * Convenient shortcut for:
+ * <pre>
+ * final Thread o = getSurfaceLockOwner();
+ * if( null != o && Thread.currentThread() != o ) { .. }
+ * </pre>
*/
public boolean isSurfaceLockedByOtherThread();
-
- /**
- * Return if surface is locked
- */
- public boolean isSurfaceLocked();
-
+
/**
* Return the locking owner's Thread, or null if not locked.
*/
diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
index 6a36bb130..c8cd78d82 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
@@ -37,7 +37,7 @@ import com.jogamp.common.util.locks.RecursiveLock;
public abstract class ProxySurface implements NativeSurface {
public static final boolean DEBUG = Debug.debug("ProxySurface");
-
+
private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper();
private AbstractGraphicsConfiguration config; // control access due to delegation
protected RecursiveLock surfaceLock = LockFactory.createRecursiveLock();
@@ -60,6 +60,7 @@ public abstract class ProxySurface implements NativeSurface {
}
protected abstract void invalidateImpl();
+ @Override
public final long getDisplayHandle() {
return displayHandle;
}
@@ -67,21 +68,26 @@ public abstract class ProxySurface implements NativeSurface {
protected final AbstractGraphicsConfiguration getPrivateGraphicsConfiguration() {
return config;
}
-
+
+ @Override
public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
return config.getNativeGraphicsConfiguration();
}
+ @Override
public final int getScreenIndex() {
return getGraphicsConfiguration().getScreen().getIndex();
}
+ @Override
public abstract long getSurfaceHandle();
+ @Override
public final int getWidth() {
return width;
}
+ @Override
public final int getHeight() {
return height;
}
@@ -91,26 +97,32 @@ public abstract class ProxySurface implements NativeSurface {
this.height = height;
}
+ @Override
public boolean surfaceSwap() {
return false;
}
+ @Override
public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
surfaceUpdatedHelper.addSurfaceUpdatedListener(l);
}
+ @Override
public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException {
surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l);
}
+ @Override
public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
surfaceUpdatedHelper.removeSurfaceUpdatedListener(l);
}
+ @Override
public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
surfaceUpdatedHelper.surfaceUpdated(updater, ns, when);
- }
-
+ }
+
+ @Override
public int lockSurface() throws NativeWindowException {
surfaceLock.lock();
int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ?
@@ -123,11 +135,11 @@ public abstract class ProxySurface implements NativeSurface {
res = lockSurfaceImpl();
if(LOCK_SUCCESS == res && surfaceHandle_old != getSurfaceHandle()) {
res = LOCK_SURFACE_CHANGED;
- if(DEBUG) {
+ if(DEBUG) {
System.err.println("ProxySurface: surface change 0x"+Long.toHexString(surfaceHandle_old)+" -> 0x"+Long.toHexString(getSurfaceHandle()));
// Thread.dumpStack();
}
- }
+ }
} finally {
if (LOCK_SURFACE_NOT_READY >= res) {
adevice.unlock();
@@ -142,6 +154,7 @@ public abstract class ProxySurface implements NativeSurface {
return res;
}
+ @Override
public final void unlockSurface() {
surfaceLock.validateLocked();
surfaceHandle_old = getSurfaceHandle();
@@ -165,17 +178,16 @@ public abstract class ProxySurface implements NativeSurface {
surfaceLock.validateLocked();
}
- public final boolean isSurfaceLocked() {
- return surfaceLock.isLocked();
- }
-
+ @Override
public final boolean isSurfaceLockedByOtherThread() {
return surfaceLock.isLockedByOtherThread();
}
+ @Override
public final Thread getSurfaceLockOwner() {
return surfaceLock.getOwner();
}
- public abstract String toString();
+ @Override
+ public abstract String toString();
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index a3adf5090..1832d4e99 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -842,22 +842,22 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
// NativeWindow completion
//
+ @Override
public final int lockSurface() {
return window.lockSurface();
}
+ @Override
public final void unlockSurface() throws NativeWindowException {
window.unlockSurface();
}
+ @Override
public final boolean isSurfaceLockedByOtherThread() {
return window.isSurfaceLockedByOtherThread();
}
- public final boolean isSurfaceLocked() {
- return window.isSurfaceLocked();
- }
-
+ @Override
public final Thread getSurfaceLockOwner() {
return window.getSurfaceLockOwner();
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 73bd9ed1c..baad77ffb 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -562,6 +562,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// NativeSurface
//
+ @Override
public final int lockSurface() {
windowLock.lock();
surfaceLock.lock();
@@ -590,6 +591,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return res;
}
+ @Override
public final void unlockSurface() {
surfaceLock.validateLocked();
windowLock.validateLocked();
@@ -606,30 +608,24 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
windowLock.unlock();
}
- public final boolean isWindowLockedByOtherThread() {
- return windowLock.isLockedByOtherThread();
- }
-
- public final boolean isWindowLocked() {
- return windowLock.isLocked();
- }
-
- public final Thread getWindowLockOwner() {
- return windowLock.getOwner();
- }
-
+ @Override
public final boolean isSurfaceLockedByOtherThread() {
return surfaceLock.isLockedByOtherThread();
}
- public final boolean isSurfaceLocked() {
- return surfaceLock.isLocked();
- }
-
+ @Override
public final Thread getSurfaceLockOwner() {
return surfaceLock.getOwner();
}
+ public final boolean isWindowLockedByOtherThread() {
+ return windowLock.isLockedByOtherThread();
+ }
+
+ public final Thread getWindowLockOwner() {
+ return windowLock.getOwner();
+ }
+
public long getSurfaceHandle() {
return windowHandle; // default: return window handle
}
@@ -1574,7 +1570,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
public void runOnEDTIfAvail(boolean wait, final Runnable task) {
- if(windowLock.isOwner()) {
+ if(windowLock.isOwner(Thread.currentThread())) {
task.run();
} else {
Screen scrn = getScreen();
@@ -1913,7 +1909,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// special repaint treatment
case WindowEvent.EVENT_WINDOW_REPAINT:
// queue repaint event in case window is locked, ie in operation
- if( isWindowLocked() ) {
+ if( null != getWindowLockOwner() ) {
// make sure only one repaint event is queued
if(!repaintQueued) {
repaintQueued=true;
@@ -1932,7 +1928,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// common treatment
case WindowEvent.EVENT_WINDOW_RESIZED:
// queue event in case window is locked, ie in operation
- if( isWindowLocked() ) {
+ if( null != getWindowLockOwner() ) {
final boolean discardTO = QUEUED_EVENT_TO <= System.currentTimeMillis()-e.getWhen();
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.consumeEvent: "+Thread.currentThread().getName()+" - queued "+e+", discard-to "+discardTO);