summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-08-30 15:37:47 +0200
committerSven Gothel <[email protected]>2011-08-30 15:37:47 +0200
commit736d1c5d27e0cee36993f74dca787aefd3df7d18 (patch)
tree0e5499e6517fa89d654625a4c567a7341b9e51ce /src/nativewindow/classes
parent78b7732498099e1cc6bbedfa7437bb3c8955cfc5 (diff)
JAWTWindow.getLocationOnScreen(): Add proper JAWT lockSurface() ; X11Util: use System.err ; TestParenting02AWT: use GearsES2
JAWTWindow.getLocationOnScreen() - Add proper JAWT lockSurface() - Turns out that the parent location query of a NEWT child to an [J]AWT window didn't lock the window
Diffstat (limited to 'src/nativewindow/classes')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java59
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java2
2 files changed, 33 insertions, 28 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
index 67f6fe4b8..f03aa06d9 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
@@ -226,34 +226,39 @@ public abstract class JAWTWindow implements NativeWindow {
}
public Point getLocationOnScreen(Point storage) {
- if( 0 != getWindowHandle() ) {
- Point d;
- // windowLock.lock();
- try {
- d = getLocationOnScreenImpl(0, 0);
- } finally {
- // windowLock.unlock();
- }
- if(null!=d) {
- if(null!=storage) {
- storage.translate(d.getX(),d.getY());
- return storage;
- }
- return d;
+ int lockRes = lockSurface();
+ if(LOCK_SURFACE_NOT_READY == lockRes) {
+ // FIXME: Shall we deal with already locked or unrealized surfaces ?
+ System.err.println("Warning: JAWT Lock couldn't be acquired!");
+ Thread.dumpStack();
+ return null;
+ }
+ try {
+ Point d = getLocationOnScreenImpl(0, 0);
+ if(null!=d) {
+ if(null!=storage) {
+ storage.translate(d.getX(),d.getY());
+ return storage;
}
- // fall through intended ..
- }
-
- if(!Thread.holdsLock(component.getTreeLock())) {
- return null; // avoid deadlock ..
- }
- java.awt.Point awtLOS = component.getLocationOnScreen();
- int dx = (int) ( awtLOS.getX() + .5 ) ;
- int dy = (int) ( awtLOS.getY() + .5 ) ;
- if(null!=storage) {
- return storage.translate(dx, dy);
- }
- return new Point(dx, dy);
+ return d;
+ }
+ // fall through intended ..
+ if(!Thread.holdsLock(component.getTreeLock())) {
+ // FIXME: Verify if this check is still required!
+ System.err.println("Warning: JAWT Lock hold, but not the AWT tree lock!");
+ Thread.dumpStack();
+ return null; // avoid deadlock ..
+ }
+ java.awt.Point awtLOS = component.getLocationOnScreen();
+ int dx = (int) ( awtLOS.getX() + .5 ) ;
+ int dy = (int) ( awtLOS.getY() + .5 ) ;
+ if(null!=storage) {
+ return storage.translate(dx, dy);
+ }
+ return new Point(dx, dy);
+ } finally {
+ unlockSurface();
+ }
}
protected abstract Point getLocationOnScreenImpl(int x, int y);
diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
index 37056d44d..28d75ea06 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
@@ -78,7 +78,7 @@ public class X11Util {
requiresX11Lock = !firstX11ActionOnProcess ;
if(DEBUG) {
- System.out.println("X11Util firstX11ActionOnProcess: "+firstX11ActionOnProcess+
+ System.err.println("X11Util firstX11ActionOnProcess: "+firstX11ActionOnProcess+
", XINITTHREADS_ALWAYS_ENABLED "+XINITTHREADS_ALWAYS_ENABLED+
", requiresX11Lock "+requiresX11Lock);
}