diff options
author | Sven Gothel <[email protected]> | 2011-08-30 15:37:47 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-08-30 15:37:47 +0200 |
commit | 736d1c5d27e0cee36993f74dca787aefd3df7d18 (patch) | |
tree | 0e5499e6517fa89d654625a4c567a7341b9e51ce | |
parent | 78b7732498099e1cc6bbedfa7437bb3c8955cfc5 (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
3 files changed, 35 insertions, 42 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); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java index d06e6259a..32e334076 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java @@ -28,27 +28,16 @@ package com.jogamp.opengl.test.junit.newt.parenting; -import java.lang.reflect.*; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import org.junit.Assert; -import org.junit.Before; import org.junit.BeforeClass; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Test; import java.awt.Button; import java.awt.BorderLayout; -import java.awt.Canvas; import java.awt.Frame; import javax.media.opengl.*; -import javax.media.nativewindow.*; -import com.jogamp.opengl.util.Animator; import com.jogamp.newt.*; import com.jogamp.newt.event.*; import com.jogamp.newt.opengl.*; @@ -57,8 +46,7 @@ import com.jogamp.newt.awt.NewtCanvasAWT; import java.io.IOException; import com.jogamp.opengl.test.junit.util.*; -import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; -import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; public class TestParenting02AWT extends UITestCase { static int width, height; @@ -102,7 +90,7 @@ public class TestParenting02AWT extends UITestCase { glWindow.setTitle("NEWT - CHILD"); glWindow.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo))); glWindow.addWindowListener(new TraceWindowAdapter(new WindowAction(eventFifo))); - GLEventListener demo = new Gears(); + GLEventListener demo = new GearsES2(); setDemoFields(demo, glWindow, false); glWindow.addGLEventListener(demo); |