aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-05-21 06:15:17 +0200
committerSven Gothel <[email protected]>2010-05-21 06:15:17 +0200
commit6e599a2696f878786783e0fea17534e67655a5c9 (patch)
tree65774f7318ea67a170902efefbd3a952c94d7f6d
parent3d8e85915ccdf48b9a97b5ed279716a2204a7a82 (diff)
Changed NEWT NativeWindow creation contract - AWT/NEWT Parenting - Misc Fixes
+++++ Changed NEWT NativeWindow creation contract Original contract: (1) A native window was created as soon as possible, ie when NEWTFactory.createWindow(..) was called - if possible. (2) A valid native window has to be created at least after setVisible(true) has been called. Problems: Not all implementation are able to create the native window that early, but at setVisible(true) only (e.g: KD and EGL). Due to window parenting especially the new AWT/NEWT parenting, the native window can only be created in case the parent native window is valid. New contract: (1) A native window is created at setVisible(true), if it's a top level window or the native parent window is valid. (2) A valid native window may not be created after setVisible(true) has been called. Subsequent setVisible(true) calls shall be made in case the creation has not been done yet. This is demonstrated in GLWindow.display() for example. The new contract implements a lazy native window creation. +++++ AWT/NEWT Parenting - HierarchyListener and ComponentListener ensure that the NEWT child window will be setVisible according to the AWT parent window. - Lazy native window creation relaxes requirements to the parent window's state. - Attachment of the child window and setVisible() may be called after NEWT child window creation. - GLWindow supports NEWT child window creation directly The test case TestParenting01AWT.java reflect this new contract and demonstrates more simplified and more flexible use cases. +++++ NEWT Fixes: - All NEWT implementation's native code method names end with 0. - GLWindow: don't issue the actual 'init'/'display' call to GLEventListeners in case the window is not visible. - NEWT setSize/setPosition: if native-window call native-window action and let the attributes being set by the feedback call, which issues more action, ie RESIZE. else set the attributes directly, no feedback call/action is necessary. +++++ X11 Fixes: - X11GLContext MakeContextCurrent: Use MakeCurrent in case write and read drawable are equal, otherwise SEGV happens on ATI with heavy multithreading involved! Even XLockDisplay and XSync didn't help here .. - X11GLXDrawableFactory shared resource: Removed the resource holder thread to simplify code, hence proper release is no more desired and it could become a cause for deadlock. - Moved XInitThreads() from NEWT X11Window -> NativeWindow X11Util, since NativeWindow is loaded first (essential for XInitThreads()) and it is the more basic lib. - Made call to XInitThreads() conditional, ie it's spared if AWT could be used - which causes SEGV .. (AWT bug). See X11Util.java +++++ JOGL Fixes: - GLProfile.isAWTAvailable() -> NativeWindowFactory.isAWTAvailable() - GLProfile.isAWTJOGLAvailable() -> GLProfile.isAWTAvailable()
-rw-r--r--make/build-jogl.xml12
-rw-r--r--make/build-nativewindow.xml8
-rw-r--r--make/build-newt.xml12
-rw-r--r--make/build.xml2
-rw-r--r--make/config/nativewindow/x11-lib.cfg1
-rwxr-xr-xmake/scripts/java-run-all.sh6
-rw-r--r--make/stub_includes/x11/window-lib.c7
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java8
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java117
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/util/Animator.java2
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javame_cdc_fp4
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javase4
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java14
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java (renamed from src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01CORE.java)8
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java2
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java12
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/newt/TestParenting01AWT.java107
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/newt/TestParenting01NEWT.java40
-rwxr-xr-xsrc/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java10
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTUtil.java61
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java14
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java32
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java23
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java36
-rw-r--r--src/nativewindow/native/x11/Xmisc.c13
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/Display.java24
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/NewtFactory.java108
-rw-r--r--src/newt/classes/com/jogamp/newt/OffscreenWindow.java7
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/Screen.java16
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/Window.java191
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java109
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java63
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java28
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/intel/gdl/Display.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java23
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java8
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/macosx/MacScreen.java6
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java137
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Display.java6
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java20
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/opengl/kd/KDDisplay.java7
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java22
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/windows/WindowsDisplay.java20
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java6
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java86
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/x11/X11Display.java31
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/x11/X11Screen.java4
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/x11/X11Window.java38
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java102
-rw-r--r--src/newt/classes/com/jogamp/newt/util/EDTUtil.java8
-rw-r--r--src/newt/native/MacWindow.m22
-rwxr-xr-xsrc/newt/native/WindowsWindow.c28
-rwxr-xr-xsrc/newt/native/X11Window.c20
56 files changed, 981 insertions, 728 deletions
diff --git a/make/build-jogl.xml b/make/build-jogl.xml
index 27ec68718..0dd04ccb8 100644
--- a/make/build-jogl.xml
+++ b/make/build-jogl.xml
@@ -1104,9 +1104,9 @@
<!-- linker configuration -->
<linker id="linker.cfg.linux.jogl.gl2" extends="linker.cfg.linux">
- <syslibset dir="/usr/lib" libs="X11"/>
- <syslibset dir="/usr/lib" libs="Xxf86vm" />
- <syslibset dir="/usr/lib" libs="GL"/>
+ <syslibset libs="X11"/>
+ <syslibset libs="Xxf86vm" />
+ <syslibset libs="GL"/>
</linker>
<linker id="linker.cfg.linux.jogl.cg" extends="linker.cfg.linux.jogl.gl2">
@@ -1114,12 +1114,12 @@
</linker>
<linker id="linker.cfg.linux.amd64.jogl.x11" extends="linker.cfg.linux.amd64">
- <syslibset dir="/usr/lib64" libs="X11"/>
- <syslibset dir="/usr/lib64" libs="Xxf86vm" />
+ <syslibset libs="X11"/>
+ <syslibset libs="Xxf86vm" />
</linker>
<linker id="linker.cfg.linux.amd64.jogl.gl2" extends="linker.cfg.linux.amd64.jogl.x11">
- <syslibset dir="/usr/lib64" libs="GL"/>
+ <syslibset libs="GL"/>
</linker>
<linker id="linker.cfg.linux.amd64.jogl.cg" extends="linker.cfg.linux.amd64.jogl.gl2">
diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml
index ee6eef03e..b087a5ba7 100644
--- a/make/build-nativewindow.xml
+++ b/make/build-nativewindow.xml
@@ -361,13 +361,13 @@
<!-- linker configuration -->
<linker id="linker.cfg.linux.nativewindow.x11" extends="linker.cfg.linux">
- <syslibset dir="/usr/lib" libs="X11"/>
- <syslibset dir="/usr/lib" libs="Xxf86vm" />
+ <syslibset libs="X11"/>
+ <syslibset libs="Xxf86vm" />
</linker>
<linker id="linker.cfg.linux.amd64.nativewindow.x11" extends="linker.cfg.linux.amd64">
- <syslibset dir="/usr/lib64" libs="X11"/>
- <syslibset dir="/usr/lib64" libs="Xxf86vm" />
+ <syslibset libs="X11"/>
+ <syslibset libs="Xxf86vm" />
</linker>
<linker id="linker.cfg.solaris.nativewindow.x11" extends="linker.cfg.solaris">
diff --git a/make/build-newt.xml b/make/build-newt.xml
index 01fb40ac8..08c0f308b 100644
--- a/make/build-newt.xml
+++ b/make/build-newt.xml
@@ -240,18 +240,18 @@
<!-- linker configuration -->
<linker id="linker.cfg.linux.newt.broadcom_egl" extends="linker.cfg.linux">
- <syslibset dir="/nfsroot/lg/lib" libs="EGL"/>
- <syslibset dir="/nfsroot/lg/lib" libs="GLES_CM"/>
+ <syslibset libs="EGL"/>
+ <syslibset libs="GLES_CM"/>
</linker>
<linker id="linker.cfg.linux.newt.x11" extends="linker.cfg.linux">
- <syslibset dir="/usr/lib" libs="X11"/>
- <syslibset dir="/usr/lib" libs="Xxf86vm" />
+ <syslibset libs="X11"/>
+ <syslibset libs="Xxf86vm" />
</linker>
<linker id="linker.cfg.linux.amd64.newt.x11" extends="linker.cfg.linux.amd64">
- <syslibset dir="/usr/lib64" libs="X11"/>
- <syslibset dir="/usr/lib64" libs="Xxf86vm" />
+ <syslibset libs="X11"/>
+ <syslibset libs="Xxf86vm" />
</linker>
<linker id="linker.cfg.solaris.newt.x11" extends="linker.cfg.solaris">
diff --git a/make/build.xml b/make/build.xml
index 51dac3fa7..9a1cf81ce 100644
--- a/make/build.xml
+++ b/make/build.xml
@@ -63,6 +63,8 @@
</copy>
</target>
+ <target name="one.dir" depends="one-lib-dir,one-jar-dir"/>
+
<target name="repack-jars" depends="one-jar-dir">
<!-- Re-pack jars we have the intent to compress later, after signing -->
<mkdir dir="${jar}/orig" />
diff --git a/make/config/nativewindow/x11-lib.cfg b/make/config/nativewindow/x11-lib.cfg
index cf9642398..2380f07ad 100644
--- a/make/config/nativewindow/x11-lib.cfg
+++ b/make/config/nativewindow/x11-lib.cfg
@@ -24,6 +24,7 @@ IncludeAs CustomJavaCode X11Lib x11-CustomJavaCode.java
# Now resides in x11/Xmisc.c: IncludeAs CustomCCode x11-CustomCCode.c
ArgumentIsString XOpenDisplay 0
+ReturnsString XDisplayString
# We have Custom code for the following
Ignore XGetVisualInfo
diff --git a/make/scripts/java-run-all.sh b/make/scripts/java-run-all.sh
index 9c3fbed03..8c50d0933 100755
--- a/make/scripts/java-run-all.sh
+++ b/make/scripts/java-run-all.sh
@@ -36,7 +36,11 @@ uname -a | grep -i Darwin && MOSX=1
# D_ARGS="-Dnativewindow.debug.X11Util=true -Djogl.debug.GLDrawableFactory=true"
# D_ARGS="-Dnativewindow.debug.X11Util=true"
# D_ARGS="-Dnewt.debug=all"
+# D_ARGS="-Dnewt.debug.Window"
# D_ARGS="-Djogl.debug=all"
-echo java $X_ARGS $D_ARGS $* 2>&1 | tee java-run.log
+rm -f java-run.log
+
+echo LIBXCB_ALLOW_SLOPPY_LOCK: $LIBXCB_ALLOW_SLOPPY_LOCK 2>&1 | tee -a java-run.log
+echo java $X_ARGS $D_ARGS $* 2>&1 | tee -a java-run.log
java $X_ARGS $D_ARGS $* 2>&1 | tee -a java-run.log
diff --git a/make/stub_includes/x11/window-lib.c b/make/stub_includes/x11/window-lib.c
index 8fca86263..9affa8427 100644
--- a/make/stub_includes/x11/window-lib.c
+++ b/make/stub_includes/x11/window-lib.c
@@ -7,6 +7,13 @@
#define _Xconst const
#endif /* _Xconst */
+extern Bool XSynchronize(Display *display, Bool onoff);
+
+extern int XFlush(Display *display);
+extern int XSync(Display *display, Bool discard);
+
+extern char *XDisplayString(Display *display);
+
extern Display *XOpenDisplay(
_Xconst char* /* display_name */
);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
index 9c3efea2e..76a6830d5 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
@@ -108,7 +108,13 @@ public abstract class X11GLXContext extends GLContextImpl {
boolean res = false;
try {
- res = GLX.glXMakeContextCurrent(dpy, writeDrawable, readDrawable, ctx);
+ // at least on ATI we receive 'often' SEGV in case of
+ // highly multithreaded MakeContextCurrent calls with writeDrawable==readDrawable
+ if(writeDrawable==readDrawable) {
+ res = GLX.glXMakeCurrent(dpy, writeDrawable, ctx);
+ } else {
+ res = GLX.glXMakeContextCurrent(dpy, writeDrawable, readDrawable, ctx);
+ }
} catch (RuntimeException re) {
if(DEBUG) {
System.err.println("X11GLXContext.glXMakeContextCurrent failed: "+re+", with "+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index 823809f43..e2b24f9f0 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -67,16 +67,21 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
new Object[] {});
} catch (JogampRuntimeException jre) { /* n/a .. */ }
- shareableResourceThread = new ShareableResourceThread(GLProfile.getDefault(), GLProfile.isAWTJOGLAvailable());
- shareableResourceThread.start();
- while (!shareableResourceThread.isInitialized()) {
- synchronized(shareableResourceThread) {
- try {
- shareableResourceThread.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
+ // init shared resources ..
+ long tlsDisplay = X11Util.createThreadLocalDisplay(null);
+ X11GraphicsDevice sharedDevice = new X11GraphicsDevice(tlsDisplay);
+ vendorName = GLXUtil.getVendorName(sharedDevice.getHandle());
+ isVendorATI = GLXUtil.isVendorATI(vendorName);
+ isVendorNVIDIA = GLXUtil.isVendorNVIDIA(vendorName);
+ sharedScreen = new X11GraphicsScreen(sharedDevice, 0);
+ X11Util.XLockDisplay(tlsDisplay);
+ try{
+ sharedDrawable = new X11DummyGLXDrawable(sharedScreen, X11GLXDrawableFactory.this, GLProfile.getDefault());
+ } finally {
+ X11Util.XUnlockDisplay(tlsDisplay);
+ }
+ if(isVendorATI() && GLProfile.isAWTAvailable()) {
+ X11Util.markThreadLocalDisplayUncloseable(tlsDisplay); // failure to close with ATI and AWT usage
}
if(null==sharedScreen || null==sharedDrawable) {
throw new GLException("Couldn't init shared screen("+sharedScreen+")/drawable("+sharedDrawable+")");
@@ -104,73 +109,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
}
}
- ShareableResourceThread shareableResourceThread;
-
- class ShareableResourceThread extends Thread {
- volatile boolean shutdown = false;
- volatile boolean initialized = false;
- GLProfile glp;
- boolean mayUseAWT;
-
- final void shutdown() { shutdown = true; }
- final boolean isInitialized() { return initialized; }
-
- public ShareableResourceThread(GLProfile glp, boolean mayUseAWT) {
- super("ShareableResourceThread-"+Thread.currentThread().getName());
- this.glp = glp;
- this.mayUseAWT = mayUseAWT;
- }
-
- public void run() {
- synchronized(this) {
- long tlsDisplay = X11Util.createThreadLocalDisplay(null);
- X11GraphicsDevice sharedDevice = new X11GraphicsDevice(tlsDisplay);
- vendorName = GLXUtil.getVendorName(sharedDevice.getHandle());
- isVendorATI = GLXUtil.isVendorATI(vendorName);
- isVendorNVIDIA = GLXUtil.isVendorNVIDIA(vendorName);
- sharedScreen = new X11GraphicsScreen(sharedDevice, 0);
- X11Util.XLockDisplay(sharedScreen.getDevice().getHandle());
- try{
- sharedDrawable = new X11DummyGLXDrawable(sharedScreen, X11GLXDrawableFactory.this, glp);
- } finally {
- X11Util.XUnlockDisplay(sharedScreen.getDevice().getHandle());
- }
- if(isVendorATI() && mayUseAWT) {
- X11Util.markThreadLocalDisplayUncloseable(tlsDisplay); // failure to close with ATI and AWT usage
- }
- initialized = true;
- this.notifyAll();
-
- while (!shutdown) {
- synchronized(this) {
- try {
- this.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
-
- // don't free native resources from this point on,
- // since we might be in a critical shutdown hook sequence
- if(null!=sharedDrawable) {
- // may cause deadlock: sharedDrawable.destroy();
- sharedDrawable=null;
- }
- if(null!=sharedScreen) {
- // may cause deadlock: X11Util.closeThreadLocalDisplay(null);
- sharedScreen = null;
- sharedDevice=null;
- }
- // don't close pending XDisplay, since they might be a different thread as the opener
- X11Util.shutdown( false, DEBUG );
-
- initialized = false;
- this.notifyAll();
- }
- }
- }
-
private X11GraphicsScreen sharedScreen;
private String vendorName;
private boolean isVendorATI;
@@ -202,20 +140,19 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
sharedContext.destroy(); // implies release, if current
sharedContext=null;
}
- synchronized(shareableResourceThread) {
- if (shareableResourceThread.isInitialized()) {
- shareableResourceThread.shutdown();
- shareableResourceThread.notifyAll();
- while (shareableResourceThread.isInitialized()) {
- try {
- shareableResourceThread.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
+
+ // don't free native resources from this point on,
+ // since we might be in a critical shutdown hook sequence
+ if(null!=sharedDrawable) {
+ // may cause deadlock: sharedDrawable.destroy();
+ sharedDrawable=null;
+ }
+ if(null!=sharedScreen) {
+ // may cause deadlock: X11Util.closeThreadLocalDisplay(null);
+ sharedScreen = null;
}
- shareableResourceThread = null;
+ // don't close pending XDisplay, since they might be a different thread as the opener
+ X11Util.shutdown( false, DEBUG );
}
public GLDrawableImpl createOnscreenDrawable(NativeWindow target) {
diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
index 9bef8e9c3..15b9d5eb9 100755
--- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
@@ -70,7 +70,7 @@ public class Animator {
/** Creates a new, empty Animator. */
public Animator(ThreadGroup tg) {
- if(GLProfile.isAWTJOGLAvailable()) {
+ if(GLProfile.isAWTAvailable()) {
try {
impl = (AnimatorImpl) Class.forName("com.jogamp.opengl.util.awt.AWTAnimatorImpl").newInstance();
} catch (Exception e) { }
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javame_cdc_fp b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javame_cdc_fp
index dbd194d21..3b694be68 100755
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javame_cdc_fp
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javame_cdc_fp
@@ -729,7 +729,7 @@ public class TextureIO {
static {
/*
- if(GLProfile.isAWTJOGLAvailable()) {
+ if(GLProfile.isAWTAvailable()) {
// ImageIO provider, the fall-back, must be the first one added
try {
// Use reflection to avoid compile-time dependencies on AWT-related classes
@@ -751,7 +751,7 @@ public class TextureIO {
/*
// ImageIO writer, the fall-back, must be the first one added
- if(GLProfile.isAWTJOGLAvailable()) {
+ if(GLProfile.isAWTAvailable()) {
try {
// Use reflection to avoid compile-time dependencies on AWT-related classes
TextureWriter writer = (TextureWriter)
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javase b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javase
index 3e6f66f10..819a6acf5 100755
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javase
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javase
@@ -729,7 +729,7 @@ public class TextureIO {
static {
// ImageIO provider, the fall-back, must be the first one added
- if(GLProfile.isAWTJOGLAvailable()) {
+ if(GLProfile.isAWTAvailable()) {
try {
// Use reflection to avoid compile-time dependencies on AWT-related classes
TextureProvider provider = (TextureProvider)
@@ -748,7 +748,7 @@ public class TextureIO {
addTextureProvider(new TGATextureProvider());
// ImageIO writer, the fall-back, must be the first one added
- if(GLProfile.isAWTJOGLAvailable()) {
+ if(GLProfile.isAWTAvailable()) {
try {
// Use reflection to avoid compile-time dependencies on AWT-related classes
TextureWriter writer = (TextureWriter)
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 6b49b24df..d746101ca 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -45,6 +45,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.security.*;
import javax.media.opengl.fixedfunc.GLPointerFunc;
+import javax.media.nativewindow.NativeWindowFactory;
/**
* Specifies the the OpenGL profile.
@@ -830,7 +831,6 @@ public class GLProfile implements Cloneable {
private static final String GL2ES12 = "GL2ES12";
private static /*final*/ boolean isAWTAvailable;
- private static /*final*/ boolean isAWTJOGLAvailable;
private static /*final*/ boolean hasGL234Impl;
private static /*final*/ boolean hasGL4bcImpl;
@@ -862,12 +862,8 @@ public class GLProfile implements Cloneable {
AccessControlContext acc = AccessController.getContext();
- isAWTAvailable = !Debug.getBooleanProperty("java.awt.headless", true, acc) &&
- ReflectionUtil.isClassAvailable("java.awt.Component") ;
-
- isAWTJOGLAvailable = isAWTAvailable &&
- ReflectionUtil.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice") && // NativeWindow
- ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas") ; // JOGL
+ isAWTAvailable = NativeWindowFactory.isAWTAvailable() &&
+ ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas") ; // JOGL
boolean hasDesktopGL = false;
boolean hasDesktopGLES12 = false;
@@ -1040,7 +1036,6 @@ public class GLProfile implements Cloneable {
if (DEBUG) {
System.err.println("GLProfile.static isAWTAvailable "+isAWTAvailable);
- System.err.println("GLProfile.static isAWTJOGLAvailable "+isAWTJOGLAvailable);
System.err.println("GLProfile.static hasNativeOSFactory "+hasNativeOSFactory);
System.err.println("GLProfile.static hasDesktopGL "+hasDesktopGL);
System.err.println("GLProfile.static hasDesktopGLES12 "+hasDesktopGLES12);
@@ -1156,8 +1151,9 @@ public class GLProfile implements Cloneable {
return null;
}
+ /** @return {@link javax.media.nativewindow.NativeWindowFactory#isAWTAvailable()} and
+ JOGL's AWT part */
public static boolean isAWTAvailable() { return isAWTAvailable; }
- public static boolean isAWTJOGLAvailable() { return isAWTJOGLAvailable; }
public static String getGLTypeName(int type) {
switch (type) {
diff --git a/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01CORE.java b/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java
index e2de8c1e1..48388d4e9 100755
--- a/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01CORE.java
+++ b/src/junit/com/jogamp/test/junit/jogl/acore/TestGLProfile01NEWT.java
@@ -46,7 +46,7 @@ import com.jogamp.newt.opengl.*;
import com.jogamp.newt.*;
import java.io.IOException;
-public class TestGLProfile01CORE {
+public class TestGLProfile01NEWT {
static GLProfile glp;
@BeforeClass
@@ -120,9 +120,9 @@ public class TestGLProfile01CORE {
protected void dumpVersion(GLProfile glp) {
GLCapabilities caps = new GLCapabilities(glp);
- GLWindow glWindow = GLWindow.create(caps);
+ GLWindow glWindow = GLWindow.create(caps, false);
Assert.assertNotNull(glWindow);
- glWindow.setTitle("TestGLProfile01CORE");
+ glWindow.setTitle("TestGLProfile01NEWT");
glWindow.addGLEventListener(new DumpVersion());
@@ -133,7 +133,7 @@ public class TestGLProfile01CORE {
}
public static void main(String args[]) throws IOException {
- String tstname = TestGLProfile01CORE.class.getName();
+ String tstname = TestGLProfile01NEWT.class.getName();
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
tstname,
"filtertrace=true",
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java
index 23c39290c..e50ffbde9 100755
--- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNEWT.java
@@ -64,7 +64,7 @@ public class TestGearsNEWT {
}
protected void runTestGL(GLCapabilities caps) throws InterruptedException {
- GLWindow glWindow = GLWindow.create(caps);
+ GLWindow glWindow = GLWindow.create(caps, false);
Assert.assertNotNull(glWindow);
glWindow.setTitle("Gears NEWT Test");
diff --git a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
index ff4186b0c..cd0c7c0e0 100755
--- a/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/drawable/TestDrawable01NEWT.java
@@ -105,9 +105,9 @@ public class TestDrawable01NEWT {
Assert.assertTrue(glCaps.getGreenBits()>5);
Assert.assertTrue(glCaps.getBlueBits()>5);
Assert.assertTrue(glCaps.getRedBits()>5);
- Assert.assertTrue(glCaps.isOnscreen()==onscreen);
+ Assert.assertEquals(glCaps.isOnscreen(),onscreen);
Assert.assertTrue(onscreen || !pbuffer || glCaps.isPBuffer()); // pass if onscreen, or !pbuffer req. or have pbuffer
- Assert.assertTrue(glCaps.getDoubleBuffered()==onscreen);
+ Assert.assertEquals(glCaps.getDoubleBuffered(),onscreen);
Assert.assertTrue(glCaps.getDepthBits()>4);
drawable = factory.createGLDrawable(window);
@@ -115,10 +115,10 @@ public class TestDrawable01NEWT {
// System.out.println("Pre: "+drawable);
//
drawable.setRealized(true);
- Assert.assertTrue(width==drawable.getWidth());
- Assert.assertTrue(height==drawable.getHeight());
- // Assert.assertTrue(glCaps==drawable.getChosenGLCapabilities());
- Assert.assertTrue(window==drawable.getNativeWindow());
+ // Assert.assertEquals(width,drawable.getWidth());
+ // Assert.assertEquals(height,drawable.getHeight());
+ // Assert.assertEquals(glCaps,drawable.getChosenGLCapabilities());
+ Assert.assertEquals(window,drawable.getNativeWindow());
// System.out.println("Post: "+drawable);
context = drawable.createContext(null);
diff --git a/src/junit/com/jogamp/test/junit/newt/TestParenting01AWT.java b/src/junit/com/jogamp/test/junit/newt/TestParenting01AWT.java
index 9d0001733..2c0dc31c1 100755
--- a/src/junit/com/jogamp/test/junit/newt/TestParenting01AWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestParenting01AWT.java
@@ -73,32 +73,27 @@ public class TestParenting01AWT {
height = 480;
}
- static void destroyWindow(Display display, Screen screen, Window window, GLWindow glWindow) {
- if(null!=glWindow) {
- glWindow.destroy();
- }
- if(null!=window) {
- window.destroy();
- }
- if(null!=screen) {
- screen.destroy();
- }
- if(null!=display) {
- display.destroy();
- }
+ @Test
+ public void testWindowParenting01NewtChildOnAWTParentLayouted() throws InterruptedException {
+ runNewtChildOnAWTParent(true, false);
}
@Test
- public void testWindowParenting01NewtChildOnAWTParentLayouted() throws InterruptedException {
- runNewtChildOnAWTParent(true);
+ public void testWindowParenting02NewtChildOnAWTParentLayoutedDef() throws InterruptedException {
+ runNewtChildOnAWTParent(true, true);
+ }
+
+ @Test
+ public void testWindowParenting03NewtChildOnAWTParentDirect() throws InterruptedException {
+ runNewtChildOnAWTParent(false, false);
}
@Test
- public void testWindowParenting02NewtChildOnAWTParentDirect() throws InterruptedException {
- runNewtChildOnAWTParent(false);
+ public void testWindowParenting04NewtChildOnAWTParentDirectDef() throws InterruptedException {
+ runNewtChildOnAWTParent(false, true);
}
- public void runNewtChildOnAWTParent(boolean useLayout) throws InterruptedException {
+ public void runNewtChildOnAWTParent(boolean useLayout, boolean deferredPeer) throws InterruptedException {
Frame frame = new Frame("AWT Parent Frame");
Assert.assertNotNull(frame);
Component overlayedAWTComponent = null;
@@ -111,7 +106,9 @@ public class TestParenting01AWT {
frame.add(new Button("South"), BorderLayout.SOUTH);
frame.add(new Button("East"), BorderLayout.EAST);
frame.add(new Button("West"), BorderLayout.WEST);
- frame.add(overlayedAWTComponent, BorderLayout.CENTER);
+ if(!deferredPeer) {
+ frame.add(overlayedAWTComponent, BorderLayout.CENTER);
+ }
} else {
overlayedAWTComponent = frame;
@@ -119,57 +116,55 @@ public class TestParenting01AWT {
Assert.assertNotNull(overlayedAWTComponent);
frame.setSize(width, height);
- frame.setVisible(true); // should have native peers after this!
-
- GLCapabilities caps = new GLCapabilities(null);
- Assert.assertNotNull(caps);
- Display display = NewtFactory.createDisplay(null); // local display
- Assert.assertNotNull(display);
- System.out.println("Display: "+display);
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- Assert.assertNotNull(screen);
+ if(!deferredPeer) {
+ // ensure native peers are valid and component is displayable
+ frame.setVisible(true);
+ }
NEWTEventFiFo eventFifo = new NEWTEventFiFo();
- Window window2 = NewtFactory.createWindow(overlayedAWTComponent, screen, caps, false);
- Assert.assertNotNull(window2);
-
- GLWindow glWindow2 = GLWindow.create(window2);
- Assert.assertNotNull(glWindow2);
+ GLCapabilities caps = new GLCapabilities(null);
+ Assert.assertNotNull(caps);
- glWindow2.setSize(width, height);
- Assert.assertTrue(false==glWindow2.isVisible());
- Assert.assertTrue(width==glWindow2.getWidth());
- Assert.assertTrue(height==glWindow2.getHeight());
+ GLWindow glWindow = GLWindow.create(overlayedAWTComponent, caps);
+ Assert.assertNotNull(glWindow);
+ Assert.assertEquals(overlayedAWTComponent.isVisible(),glWindow.isVisible());
+ if(!deferredPeer) {
+ Assert.assertTrue(0!=glWindow.getWindowHandle());
+ } else {
+ Assert.assertTrue(0==glWindow.getWindowHandle());
+ }
+ glWindow.setTitle("NEWT - CHILD");
+ glWindow.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo)));
+ glWindow.addWindowListener(new TraceWindowAdapter(new WindowAction(eventFifo)));
- glWindow2.setTitle("NEWT - CHILD");
- glWindow2.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo)));
- glWindow2.addWindowListener(new TraceWindowAdapter(new WindowAction(eventFifo)));
- glWindow2.setVisible(true);
+ if(deferredPeer) {
+ if(useLayout) {
+ frame.add(overlayedAWTComponent, BorderLayout.CENTER);
+ }
+ frame.setVisible(true); // should have native peers after this - and all childs shall be visible!
+ }
- GLEventListener demo2 = new Gears();
- setDemoFields(demo2, window2, glWindow2, false);
- glWindow2.addGLEventListener(demo2);
+ GLEventListener demo = new Gears();
+ setDemoFields(demo, glWindow, false);
+ glWindow.addGLEventListener(demo);
long duration = durationPerTest;
long step = 20;
NEWTEvent event;
- boolean shouldQuit = false;
- while (duration>0 && !shouldQuit) {
- glWindow2.display();
+ while (duration>0 && !glWindow.isDestroyed()) {
+ glWindow.display();
Thread.sleep(step);
duration -= step;
while( null != ( event = (NEWTEvent) eventFifo.get() ) ) {
Window source = (Window) event.getSource();
- if(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY == event.getEventType()) {
- shouldQuit = true;
- } else if(event instanceof KeyEvent) {
+ if(event instanceof KeyEvent) {
KeyEvent keyEvent = (KeyEvent) event;
switch(keyEvent.getKeyChar()) {
case 'q':
- shouldQuit = true;
+ glWindow.destroy();
break;
case 'f':
source.setFullscreen(!source.isFullscreen());
@@ -178,13 +173,17 @@ public class TestParenting01AWT {
}
}
}
- destroyWindow(null, null, window2, glWindow2);
+ glWindow.destroy();
+ if(useLayout) {
+ frame.remove(overlayedAWTComponent);
+ }
frame.dispose();
}
- public static void setDemoFields(GLEventListener demo, Window window, GLWindow glWindow, boolean debug) {
+ public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) {
Assert.assertNotNull(demo);
- Assert.assertNotNull(window);
+ Assert.assertNotNull(glWindow);
+ Window window = glWindow.getWindow();
if(debug) {
MiscUtils.setFieldIfExists(demo, "glDebug", true);
MiscUtils.setFieldIfExists(demo, "glTrace", true);
diff --git a/src/junit/com/jogamp/test/junit/newt/TestParenting01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestParenting01NEWT.java
index 1940534dd..ee135e83e 100755
--- a/src/junit/com/jogamp/test/junit/newt/TestParenting01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestParenting01NEWT.java
@@ -68,23 +68,17 @@ public class TestParenting01NEWT {
height = 480;
}
- static Window createWindow(NativeWindow parent, Screen screen, Capabilities caps, int width, int height) {
+ static Window createWindow(Screen screen, Capabilities caps) {
Assert.assertNotNull(caps);
- Window window;
- window = ( null == parent ) ? NewtFactory.createWindow(screen, caps, false) : NewtFactory.createWindow(parent, screen, caps, false) ;
+ Window window = NewtFactory.createWindow(screen, caps, false) ;
Assert.assertNotNull(window);
- window.setSize(width, height);
- Assert.assertTrue(false==window.isVisible());
- Assert.assertTrue(width==window.getWidth());
- Assert.assertTrue(height==window.getHeight());
+ return window;
+ }
- caps = window.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ static Window createWindow(NativeWindow parent, Capabilities caps) {
Assert.assertNotNull(caps);
- Assert.assertTrue(caps.getGreenBits()>5);
- Assert.assertTrue(caps.getBlueBits()>5);
- Assert.assertTrue(caps.getRedBits()>5);
- Assert.assertTrue(caps.isOnscreen()==true);
-
+ Window window = NewtFactory.createWindow(parent, caps, true);
+ Assert.assertNotNull(window);
return window;
}
@@ -117,30 +111,38 @@ public class TestParenting01NEWT {
NEWTEventFiFo eventFifo = new NEWTEventFiFo();
- Window window1 = createWindow( null, screen, caps, width, height );
+ Window window1 = createWindow(screen, caps);
Assert.assertNotNull(window1);
GLWindow glWindow1 = GLWindow.create(window1);
Assert.assertNotNull(glWindow1);
- Assert.assertTrue(width==glWindow1.getWidth());
- Assert.assertTrue(height==glWindow1.getHeight());
+ glWindow1.setSize(width, height);
+ Assert.assertEquals(width,glWindow1.getWidth());
+ Assert.assertEquals(height,glWindow1.getHeight());
glWindow1.setTitle("testWindowParenting01NewtOnNewtParentChildDraw - PARENT");
glWindow1.setPosition(x,y);
glWindow1.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo)));
glWindow1.addWindowListener(new TraceWindowAdapter());
glWindow1.setVisible(true);
+ Capabilities capsChosen = glWindow1.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ Assert.assertNotNull(capsChosen);
+ Assert.assertTrue(capsChosen.isOnscreen()==true);
- Window window2 = createWindow(window1, screen, caps, width/2, height/2);
+ Window window2 = createWindow(window1, caps);
Assert.assertNotNull(window2);
GLWindow glWindow2 = GLWindow.create(window2);
Assert.assertNotNull(glWindow2);
- Assert.assertTrue(width/2==glWindow2.getWidth());
- Assert.assertTrue(height/2==glWindow2.getHeight());
+ glWindow2.setSize(width/2, height/2);
+ //Assert.assertEquals(width/2,glWindow2.getWidth());
+ //Assert.assertEquals(height/2,glWindow2.getHeight());
glWindow2.setTitle("testWindowParenting01NewtOnNewtParentChildDraw - CHILD");
glWindow2.setPosition(glWindow1.getWidth()/2, glWindow1.getHeight()/2);
glWindow2.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo)));
glWindow2.addWindowListener(new TraceWindowAdapter(new WindowAction(eventFifo)));
// glWindow2.addMouseListener(new TraceMouseAdapter());
glWindow2.setVisible(true);
+ capsChosen = glWindow2.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ Assert.assertNotNull(capsChosen);
+ Assert.assertTrue(capsChosen.isOnscreen()==true);
GLEventListener demo1 = new RedSquare();
setDemoFields(demo1, window1, glWindow1, false);
diff --git a/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java
index 4969a685f..e0affa4ab 100755
--- a/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestWindows01NEWT.java
@@ -69,11 +69,11 @@ public class TestWindows01NEWT {
Window window = NewtFactory.createWindow(screen, caps, onscreen && undecorated);
Assert.assertNotNull(window);
window.setSize(width, height);
- Assert.assertTrue(false==window.isVisible());
+ Assert.assertEquals(false,window.isVisible());
window.setVisible(true);
- Assert.assertTrue(true==window.isVisible());
- Assert.assertTrue(width==window.getWidth());
- Assert.assertTrue(height==window.getHeight());
+ Assert.assertEquals(true,window.isVisible());
+ // Assert.assertEquals(width,window.getWidth());
+ // Assert.assertEquals(height,window.getHeight());
// System.out.println("Created: "+window);
//
@@ -85,7 +85,7 @@ public class TestWindows01NEWT {
Assert.assertTrue(caps.getGreenBits()>5);
Assert.assertTrue(caps.getBlueBits()>5);
Assert.assertTrue(caps.getRedBits()>5);
- Assert.assertTrue(caps.isOnscreen()==onscreen);
+ Assert.assertEquals(caps.isOnscreen(),onscreen);
return window;
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTUtil.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTUtil.java
index b3c706ed8..527d7750d 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTUtil.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTUtil.java
@@ -42,6 +42,7 @@ import javax.media.nativewindow.*;
import java.awt.GraphicsEnvironment;
import java.lang.reflect.*;
+import java.security.*;
public class JAWTUtil {
@@ -53,6 +54,12 @@ public class JAWTUtil {
private static final Method isQueueFlusherThread;
private static final boolean j2dExist;
+ private static Class sunToolkitClass;
+ private static Method sunToolkitAWTLockMethod;
+ private static Method sunToolkitAWTUnlockMethod;
+ private static final boolean hasSunToolkitAWTLock;
+ private static final boolean useSunToolkitAWTLock;
+
static {
JAWTJNILibLoader.loadAWTImpl();
JAWTJNILibLoader.loadNativeWindow("awt");
@@ -73,6 +80,32 @@ public class JAWTUtil {
j2dClazz = jC;
isQueueFlusherThread = m;
j2dExist = ok;
+
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ try {
+ sunToolkitClass = Class.forName("sun.awt.SunToolkit");
+ sunToolkitAWTLockMethod = sunToolkitClass.getDeclaredMethod("awtLock", new Class[] {});
+ sunToolkitAWTLockMethod.setAccessible(true);
+ sunToolkitAWTUnlockMethod = sunToolkitClass.getDeclaredMethod("awtUnlock", new Class[] {});
+ sunToolkitAWTUnlockMethod.setAccessible(true);
+ } catch (Exception e) {
+ // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5
+ }
+ return null;
+ }
+ });
+ boolean _hasSunToolkitAWTLock = false;
+ if ( null!=sunToolkitAWTLockMethod && null!=sunToolkitAWTUnlockMethod ) {
+ try {
+ sunToolkitAWTLockMethod.invoke(null, null);
+ sunToolkitAWTUnlockMethod.invoke(null, null);
+ _hasSunToolkitAWTLock = true;
+ } catch (Exception e) {}
+ }
+ hasSunToolkitAWTLock = _hasSunToolkitAWTLock;
+ // useSunToolkitAWTLock = hasSunToolkitAWTLock;
+ useSunToolkitAWTLock = false;
}
private static Exception lockedStack;
@@ -99,6 +132,30 @@ public class JAWTUtil {
return headlessMode;
}
+ private static void awtLock() {
+ if(useSunToolkitAWTLock) {
+ try {
+ sunToolkitAWTLockMethod.invoke(null, null);
+ } catch (Exception e) {
+ throw new NativeWindowException("SunToolkit.awtLock failed", e);
+ }
+ } else {
+ JAWT.getJAWT().Lock();
+ }
+ }
+
+ private static void awtUnlock() {
+ if(useSunToolkitAWTLock) {
+ try {
+ sunToolkitAWTUnlockMethod.invoke(null, null);
+ } catch (Exception e) {
+ throw new NativeWindowException("SunToolkit.awtUnlock failed", e);
+ }
+ } else {
+ JAWT.getJAWT().Unlock();
+ }
+ }
+
public static synchronized void lockToolkit() throws NativeWindowException {
if (isJava2DQueueFlusherThread()) return;
@@ -115,7 +172,7 @@ public class JAWTUtil {
return;
}
- JAWT.getJAWT().Lock();
+ awtLock();
}
public static synchronized void unlockToolkit() {
@@ -130,7 +187,7 @@ public class JAWTUtil {
return;
}
- JAWT.getJAWT().Unlock();
+ awtUnlock();
}
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java
index f2977e8f0..77bf93204 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java
@@ -37,6 +37,7 @@
package com.jogamp.nativewindow.impl.jawt.x11;
import javax.media.nativewindow.*;
+import javax.media.nativewindow.awt.*;
import javax.media.nativewindow.x11.*;
import com.jogamp.nativewindow.impl.x11.*;
@@ -53,6 +54,19 @@ public class X11JAWTWindow extends JAWTWindow {
}
protected void initNative() throws NativeWindowException {
+ if(0==config.getScreen().getDevice().getHandle()) {
+ AWTGraphicsDevice awtDevice = (AWTGraphicsDevice) config.getScreen().getDevice();
+ NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
+ try {
+ long displayHandle = X11SunJDKReflection.graphicsDeviceGetDisplay(awtDevice.getGraphicsDevice());
+ if(0==displayHandle) {
+ displayHandle = X11Util.createThreadLocalDefaultDisplay();
+ }
+ awtDevice.setHandle(displayHandle);
+ } finally {
+ NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
+ }
+ }
}
public synchronized int lockSurface() throws NativeWindowException {
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java
index d93302e57..196e8f4e2 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java
@@ -56,7 +56,17 @@ public class X11Util {
static {
NWJNILibLoader.loadNativeWindow("x11");
- initialize();
+
+ // No concurrent threading support in case AWT could be used,
+ // Mixing AWT and X11/NEWT results in a segmentation fault:
+ // C pthread_mutex_lock+0x4
+ // J sun.awt.X11.XlibWrapper.XGetDefault
+ // J sun.awt.X11.XToolkit.initializeMultiClickTime
+ // J sun.awt.X11.XToolkit.getMultiClickTime
+ //
+ // It seems like (Oracle's) AWT's Display locking is buggy.
+ //
+ initialize( ! NativeWindowFactory.isAWTAvailable() ) ;
}
public static void initSingleton() {
@@ -142,6 +152,8 @@ public class X11Util {
if(0==dpy) {
throw new NativeWindowException("X11Util.Display: Unable to create a display("+name+") connection in Thread "+Thread.currentThread().getName());
}
+ // if you like to debug and synchronize X11 commands ..
+ // setSynchronizeDisplay(dpy, true);
namedDpy = new NamedDisplay(name, dpy);
addCurrentDisplay( namedDpy );
synchronized(globalLock) {
@@ -207,6 +219,22 @@ public class X11Util {
return closeThreadLocalDisplay(ndpy.getName());
}
+ public static boolean setSynchronizeDisplay(long handle, boolean onoff) {
+ String name;
+ XLockDisplay(handle);
+ boolean res = X11Lib.XSynchronize(handle, onoff);
+ XUnlockDisplay(handle);
+ return res;
+ }
+
+ public static String getNameOfDisplay(long handle) {
+ String name;
+ XLockDisplay(handle);
+ name = X11Lib.XDisplayString(handle);
+ XUnlockDisplay(handle);
+ return name;
+ }
+
public static void XLockDisplay(long handle) {
if(DEBUG_XDISPLAY_LOCK) {
NamedDisplay ndpy;
@@ -298,5 +326,5 @@ public class X11Util {
return (NamedDisplay) displayMap.get(name);
}
- private static native void initialize();
+ private static native void initialize(boolean initConcurrentThreadSupport);
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
index 944fdee74..2125fb4c0 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
@@ -74,6 +74,8 @@ public abstract class NativeWindowFactory {
private static String nativeOSNamePure;
private static String nativeWindowingTypeCustom;
private static String nativeOSNameCustom;
+ private static final boolean isAWTAvailable;
+ private static final String awtComponentClassName = "java.awt.Component" ;
/** Creates a new NativeWindowFactory instance. End users do not
need to call this method. */
@@ -123,21 +125,17 @@ public abstract class NativeWindowFactory {
// We break compile-time dependencies on the AWT here to
// make it easier to run this code on mobile devices
- Class componentClass = null;
- if ( ReflectionUtil.isClassAvailable("java.awt.Component") &&
- ReflectionUtil.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice") ) {
- try {
- componentClass = ReflectionUtil.getClass("java.awt.Component", false);
- } catch (Exception e) { }
- }
+ isAWTAvailable = !Debug.getBooleanProperty("java.awt.headless", true, acc) &&
+ ReflectionUtil.isClassAvailable(awtComponentClassName) &&
+ ReflectionUtil.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice") ;
boolean toolkitLockForced = Debug.getBooleanProperty("nativewindow.locking", true, acc);
- boolean awtToolkitLockDisabled = Debug.getBooleanProperty("java.awt.headless", true, acc) ||
+ boolean awtToolkitLockDisabled = !isAWTAvailable ||
Debug.getBooleanProperty("nativewindow.nolocking", true, acc) ;
NativeWindowFactory _factory = null;
- if( !awtToolkitLockDisabled && null!=componentClass && TYPE_X11.equals(nativeWindowingTypeCustom) ) {
+ if( !awtToolkitLockDisabled && TYPE_X11.equals(nativeWindowingTypeCustom) ) {
// There are certain operations that may be done by
// user-level native code which must share the display
// connection with the underlying window toolkit. In JOGL,
@@ -195,9 +193,9 @@ public abstract class NativeWindowFactory {
factory = _factory;
}
- if(null!=componentClass) {
+ if ( isAWTAvailable ) {
// register either our default factory or (if exist) the X11/AWT one -> AWT Component
- registerFactory(componentClass, factory);
+ registerFactory(ReflectionUtil.getClass(awtComponentClassName, false), factory);
}
defaultFactory = factory;
@@ -207,6 +205,9 @@ public abstract class NativeWindowFactory {
}
}
+ /** @return true if not headless, AWT Component and NativeWindow's AWT part available */
+ public static boolean isAWTAvailable() { return isAWTAvailable; }
+
public static String getNativeOSName(boolean useCustom) {
return useCustom?nativeOSNameCustom:nativeOSNamePure;
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
index 9b48f8f6e..f56248e67 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
@@ -40,7 +40,9 @@
package javax.media.nativewindow.awt;
import javax.media.nativewindow.*;
+import java.awt.Component;
import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
import java.awt.Transparency;
import java.awt.image.ColorModel;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
@@ -67,6 +69,40 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple
this.encapsulated=null;
}
+ /**
+ * @param capsChosen if null, <code>capsRequested</code> is copied and aligned
+ * with the graphics capabilties of the AWT Component to produce the chosen Capabilties.
+ * Otherwise the <code>capsChosen</code> is used.
+ */
+ public static AWTGraphicsConfiguration create(Component awtComp, Capabilities capsChosen, Capabilities capsRequested)
+ {
+ AWTGraphicsScreen awtScreen = null;
+ AWTGraphicsDevice awtDevice = null;
+ GraphicsDevice awtGraphicsDevice = null;
+ GraphicsConfiguration awtGfxConfig = awtComp.getGraphicsConfiguration();
+ if(null!=awtGfxConfig) {
+ awtGraphicsDevice = awtGfxConfig.getDevice();
+ if(null!=awtGraphicsDevice) {
+ // Create Device/Screen
+ awtDevice = new AWTGraphicsDevice(awtGraphicsDevice);
+ awtScreen = new AWTGraphicsScreen(awtDevice);
+ }
+ }
+ if(null==awtScreen) {
+ // use defaults since no native peer is available yet
+ awtScreen = (AWTGraphicsScreen) AWTGraphicsScreen.createScreenDevice(-1);
+ awtDevice = (AWTGraphicsDevice) awtScreen.getDevice();
+ awtGraphicsDevice = awtDevice.getGraphicsDevice();
+ }
+
+ if(null==capsChosen) {
+ capsChosen = (Capabilities) capsRequested.clone() ;
+ GraphicsConfiguration gc = awtGraphicsDevice.getDefaultConfiguration();
+ setupCapabilitiesRGBABits(capsChosen, gc);
+ }
+ return new AWTGraphicsConfiguration(awtScreen, capsChosen, capsRequested, awtGfxConfig);
+ }
+
public Object clone() {
return super.clone();
}
diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c
index b8a5004c4..23ff5f854 100644
--- a/src/nativewindow/native/x11/Xmisc.c
+++ b/src/nativewindow/native/x11/Xmisc.c
@@ -247,8 +247,18 @@ static void x11IOErrorHandlerEnable(int onoff, JNIEnv * env) {
static int _initialized=0;
JNIEXPORT void JNICALL
-Java_com_jogamp_nativewindow_impl_x11_X11Util_initialize(JNIEnv *env, jclass _unused) {
+Java_com_jogamp_nativewindow_impl_x11_X11Util_initialize(JNIEnv *env, jclass _unused, jboolean initConcurrentThreadSupport) {
if(0==_initialized) {
+ if( JNI_TRUE == initConcurrentThreadSupport ) {
+ if( 0 == XInitThreads() ) {
+ fprintf(stderr, "Warning: XInitThreads() failed\n");
+ } else {
+ fprintf(stderr, "Info: XInitThreads() called for concurrent Thread support\n");
+ }
+ } else {
+ fprintf(stderr, "Info: XInitThreads() _not_ called for concurrent Thread support\n");
+ }
+
_initClazzAccess(env);
x11ErrorHandlerEnable(1, env);
x11IOErrorHandlerEnable(1, env);
@@ -350,7 +360,6 @@ Java_com_jogamp_nativewindow_impl_x11_X11Lib_XUnlockDisplay__J(JNIEnv *env, jcla
XUnlockDisplay((Display *) (intptr_t) display);
}
-
/* Java->C glue code:
* Java package: com.jogamp.nativewindow.impl.x11.X11Lib
* Java method: int XCloseDisplay(long display)
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java
index abd03d13d..6705db970 100755
--- a/src/newt/classes/com/jogamp/newt/Display.java
+++ b/src/newt/classes/com/jogamp/newt/Display.java
@@ -125,8 +125,11 @@ public abstract class Display {
}
/** Make sure to reuse a Display with the same name */
- protected static Display create(String type, String name) {
+ protected static Display create(String type, String name, final long handle) {
try {
+ if(null==name && 0!=handle) {
+ name="wrapping-0x"+Long.toHexString(handle); // may change within implementation ..
+ }
if(DEBUG) {
dumpDisplayMap("Display.create("+getFQName(type, name)+") BEGIN");
}
@@ -152,11 +155,11 @@ public abstract class Display {
display.edt = display.edtUtil.start();
display.edtUtil.invokeAndWait(new Runnable() {
public void run() {
- f_dpy.createNative();
+ f_dpy.createNative(handle);
}
} );
} else {
- display.createNative();
+ display.createNative(handle);
}
if(null==display.aDevice) {
throw new RuntimeException("Display.createNative() failed to instanciate an AbstractGraphicsDevice");
@@ -182,19 +185,6 @@ public abstract class Display {
}
}
- protected static Display wrapHandle(String type, String name, AbstractGraphicsDevice aDevice) {
- try {
- Class displayClass = getDisplayClass(type);
- Display display = (Display) displayClass.newInstance();
- display.name=name;
- display.type=type;
- display.aDevice=aDevice;
- return display;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
public EDTUtil getEDTUtil() { return edtUtil; }
public synchronized void destroy() {
@@ -234,7 +224,7 @@ public abstract class Display {
}
}
- protected abstract void createNative();
+ protected abstract void createNative(long handle);
protected abstract void closeNative();
public final String getType() {
diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java
index 183acb3df..7860197ef 100755
--- a/src/newt/classes/com/jogamp/newt/NewtFactory.java
+++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java
@@ -78,14 +78,14 @@ public abstract class NewtFactory {
* Create a Display entity, incl native creation
*/
public static Display createDisplay(String name) {
- return Display.create(NativeWindowFactory.getNativeWindowType(true), name);
+ return Display.create(NativeWindowFactory.getNativeWindowType(true), name, 0);
}
/**
* Create a Display entity using the given implementation type, incl native creation
*/
public static Display createDisplay(String type, String name) {
- return Display.create(type, name);
+ return Display.create(type, name, 0);
}
/**
@@ -106,77 +106,99 @@ public abstract class NewtFactory {
* Create a top level Window entity, incl native creation
*/
public static Window createWindow(Screen screen, Capabilities caps) {
- return Window.create(NativeWindowFactory.getNativeWindowType(true), 0, screen, caps, false);
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), null, 0, screen, caps, false);
}
/**
* Create a top level Window entity, incl native creation
*/
public static Window createWindow(Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(NativeWindowFactory.getNativeWindowType(true), 0, screen, caps, undecorated);
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), null, 0, screen, caps, undecorated);
}
/**
- * Create a child Window entity attached to the given parent, incl native creation<br>
+ * Create a child Window entity attached to the given parent, incl native creation.<br>
+ * The Screen and Display information is regenrated utilizing the parents information.<br>
* <p>
* In case <code>parentWindowObject</code> is a {@link javax.media.nativewindow.NativeWindow},<br>
* we create a child {@link com.jogamp.newt.Window},
- * utilizing {@link com.jogamp.newt.NewtFactory#createWindow(long, com.jogamp.newt.Screen, javax.media.nativewindow.Capabilities, boolean)}
- * passing the parent's native window handle retrieved via {@link javax.media.nativewindow.NativeWindow#getWindowHandle()}.<br></p>
+ * utilizing {@link com.jogamp.newt.NewtFactory#createWindowImpl(java.lang.String, javax.media.nativewindow.NativeWindow, com.jogamp.newt.Screen, javax.media.nativewindow.Capabilities, boolean)}<br></p>.
* <p>
* In case <code>parentWindowObject</code> is even a {@link com.jogamp.newt.Window}, the following applies:<br>
* {@link com.jogamp.newt.event.WindowEvent#EVENT_WINDOW_RESIZED} is not propagated to the child window for e.g. layout<br>,
* you have to add an appropriate {@link com.jogamp.newt.event.WindowListener} for this use case.<br>
* However, {@link com.jogamp.newt.event.WindowEvent#EVENT_WINDOW_DESTROY_NOTIFY} is propagated to the child window, so it will be closed properly.<br>
- * In case <code>parentWindowObject</code> is a different {@javax.media.nativewindow.NativeWindow} implementation,<br>
+ * The parents visibility is passed to the new Window<br></p>
+ * <p>
+ * In case <code>parentWindowObject</code> is a different {@link javax.media.nativewindow.NativeWindow} implementation,<br>
* you have to handle all events appropriatly.<br></p>
* <p>
* In case <code>parentWindowObject</code> is a {@link java.awt.Component},<br>
- * we utilize the {@link com.jogamp.newt.impl.awt.AWTNewtFactory#createNativeChildWindow(Object, com.jogamp.newt.Screen, com.jogamp.newt.Capabilities, boolean)}
+ * we utilize the {@link com.jogamp.newt.impl.awt.AWTNewtFactory#createNativeChildWindow(Object, com.jogamp.newt.Capabilities, boolean)}
* factory method.<br>
* The factory adds a {@link com.jogamp.newt.event.WindowListener} to propagate {@link com.jogamp.newt.event.WindowEvent}'s so
- * your NEWT Window integrates into the AWT layout.<br></p>
+ * your NEWT Window integrates into the AWT layout.<br>
+ * The parents visibility is passed to the new Window<br></p>
*
* @param parentWindowObject either a NativeWindow or java.awt.Component
* @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always
*
* @see com.jogamp.newt.NewtFactory#createWindow(long, com.jogamp.newt.Screen, javax.media.nativewindow.Capabilities, boolean)
- * @see com.jogamp.newt.impl.awt.AWTNewtFactory#createNativeChildWindow(java.lang.Object, com.jogamp.newt.Screen, javax.media.nativewindow.Capabilities, boolean)
+ * @see com.jogamp.newt.impl.awt.AWTNewtFactory#createNativeChildWindow(java.lang.Object, javax.media.nativewindow.Capabilities, boolean)
*/
- public static Window createWindow(Object parentWindowObject, Screen screen, Capabilities caps, boolean undecorated) {
+ public static Window createWindow(Object parentWindowObject, Capabilities caps, boolean undecorated) {
+ final String type = NativeWindowFactory.getNativeWindowType(true);
if(null==parentWindowObject) {
- throw new RuntimeException("Null parentWindowObject");
+ return createWindowImpl(type, null, null, caps, undecorated);
}
if(parentWindowObject instanceof NativeWindow) {
- NativeWindow nativeParentWindow = (NativeWindow) parentWindowObject;
- nativeParentWindow.lockSurface();
- long parentWindowHandle = nativeParentWindow.getWindowHandle();
- nativeParentWindow.unlockSurface();
- final Window win = createWindow(parentWindowHandle, screen, caps, undecorated);
- if ( nativeParentWindow instanceof Window) {
- final Window f_nativeParentWindow = (Window) nativeParentWindow ;
- f_nativeParentWindow.addWindowListener(new WindowAdapter() {
+ NativeWindow nParentWindow = (NativeWindow) parentWindowObject;
+
+ Display display=null;
+ Screen screen=null;
+ Window parentWindow=null;
+
+ if ( nParentWindow instanceof Window ) {
+ parentWindow = (Window) nParentWindow ;
+ Screen nParentScreen = parentWindow.getScreen();
+ Display nParentDisplay = nParentScreen.getDisplay();
+ display = NewtFactory.wrapDisplay(type, nParentDisplay.getHandle());
+ screen = NewtFactory.createScreen(type, display, nParentScreen.getIndex());
+ } else {
+ AbstractGraphicsConfiguration nParentConfig = nParentWindow.getGraphicsConfiguration();
+ AbstractGraphicsScreen nParentScreen = nParentConfig.getScreen();
+ AbstractGraphicsDevice nParentDevice = nParentScreen.getDevice();
+ display = NewtFactory.wrapDisplay(type, nParentDevice.getHandle());
+ screen = NewtFactory.createScreen(type, display, nParentScreen.getIndex());
+ }
+ final Window win = createWindowImpl(type, nParentWindow, screen, caps, undecorated);
+
+ win.setSize(nParentWindow.getWidth(), nParentWindow.getHeight());
+ if ( null != parentWindow ) {
+ parentWindow.addWindowListener(new WindowAdapter() {
public void windowDestroyNotify(WindowEvent e) {
win.sendEvent(e);
}
});
+ win.setVisible(parentWindow.isVisible());
}
return win;
} else {
if(ReflectionUtil.instanceOf(parentWindowObject, "java.awt.Component")) {
if(ReflectionUtil.isClassAvailable("com.jogamp.newt.impl.awt.AWTNewtFactory")) {
- return (Window) ReflectionUtil.callStaticMethod("com.jogamp.newt.impl.awt.AWTNewtFactory",
- "createNativeChildWindow",
- new Class[] { Object.class, Screen.class, Capabilities.class, java.lang.Boolean.TYPE},
- new Object[] { parentWindowObject, screen, caps, new Boolean(undecorated) } );
+ return (Window) ReflectionUtil.callStaticMethod(
+ "com.jogamp.newt.impl.awt.AWTNewtFactory",
+ "createNativeChildWindow",
+ new Class[] { Object.class, Capabilities.class, java.lang.Boolean.TYPE},
+ new Object[] { parentWindowObject, caps, new Boolean(undecorated) } );
}
}
}
throw new RuntimeException("No NEWT child Window factory method for parent object: "+parentWindowObject);
}
- public static Window createWindow(Object parentWindowObject, Screen screen, Capabilities caps) {
- return createWindow(parentWindowObject, screen, caps, false);
+ protected static Window createWindowImpl(String type, NativeWindow parentNativeWindow, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(type, parentNativeWindow, 0, screen, caps, undecorated);
}
/**
@@ -186,14 +208,7 @@ public abstract class NewtFactory {
* @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always
*/
public static Window createWindow(long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) {
- if(0==parentWindowHandle) {
- throw new RuntimeException("Null parentWindowHandle");
- }
- return Window.create(NativeWindowFactory.getNativeWindowType(true), parentWindowHandle, screen, caps, undecorated);
- }
-
- public static Window createWindow(long parentWindowHandle, Screen screen, Capabilities caps) {
- return createWindow(parentWindowHandle, screen, caps, false);
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), null, parentWindowHandle, screen, caps, undecorated);
}
/**
@@ -213,7 +228,7 @@ public abstract class NewtFactory {
* @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always
*/
public static Window createWindow(String type, Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(type, 0, screen, caps, undecorated);
+ return Window.create(type, null, 0, screen, caps, undecorated);
}
public static Window createWindow(String type, Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
@@ -223,25 +238,8 @@ public abstract class NewtFactory {
/**
* Instantiate a Display entity using the native handle.
*/
- public static Display wrapDisplay(String name, AbstractGraphicsDevice device) {
- return Display.wrapHandle(NativeWindowFactory.getNativeWindowType(true), name, device);
- }
-
- /**
- * Instantiate a Screen entity using the native handle.
- */
- public static Screen wrapScreen(Display display, AbstractGraphicsScreen screen) {
- return Screen.wrapHandle(NativeWindowFactory.getNativeWindowType(true), display, screen);
- }
-
- /**
- * Instantiate a Window entity using the native handle.
- */
- public static Window wrapWindow(Screen screen, AbstractGraphicsConfiguration config,
- long windowHandle, boolean fullscreen, boolean visible,
- int x, int y, int width, int height) {
- return Window.wrapHandle(NativeWindowFactory.getNativeWindowType(true), screen, config,
- windowHandle, fullscreen, visible, x, y, width, height);
+ public static Display wrapDisplay(String type, long handle) {
+ return Display.create(type, null, handle);
}
private static final boolean instanceOf(Object obj, String clazzName) {
diff --git a/src/newt/classes/com/jogamp/newt/OffscreenWindow.java b/src/newt/classes/com/jogamp/newt/OffscreenWindow.java
index c9c56fc61..5b957afa5 100644
--- a/src/newt/classes/com/jogamp/newt/OffscreenWindow.java
+++ b/src/newt/classes/com/jogamp/newt/OffscreenWindow.java
@@ -44,7 +44,7 @@ public class OffscreenWindow extends Window implements SurfaceChangeable {
static long nextWindowHandle = 0x100; // start here - a marker
- protected void createNative(long parentWindowHandle, Capabilities caps) {
+ protected void createNativeImpl() {
if(0!=parentWindowHandle) {
throw new NativeWindowException("OffscreenWindow does not support window parenting");
}
@@ -83,10 +83,7 @@ public class OffscreenWindow extends Window implements SurfaceChangeable {
return surfaceHandle;
}
- public void setVisible(boolean visible) {
- if(!visible) {
- this.visible = visible;
- }
+ protected void setVisibleImpl() {
}
public void setSize(int width, int height) {
diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java
index 7bf520332..26342519e 100755
--- a/src/newt/classes/com/jogamp/newt/Screen.java
+++ b/src/newt/classes/com/jogamp/newt/Screen.java
@@ -67,7 +67,9 @@ public abstract class Screen {
if(usrWidth<0 || usrHeight<0) {
usrWidth = Debug.getIntProperty("newt.ws.swidth", true, localACC);
usrHeight = Debug.getIntProperty("newt.ws.sheight", true, localACC);
- System.out.println("User screen size "+usrWidth+"x"+usrHeight);
+ if(usrWidth>0 || usrHeight>0) {
+ System.out.println("User screen size "+usrWidth+"x"+usrHeight);
+ }
}
Class screenClass = getScreenClass(type);
Screen screen = (Screen) screenClass.newInstance();
@@ -88,18 +90,6 @@ public abstract class Screen {
aScreen = null;
}
- protected static Screen wrapHandle(String type, Display display, AbstractGraphicsScreen aScreen) {
- try {
- Class screenClass = getScreenClass(type);
- Screen screen = (Screen) screenClass.newInstance();
- screen.display = display;
- screen.aScreen = aScreen;
- return screen;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
protected abstract void createNative(int index);
protected abstract void closeNative();
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index 869ca2cf3..978b7f068 100755
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -88,8 +88,12 @@ public abstract class Window implements NativeWindow
return windowClass;
}
- protected static Window create(String type, final long parentWindowHandle, Screen screen, final Capabilities caps, boolean undecorated) {
+ protected static Window create(String type, NativeWindow parentNativeWindow, long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) {
try {
+ if(null==screen) {
+ Display display = NewtFactory.createDisplay(type, null); // local display
+ screen = NewtFactory.createScreen(type, display, 0); // screen 0
+ }
Class windowClass;
if(caps.isOnscreen()) {
windowClass = getWindowClass(type);
@@ -98,22 +102,11 @@ public abstract class Window implements NativeWindow
}
Window window = (Window) windowClass.newInstance();
window.invalidate();
- window.screen = screen;
+ window.parentNativeWindow = parentNativeWindow;
+ window.parentWindowHandle = parentWindowHandle;
+ window.screen = screen;
+ window.caps = (Capabilities)caps.clone();
window.setUndecorated(undecorated||0!=parentWindowHandle);
- EDTUtil edtUtil = screen.getDisplay().getEDTUtil();
- if(null!=edtUtil) {
- final Window f_win = window;
- edtUtil.invokeAndWait(new Runnable() {
- public void run() {
- f_win.createNative(parentWindowHandle, caps);
- }
- } );
- } else {
- window.createNative(parentWindowHandle, caps);
- }
- if(DEBUG_WINDOW_EVENT) {
- System.out.println("Window.create-1() done ("+Thread.currentThread()+", "+window+")");
- }
return window;
} catch (Throwable t) {
t.printStackTrace();
@@ -121,7 +114,7 @@ public abstract class Window implements NativeWindow
}
}
- protected static Window create(String type, Object[] cstrArguments, Screen screen, final Capabilities caps, boolean undecorated) {
+ protected static Window create(String type, Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
try {
Class windowClass = getWindowClass(type);
Class[] cstrArgumentTypes = getCustomConstructorArgumentTypes(windowClass);
@@ -134,52 +127,15 @@ public abstract class Window implements NativeWindow
}
Window window = (Window) ReflectionUtil.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ;
window.invalidate();
- window.screen = screen;
+ window.screen = screen;
+ window.caps = (Capabilities)caps.clone();
window.setUndecorated(undecorated);
- EDTUtil edtUtil = screen.getDisplay().getEDTUtil();
- if(null!=edtUtil) {
- final Window f_win = window;
- edtUtil.invokeAndWait(new Runnable() {
- public void run() {
- f_win.createNative(0, caps);
- }
- } );
- } else {
- window.createNative(0, caps);
- }
- if(DEBUG_WINDOW_EVENT) {
- System.out.println("Window.create-2() done ("+Thread.currentThread()+", "+window+")");
- }
return window;
} catch (Throwable t) {
throw new NativeWindowException(t);
}
}
- protected static Window wrapHandle(String type, Screen screen, AbstractGraphicsConfiguration config,
- long windowHandle, boolean fullscreen, boolean visible,
- int x, int y, int width, int height)
- {
- try {
- Class windowClass = getWindowClass(type);
- Window window = (Window) windowClass.newInstance();
- window.invalidate();
- window.screen = screen;
- window.config = config;
- window.windowHandle = windowHandle;
- window.fullscreen=fullscreen;
- window.visible=visible;
- window.x=x;
- window.y=y;
- window.width=width;
- window.height=height;
- return window;
- } catch (Throwable t) {
- t.printStackTrace();
- throw new NativeWindowException(t);
- }
- }
-
public static String toHexString(int hex) {
return "0x" + Integer.toHexString(hex);
}
@@ -190,6 +146,10 @@ public abstract class Window implements NativeWindow
protected Screen screen;
+ private NativeWindow parentNativeWindow;
+ protected long parentWindowHandle;
+
+ protected Capabilities caps;
protected AbstractGraphicsConfiguration config;
protected long windowHandle;
protected boolean fullscreen, visible;
@@ -199,16 +159,53 @@ public abstract class Window implements NativeWindow
protected String title = "Newt Window";
protected boolean undecorated = false;
+ private synchronized boolean createNative() {
+ if( null==screen || 0!=windowHandle || !visible ) {
+ // NOP .. or already done
+ return 0 != windowHandle ;
+ }
+ EDTUtil edtUtil = screen.getDisplay().getEDTUtil();
+ if( null != edtUtil && !edtUtil.isCurrentThreadEDT() ) {
+ throw new NativeWindowException("EDT enabled but not on EDT");
+ }
+
+ if(DEBUG_WINDOW_EVENT) {
+ System.out.println("Window.createNative() START ("+Thread.currentThread()+", "+this+")");
+ }
+ if(validateParentWindowHandle()) {
+ createNativeImpl();
+ setVisibleImpl();
+ }
+ if(DEBUG_WINDOW_EVENT) {
+ System.out.println("Window.createNative() END ("+Thread.currentThread()+", "+this+")");
+ }
+ return 0 != windowHandle ;
+ }
+
+ private boolean validateParentWindowHandle() {
+ boolean ok = true;
+ if(null!=parentNativeWindow) {
+ try {
+ parentNativeWindow.lockSurface();
+ } catch (NativeWindowException nwe) {
+ // parent native window not ready .. just skip action for now
+ ok = false;
+ }
+ if(ok) {
+ parentWindowHandle = parentNativeWindow.getWindowHandle();
+ parentNativeWindow.unlockSurface();
+ if(0==parentWindowHandle) {
+ throw new NativeWindowException("Parent native window handle is NULL, after succesful locking: "+parentNativeWindow);
+ }
+ }
+ }
+ return ok;
+ }
+
/**
* Create native windowHandle, ie creates a new native invisible window.
- *
- * The parentWindowHandle may be null, in which case no window parenting
- * is requested.
- *
- * Shall use the capabilities to determine the graphics configuration
- * and shall set the chosen capabilities.
*/
- protected abstract void createNative(long parentWindowHandle, Capabilities caps);
+ protected abstract void createNativeImpl();
protected abstract void closeNative();
@@ -371,18 +368,25 @@ public abstract class Window implements NativeWindow
e.printStackTrace();
}
screen = null;
+ parentNativeWindow = null;
+ parentWindowHandle = 0;
+ caps = null;
windowHandle = 0;
fullscreen=false;
visible=false;
eventMask = 0;
// Default position and dimension will be re-set immediately by user
- width = 100;
- height = 100;
+ width = 128;
+ height = 128;
x=0;
y=0;
}
+ public boolean isDestroyed() {
+ return null == screen ;
+ }
+
public boolean surfaceSwap() {
return false;
}
@@ -506,7 +510,62 @@ public abstract class Window implements NativeWindow
}
}
- public abstract void setVisible(boolean visible);
+ /**
+ * <p>
+ * <code>setVisible</code> makes the window visible if <code>visible</code> is true,
+ * otherwise the window becomes invisible.<br></p>
+ * <p>
+ * The <code>setVisible(true)</code> is responsible to actual create the native window.<br></p>
+ * <p>
+ * In case this window is a child window and a parent {@link javax.media.nativewindow.NativeWindow} is being used,<br>
+ * the parent's {@link javax.media.nativewindow.NativeWindow} handle is retrieved via {@link javax.media.nativewindow.NativeWindow#getWindowHandle()}.<br>
+ * If this action fails, ie if the parent {@link javax.media.nativewindow.NativeWindow} is not valid yet,<br>
+ * no native window is created yet and <code>setVisible(true)</code> shall be repeated when it is.<br></p>
+ */
+ public void setVisible(final boolean visible) {
+ setVisible(visible, false);
+ }
+
+ public void setVisible(final boolean visible, boolean deferred) {
+ if(!isDestroyed()) {
+ EDTUtil edtUtil = screen.getDisplay().getEDTUtil();
+ if(null!=edtUtil) {
+ edtUtil.invoke(deferred, new Runnable() {
+ public void run() {
+ setVisibleTask(visible);
+ }
+ });
+ } else {
+ setVisibleTask(visible);
+ }
+ }
+ }
+
+ private synchronized void setVisibleTask(final boolean visible) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("setVisibleTask: START ("+Thread.currentThread()+") "+this.x+"/"+this.y+" "+this.width+"x"+this.height+", fs "+fullscreen+", windowHandle "+windowHandle+", visible: "+this.visible+" -> "+visible);
+ }
+ int didit = 0;
+ if(0==windowHandle && visible) {
+ this.visible = visible;
+ didit = 01;
+ if( createNative() ) {
+ didit = 11;
+ }
+ } else if(this.visible != visible) {
+ this.visible = visible;
+ didit = 2;
+ if(0 != windowHandle) {
+ setVisibleImpl();
+ didit = 22;
+ }
+ }
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("setVisibleTask: END ("+Thread.currentThread()+") didit "+didit+", "+this.x+"/"+this.y+" "+this.width+"x"+this.height+", fs "+fullscreen+", windowHandle "+windowHandle+", visible: "+visible);
+ }
+ }
+
+ protected abstract void setVisibleImpl();
/**
* Sets the size of the client area of the window, excluding decorations
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java
index 9fd3d604b..3abe6531a 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java
@@ -136,6 +136,7 @@ public abstract class AWTAdapter implements java.util.EventListener
/**
* Create a pipeline adapter, AWT EventListener.<br>
* Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream window.<br>
+ * This is only supported with EDT enabled!
*/
public AWTAdapter(com.jogamp.newt.Window downstream) {
if(null==downstream) {
@@ -143,6 +144,9 @@ public abstract class AWTAdapter implements java.util.EventListener
}
this.newtListener = null;
this.newtWindow = downstream;
+ if( null == newtWindow.getScreen().getDisplay().getEDTUtil() ) {
+ throw new RuntimeException("EDT not enabled");
+ }
}
/**
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java
index 49d9bf0f2..01f0457e3 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java
@@ -52,11 +52,11 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter
}
public void windowActivated(java.awt.event.WindowEvent e) {
- // no propagation to NEWT child window ?? FIXME: Maybe yes in case of a 100% Opaque one ?
+ // no propagation to NEWT child window
}
public void windowDeactivated(java.awt.event.WindowEvent e) {
- // no propagation to NEWT child window ?? FIXME: Maybe yes in case of a 100% Opaque one ?
+ // no propagation to NEWT child window
}
}
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
index 2a5312d0b..fd6ceddae 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
@@ -31,8 +31,13 @@
*/
package com.jogamp.newt.event.awt;
-public class AWTWindowAdapter extends AWTAdapter implements java.awt.event.ComponentListener, java.awt.event.WindowListener
+public class AWTWindowAdapter
+ extends AWTAdapter
+ implements java.awt.event.ComponentListener, java.awt.event.WindowListener, java.awt.event.HierarchyListener
{
+ java.awt.Component awtComponent;
+ WindowClosingListener windowClosingListener;
+
public AWTWindowAdapter(com.jogamp.newt.event.WindowListener newtListener) {
super(newtListener);
}
@@ -46,13 +51,35 @@ public class AWTWindowAdapter extends AWTAdapter implements java.awt.event.Compo
}
public AWTAdapter addTo(java.awt.Component awtComponent) {
+ this.awtComponent = awtComponent;
awtComponent.addComponentListener(this);
+ awtComponent.addHierarchyListener(this);
+ addWindowClosingListenerTo(getWindow(awtComponent));
if(awtComponent instanceof java.awt.Window) {
((java.awt.Window)awtComponent).addWindowListener(this);
}
return this;
}
+ static java.awt.Window getWindow(java.awt.Component comp) {
+ while( null != comp && !(comp instanceof java.awt.Window) ) {
+ comp = comp.getParent();
+ }
+ if(comp instanceof java.awt.Window) {
+ return (java.awt.Window) comp;
+ }
+ return null;
+ }
+
+ void addWindowClosingListenerTo(java.awt.Window win) {
+ if( null == windowClosingListener ) {
+ windowClosingListener = new WindowClosingListener();
+ }
+ if( null != win ) {
+ win.addWindowListener(windowClosingListener);
+ }
+ }
+
public void componentResized(java.awt.event.ComponentEvent e) {
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(null!=newtListener) {
@@ -72,11 +99,19 @@ public class AWTWindowAdapter extends AWTAdapter implements java.awt.event.Compo
}
public void componentShown(java.awt.event.ComponentEvent e) {
- // n/a
+ if(null==newtListener) {
+ if(!newtWindow.isDestroyed()) {
+ newtWindow.setVisible(true, true /* deferred */);
+ }
+ }
}
public void componentHidden(java.awt.event.ComponentEvent e) {
- // n/a
+ if(null==newtListener) {
+ if(!newtWindow.isDestroyed()) {
+ newtWindow.setVisible(false, true /* deferred */);
+ }
+ }
}
public void windowActivated(java.awt.event.WindowEvent e) {
@@ -88,18 +123,9 @@ public class AWTWindowAdapter extends AWTAdapter implements java.awt.event.Compo
}
}
- public void windowClosed(java.awt.event.WindowEvent e) {
- // n/a
- }
+ public void windowClosed(java.awt.event.WindowEvent e) { }
- public void windowClosing(java.awt.event.WindowEvent e) {
- com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
- if(null!=newtListener) {
- ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyNotify(event);
- } else {
- enqueueEvent(event);
- }
- }
+ public void windowClosing(java.awt.event.WindowEvent e) { }
public void windowDeactivated(java.awt.event.WindowEvent e) {
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
@@ -110,17 +136,56 @@ public class AWTWindowAdapter extends AWTAdapter implements java.awt.event.Compo
}
}
- public void windowDeiconified(java.awt.event.WindowEvent e) {
- // n/a
+ public void windowDeiconified(java.awt.event.WindowEvent e) { }
+
+ public void windowIconified(java.awt.event.WindowEvent e) { }
+
+ public void windowOpened(java.awt.event.WindowEvent e) { }
+
+ public void hierarchyChanged(java.awt.event.HierarchyEvent e) {
+ if( null == newtListener ) {
+ long bits = e.getChangeFlags();
+ java.awt.Component changed = e.getChanged();
+ if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) {
+ final boolean visible = changed.isVisible();
+ if(!newtWindow.isDestroyed()) {
+ newtWindow.setVisible(visible, true /* deferred */);
+ }
+ } else if( 0 != ( java.awt.event.HierarchyEvent.PARENT_CHANGED & bits ) ) {
+ if(awtComponent == changed) {
+ java.awt.Window win = getWindow(changed);
+ if(null != win) {
+ addWindowClosingListenerTo(win);
+ } else {
+ java.awt.Component parent = e.getChangedParent();
+ if(parent instanceof java.awt.Window) {
+ ((java.awt.Window)parent).removeWindowListener(this);
+ if( null != windowClosingListener ) {
+ ((java.awt.Window)parent).removeWindowListener(windowClosingListener);
+ }
+ }
+ }
+ }
+ }
+ }
}
- public void windowIconified(java.awt.event.WindowEvent e) {
- // n/a
- }
+ class WindowClosingListener implements java.awt.event.WindowListener {
+ public void windowClosing(java.awt.event.WindowEvent e) {
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyNotify(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
- public void windowOpened(java.awt.event.WindowEvent e) {
- // n/a
+ public void windowActivated(java.awt.event.WindowEvent e) { }
+ public void windowClosed(java.awt.event.WindowEvent e) { }
+ public void windowDeactivated(java.awt.event.WindowEvent e) { }
+ public void windowDeiconified(java.awt.event.WindowEvent e) { }
+ public void windowIconified(java.awt.event.WindowEvent e) { }
+ public void windowOpened(java.awt.event.WindowEvent e) { }
}
-
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java
index f54e66f07..b0b518c59 100644
--- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java
@@ -44,7 +44,7 @@ public class AWTDisplay extends Display {
public AWTDisplay() {
}
- protected void createNative() {
+ protected void createNative(long handle) {
aDevice = (AWTGraphicsDevice) AWTGraphicsDevice.createDevice(null); // default
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java
index b42730a81..e0f86b1a9 100644
--- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java
+++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java
@@ -42,11 +42,13 @@ import javax.media.nativewindow.*;
import javax.media.nativewindow.awt.*;
import com.jogamp.newt.event.awt.AWTParentWindowAdapter;
+import com.jogamp.newt.Display;
import com.jogamp.newt.Screen;
import com.jogamp.newt.Window;
import com.jogamp.newt.NewtFactory;
+import com.jogamp.common.util.ReflectionUtil;
-public class AWTNewtFactory {
+public class AWTNewtFactory extends NewtFactory {
/**
* Wraps an AWT component into a {@link javax.media.nativewindow.NativeWindow} utilizing the {@link javax.media.nativewindow.NativeWindowFactory},<br>
@@ -60,19 +62,20 @@ public class AWTNewtFactory {
*
* @param awtCompObject must be of type java.awt.Component
*/
- public static NativeWindow getNativeWindow(Object awtCompObject) {
+ public static NativeWindow getNativeWindow(Object awtCompObject, Capabilities capsRequested) {
if(null==awtCompObject) {
throw new NativeWindowException("Null AWT Component");
}
if( ! (awtCompObject instanceof java.awt.Component) ) {
throw new NativeWindowException("AWT Component not a java.awt.Component");
}
- java.awt.Component awtComp = (java.awt.Component) awtCompObject;
- DefaultGraphicsDevice dummyDevice = new DefaultGraphicsDevice("AWTNewtBridge");
- DefaultGraphicsScreen dummyScreen = new DefaultGraphicsScreen(dummyDevice, 0);
- Capabilities dummyCaps = new Capabilities();
- DefaultGraphicsConfiguration dummyConfig = new DefaultGraphicsConfiguration(dummyScreen, dummyCaps, dummyCaps);
- NativeWindow awtNative = NativeWindowFactory.getNativeWindow(awtComp, dummyConfig);
+ return getNativeWindow( (java.awt.Component) awtCompObject, capsRequested );
+ }
+
+ public static NativeWindow getNativeWindow(java.awt.Component awtComp, Capabilities capsRequested) {
+ DefaultGraphicsConfiguration config =
+ AWTGraphicsConfiguration.create(awtComp, (Capabilities) capsRequested.clone(), capsRequested);
+ NativeWindow awtNative = NativeWindowFactory.getNativeWindow(awtComp, config); // a JAWTWindow
return awtNative;
}
@@ -84,30 +87,52 @@ public class AWTNewtFactory {
* The actual wrapping implementation is {@link com.jogamp.nativewindow.impl.jawt.JAWTWindow}.<br></p>
* <p>
* Second we create a child {@link com.jogamp.newt.Window},
- * utilizing {@link com.jogamp.newt.NewtFactory#createWindow(long, com.jogamp.newt.Screen, javax.media.nativewindow.Capabilities, boolean)},
- * passing the AWT parent's native window handle retrieved via {@link com.jogamp.nativewindow.impl.jawt.JAWTWindow#getWindowHandle()}.<br></p>
+ * utilizing {@link com.jogamp.newt.NewtFactory#createWindowImpl(java.lang.String, javax.media.nativewindow.NativeWindow, com.jogamp.newt.Screen, javax.media.nativewindow.Capabilities, boolean)},
+ * passing the created {@link javax.media.nativewindow.NativeWindow}.<br></p>
* <p>
* Third we attach a {@link com.jogamp.newt.event.awt.AWTParentWindowAdapter} to the given AWT component.<br>
* The adapter passes window related events to our new child window, look at the implementation<br></p>
*
+ * <p>
+ * Forth we pass the parents visibility to the new Window<br></p>
+ *
* @param awtParentObject must be of type java.awt.Component
* @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always
+ * @return The successful created child window, or null if the AWT parent is not ready yet (no valid peers)
*/
- public static Window createNativeChildWindow(Object awtParentObject, Screen newtScreen, Capabilities newtCaps, boolean undecorated) {
- NativeWindow parent = getNativeWindow(awtParentObject); // also checks java.awt.Component type
+ public static Window createNativeChildWindow(Object awtParentObject, Capabilities newtCaps, boolean undecorated) {
+ if( null == awtParentObject ) {
+ throw new NativeWindowException("Null AWT Parent Component");
+ }
+ if( ! (awtParentObject instanceof java.awt.Component) ) {
+ throw new NativeWindowException("AWT Parent Component not a java.awt.Component");
+ }
java.awt.Component awtParent = (java.awt.Component) awtParentObject;
+
+ // Generate a complete JAWT NativeWindow from the AWT Component
+ NativeWindow parent = getNativeWindow(awtParent, newtCaps);
if(null==parent) {
throw new NativeWindowException("Null NativeWindow from parent: "+awtParent);
}
- parent.lockSurface();
- long windowHandle = parent.getWindowHandle();
- parent.unlockSurface();
- if(0==windowHandle) {
- throw new NativeWindowException("Null window handle: "+parent);
- }
- Window window = NewtFactory.createWindow(windowHandle, newtScreen, newtCaps, undecorated);
+
+ // Get parent's NativeWindow details
+ AWTGraphicsConfiguration parentConfig = (AWTGraphicsConfiguration) parent.getGraphicsConfiguration();
+ AWTGraphicsScreen parentScreen = (AWTGraphicsScreen) parentConfig.getScreen();
+ AWTGraphicsDevice parentDevice = (AWTGraphicsDevice) parentScreen.getDevice();
+
+ // Prep NEWT's Display and Screen according to the parent
+ final String type = NativeWindowFactory.getNativeWindowType(true);
+ Display display = NewtFactory.wrapDisplay(type, parentDevice.getHandle());
+ Screen screen = NewtFactory.createScreen(type, display, parentScreen.getIndex());
+
+ // NEWT Window creation and add event handler for proper propagation AWT -> NEWT
+ // and copy size/visible state
+ Window window = NewtFactory.createWindowImpl(type, parent, screen, newtCaps, undecorated);
new AWTParentWindowAdapter(window).addTo(awtParent);
+ window.setSize(awtParent.getWidth(), awtParent.getHeight());
+ window.setVisible(awtParent.isVisible());
+
return window;
}
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java
index bc04f2523..b98a6fa20 100644
--- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java
@@ -34,6 +34,7 @@
package com.jogamp.newt.impl.awt;
import com.jogamp.newt.event.awt.*;
+import com.jogamp.newt.util.EDTUtil;
import java.awt.BorderLayout;
import java.awt.Canvas;
@@ -94,7 +95,7 @@ public class AWTWindow extends Window {
});
}
- protected void createNative(long parentWindowHandle, final Capabilities caps) {
+ protected void createNativeImpl() {
if(0!=parentWindowHandle) {
throw new RuntimeException("Window parenting not supported in AWT, use AWTWindow(Frame) cstr for wrapping instead");
@@ -175,7 +176,7 @@ public class AWTWindow extends Window {
return res;
}
- public void setVisible(final boolean visible) {
+ protected void setVisibleImpl() {
runOnEDT(true, new Runnable() {
public void run() {
container.setVisible(visible);
@@ -209,14 +210,16 @@ public class AWTWindow extends Window {
nfs_width=width;
nfs_height=height;
}
- /** An AWT event on setSize() would bring us in a deadlock situation, hence invokeLater() */
- runOnEDT(false, new Runnable() {
- public void run() {
- Insets insets = container.getInsets();
- container.setSize(width + insets.left + insets.right,
- height + insets.top + insets.bottom);
- }
- });
+ if(null!=container) {
+ /** An AWT event on setSize() would bring us in a deadlock situation, hence invokeLater() */
+ runOnEDT(false, new Runnable() {
+ public void run() {
+ Insets insets = container.getInsets();
+ container.setSize(width + insets.left + insets.right,
+ height + insets.top + insets.bottom);
+ }
+ });
+ }
}
public com.jogamp.newt.Insets getInsets() {
@@ -302,8 +305,9 @@ public class AWTWindow extends Window {
super.sendMouseEvent(eventType, modifiers, x, y, button, rotation);
}
- private static void runOnEDT(boolean wait, Runnable r) {
- if (EventQueue.isDispatchThread()) {
+ private void runOnEDT(boolean wait, Runnable r) {
+ EDTUtil edtUtil = screen.getDisplay().getEDTUtil();
+ if ( ( null != edtUtil && edtUtil.isCurrentThreadEDT() ) || EventQueue.isDispatchThread() ) {
r.run();
} else {
try {
diff --git a/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Display.java b/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Display.java
index d19aaf796..ac27da9ef 100644
--- a/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Display.java
+++ b/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Display.java
@@ -58,10 +58,10 @@ public class Display extends com.jogamp.newt.Display {
public Display() {
}
- protected void createNative() {
+ protected void createNative(long handle) {
synchronized(Display.class) {
if(0==initCounter) {
- displayHandle = CreateDisplay();
+ displayHandle = (0 == handle) ? CreateDisplay() : handle;
if(0==displayHandle) {
throw new NativeWindowException("Couldn't initialize GDL Display");
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java b/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java
index cb52618b2..7b867db21 100644
--- a/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java
+++ b/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java
@@ -45,7 +45,7 @@ public class Window extends com.jogamp.newt.Window {
static long nextWindowHandle = 1;
- protected void createNative(long parentWindowHandle, Capabilities caps) {
+ protected void createNativeImpl() {
if(0!=parentWindowHandle) {
throw new NativeWindowException("GDL Window does not support window parenting");
}
@@ -59,6 +59,11 @@ public class Window extends com.jogamp.newt.Window {
synchronized(Window.class) {
windowHandle = nextWindowHandle++;
+
+ surfaceHandle = CreateSurface(aDevice.getHandle(), screen.getWidth(), screen.getHeight(), x, y, width, height);
+ if (surfaceHandle == 0) {
+ throw new NativeWindowException("Error creating window");
+ }
}
}
@@ -72,19 +77,9 @@ public class Window extends com.jogamp.newt.Window {
}
}
- public void setVisible(boolean visible) {
- if(this.visible!=visible) {
- this.visible=visible;
- if(visible && 0==surfaceHandle) {
- synchronized(Window.class) {
- AbstractGraphicsDevice aDevice = screen.getDisplay().getGraphicsDevice();
- surfaceHandle = CreateSurface(aDevice.getHandle(), screen.getWidth(), screen.getHeight(), x, y, width, height);
- }
- if (surfaceHandle == 0) {
- throw new NativeWindowException("Error creating window");
- }
- ((Display)screen.getDisplay()).setFocus(this);
- }
+ protected void setVisibleImpl() {
+ if(visible) {
+ ((Display)screen.getDisplay()).setFocus(this);
}
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java b/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java
index 68242bba7..6e1119a9d 100755
--- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java
@@ -43,10 +43,10 @@ public class MacDisplay extends Display {
static {
NEWTJNILibLoader.loadNEWT();
- if(!initNSApplication()) {
+ if(!initNSApplication0()) {
throw new NativeWindowException("Failed to initialize native Application hook");
}
- if(!MacWindow.initIDs()) {
+ if(!MacWindow.initIDs0()) {
throw new NativeWindowException("Failed to initialize jmethodIDs");
}
if(DEBUG) System.out.println("MacDisplay.init App and IDs OK "+Thread.currentThread().getName());
@@ -70,13 +70,13 @@ public class MacDisplay extends Display {
MainThread.invoke(false, dispatchAction);
}
- protected void createNative() {
+ protected void createNative(long handle) {
aDevice = new MacOSXGraphicsDevice();
}
protected void closeNative() { }
- private static native boolean initNSApplication();
+ private static native boolean initNSApplication0();
protected native void dispatchMessages0();
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/macosx/MacScreen.java b/src/newt/classes/com/jogamp/newt/impl/macosx/MacScreen.java
index ce9254857..d7deb13ee 100755
--- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacScreen.java
+++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacScreen.java
@@ -46,11 +46,11 @@ public class MacScreen extends Screen {
protected void createNative(int index) {
aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
- setScreenSize(getWidthImpl(getIndex()), getHeightImpl(getIndex()));
+ setScreenSize(getWidthImpl0(getIndex()), getHeightImpl0(getIndex()));
}
protected void closeNative() { }
- private static native int getWidthImpl(int scrn_idx);
- private static native int getHeightImpl(int scrn_idx);
+ private static native int getWidthImpl0(int scrn_idx);
+ private static native int getHeightImpl0(int scrn_idx);
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
index 963c0c0a7..93c2b14bb 100755
--- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
@@ -130,7 +130,6 @@ public class MacWindow extends Window {
private static final int NSModeSwitchFunctionKey = 0xF747;
private volatile long surfaceHandle;
- private long parentWindowHandle;
// non fullscreen dimensions ..
private int nfs_width, nfs_height, nfs_x, nfs_y;
@@ -143,8 +142,7 @@ public class MacWindow extends Window {
public MacWindow() {
}
- protected void createNative(long parentWindowHandle, Capabilities caps) {
- this.parentWindowHandle=parentWindowHandle;
+ protected void createNativeImpl() {
config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
if (config == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
@@ -193,7 +191,7 @@ public class MacWindow extends Window {
public void run() {
nsViewLock.lock();
try {
- createWindow(parentWindowHandle, false);
+ createWindow(false);
} finally {
nsViewLock.unlock();
}
@@ -237,13 +235,13 @@ public class MacWindow extends Window {
try {
if(DEBUG_IMPLEMENTATION) System.out.println("MacWindow.VisibleAction "+visible+" "+Thread.currentThread().getName());
if (visible) {
- createWindow(parentWindowHandle, false);
+ createWindow(false);
if (windowHandle != 0) {
- makeKeyAndOrderFront(windowHandle);
+ makeKeyAndOrderFront0(windowHandle);
}
} else {
if (windowHandle != 0) {
- orderOut(windowHandle);
+ orderOut0(windowHandle);
}
}
} finally {
@@ -253,8 +251,7 @@ public class MacWindow extends Window {
}
private VisibleAction visibleAction = new VisibleAction();
- public void setVisible(boolean visible) {
- this.visible = visible;
+ protected void setVisibleImpl() {
MainThread.invoke(true, visibleAction);
}
@@ -282,7 +279,7 @@ public class MacWindow extends Window {
nsViewLock.lock();
try {
if (windowHandle != 0) {
- makeKey(windowHandle);
+ makeKey0(windowHandle);
}
} finally {
nsViewLock.unlock();
@@ -301,7 +298,7 @@ public class MacWindow extends Window {
nsViewLock.lock();
try {
if (windowHandle != 0) {
- setContentSize(windowHandle, width, height);
+ setContentSize0(windowHandle, width, height);
}
} finally {
nsViewLock.unlock();
@@ -311,13 +308,19 @@ public class MacWindow extends Window {
private SizeAction sizeAction = new SizeAction();
public void setSize(int width, int height) {
- this.width=width;
- this.height=height;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
+ if (width != this.width || this.height != height) {
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ if (0 != windowHandle) {
+ // this width/height will be set by sizeChanged, called by OSX
+ MainThread.invoke(true, sizeAction);
+ } else {
+ this.width=width;
+ this.height=height;
+ }
+ }
}
- MainThread.invoke(true, sizeAction);
}
class PositionAction implements Runnable {
@@ -325,7 +328,7 @@ public class MacWindow extends Window {
nsViewLock.lock();
try {
if (windowHandle != 0) {
- setFrameTopLeftPoint(parentWindowHandle, windowHandle, x, y);
+ setFrameTopLeftPoint0(parentWindowHandle, windowHandle, x, y);
}
} finally {
nsViewLock.unlock();
@@ -335,13 +338,19 @@ public class MacWindow extends Window {
private PositionAction positionAction = new PositionAction();
public void setPosition(int x, int y) {
- this.x=x;
- this.y=y;
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
+ if ( this.x != x || this.y != y ) {
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ if (0 != windowHandle) {
+ // this x/y will be set by positionChanged, called by OSX
+ MainThread.invoke(true, positionAction);
+ } else {
+ this.x=x;
+ this.y=y;
+ }
+ }
}
- MainThread.invoke(true, positionAction);
}
class FullscreenAction implements Runnable {
@@ -351,9 +360,9 @@ public class MacWindow extends Window {
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
System.err.println("MacWindow fs: "+fullscreen+" "+x+"/"+y+" "+width+"x"+height);
}
- createWindow(parentWindowHandle, true);
+ createWindow(true);
if (windowHandle != 0) {
- makeKeyAndOrderFront(windowHandle);
+ makeKeyAndOrderFront0(windowHandle);
}
} finally {
nsViewLock.unlock();
@@ -382,19 +391,21 @@ public class MacWindow extends Window {
}
private void sizeChanged(int newWidth, int newHeight) {
- if (DEBUG_IMPLEMENTATION) {
- System.out.println(Thread.currentThread().getName()+" Size changed to " + newWidth + ", " + newHeight);
- }
- width = newWidth;
- height = newHeight;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
- }
- if (DEBUG_IMPLEMENTATION) {
- System.out.println(" Posted WINDOW_RESIZED event");
+ if(width != newWidth || height != newHeight) {
+ if (DEBUG_IMPLEMENTATION) {
+ System.out.println(Thread.currentThread().getName()+" Size changed to " + newWidth + ", " + newHeight);
+ }
+ width = newWidth;
+ height = newHeight;
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ }
+ if (DEBUG_IMPLEMENTATION) {
+ System.out.println(" Posted WINDOW_RESIZED event");
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
}
- sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
}
private void insetsChanged(int left, int top, int right, int bottom) {
@@ -411,19 +422,21 @@ public class MacWindow extends Window {
}
private void positionChanged(int newX, int newY) {
- if (DEBUG_IMPLEMENTATION) {
- System.out.println(Thread.currentThread().getName()+" Position changed to " + newX + ", " + newY);
- }
- x = newX;
- y = newY;
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
- }
- if (DEBUG_IMPLEMENTATION) {
- System.out.println(" Posted WINDOW_MOVED event");
+ if( 0==parentWindowHandle && ( x != newX || y != newY ) ) {
+ if (DEBUG_IMPLEMENTATION) {
+ System.out.println(Thread.currentThread().getName()+" Position changed to " + newX + ", " + newY);
+ }
+ x = newX;
+ y = newY;
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ }
+ if (DEBUG_IMPLEMENTATION) {
+ System.out.println(" Posted WINDOW_MOVED event");
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
}
- sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
}
private void focusChanged(boolean focusGained) {
@@ -525,13 +538,13 @@ public class MacWindow extends Window {
super.sendKeyEvent(eventType, modifiers, key, keyChar);
}
- private void createWindow(long parentWindowHandle, boolean recreate) {
+ private void createWindow(boolean recreate) {
if(0!=windowHandle && !recreate) {
return;
}
if(0!=windowHandle) {
// save the view .. close the window
- surfaceHandle = changeContentView(parentWindowHandle, windowHandle, 0);
+ surfaceHandle = changeContentView0(parentWindowHandle, windowHandle, 0);
if(recreate && 0==surfaceHandle) {
throw new NativeWindowException("Internal Error - recreate, window but no view");
}
@@ -550,27 +563,27 @@ public class MacWindow extends Window {
if (windowHandle == 0) {
throw new NativeWindowException("Could create native window "+Thread.currentThread().getName()+" "+this);
}
- surfaceHandle = contentView(windowHandle);
+ surfaceHandle = contentView0(windowHandle);
setTitle0(windowHandle, getTitle());
// don't make the window visible on window creation
-// makeKeyAndOrderFront(windowHandle);
+// makeKeyAndOrderFront0(windowHandle);
sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
sendWindowEvent(WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
}
- protected static native boolean initIDs();
+ protected static native boolean initIDs0();
private native long createWindow0(long parentWindowHandle, int x, int y, int w, int h,
boolean fullscreen, int windowStyle,
int backingStoreType,
int screen_idx, long view);
- private native void makeKeyAndOrderFront(long window);
- private native void makeKey(long window);
- private native void orderOut(long window);
+ private native void makeKeyAndOrderFront0(long window);
+ private native void makeKey0(long window);
+ private native void orderOut0(long window);
private native void close0(long window);
private native void setTitle0(long window, String title);
- private native long contentView(long window);
- private native long changeContentView(long parentWindowHandle, long window, long view);
- private native void setContentSize(long window, int w, int h);
- private native void setFrameTopLeftPoint(long parentWindowHandle, long window, int x, int y);
+ private native long contentView0(long window);
+ private native long changeContentView0(long parentWindowHandle, long window, long view);
+ private native void setContentSize0(long window, int w, int h);
+ private native void setFrameTopLeftPoint0(long parentWindowHandle, long window, int x, int y);
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Display.java b/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Display.java
index c2d323e56..c08499359 100644
--- a/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Display.java
+++ b/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Display.java
@@ -56,8 +56,10 @@ public class Display extends com.jogamp.newt.Display {
public Display() {
}
- protected void createNative() {
- long handle = CreateDisplay(Screen.fixedWidth, Screen.fixedHeight);
+ protected void createNative(long handle) {
+ if( 0 == handle ) {
+ handle = CreateDisplay(Screen.fixedWidth, Screen.fixedHeight);
+ }
if (handle == EGL.EGL_NO_DISPLAY) {
throw new NativeWindowException("BC EGL CreateDisplay failed");
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java b/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java
index 9e1ead40e..b25ed4ee8 100755
--- a/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java
+++ b/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java
@@ -46,7 +46,7 @@ public class Window extends com.jogamp.newt.Window {
public Window() {
}
- protected void createNative(long parentWindowHandle, Capabilities caps) {
+ protected void createNativeImpl() {
if(0!=parentWindowHandle) {
throw new RuntimeException("Window parenting not supported (yet)");
}
@@ -57,6 +57,11 @@ public class Window extends com.jogamp.newt.Window {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
setSizeImpl(getScreen().getWidth(), getScreen().getHeight());
+
+ windowHandle = realizeWindow(true, width, height);
+ if (0 == windowHandle) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
}
protected void closeNative() {
@@ -65,18 +70,7 @@ public class Window extends com.jogamp.newt.Window {
}
}
- public void setVisible(boolean visible) {
- if(this.visible!=visible) {
- this.visible=visible;
- if ( 0==windowHandle ) {
- windowHandle = realizeWindow(true, width, height);
- if (0 == windowHandle) {
- throw new NativeWindowException("Error native Window Handle is null");
- }
- }
- clearEventMask();
- }
- }
+ protected void setVisibleImpl() { }
public void setSize(int width, int height) {
System.err.println("setSize "+width+"x"+height+" n/a in BroadcomEGL");
diff --git a/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDDisplay.java b/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDDisplay.java
index 2ab30773f..bb5f1cc7a 100755
--- a/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDDisplay.java
@@ -57,9 +57,12 @@ public class KDDisplay extends Display {
public KDDisplay() {
}
- protected void createNative() {
+ protected void createNative(long handle) {
// FIXME: map name to EGL_*_DISPLAY
- long handle = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
+ // FIXME: what do to with external handle ?
+ if(0==handle) {
+ handle = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
+ }
if (handle == EGL.EGL_NO_DISPLAY) {
throw new NativeWindowException("eglGetDisplay failed");
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java b/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java
index 5f1068cad..f60abb7cd 100755
--- a/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java
@@ -54,7 +54,7 @@ public class KDWindow extends Window {
public KDWindow() {
}
- protected void createNative(long parentWindowHandle, Capabilities caps) {
+ protected void createNativeImpl() {
if(0!=parentWindowHandle) {
throw new RuntimeException("Window parenting not supported (yet)");
}
@@ -66,12 +66,15 @@ public class KDWindow extends Window {
GLCapabilities eglCaps = (GLCapabilities)config.getChosenCapabilities();
int[] eglAttribs = EGLGraphicsConfiguration.GLCapabilities2AttribList(eglCaps);
- windowHandle = 0;
eglWindowHandle = CreateWindow(getDisplayHandle(), eglAttribs);
if (eglWindowHandle == 0) {
throw new NativeWindowException("Error creating egl window: "+config);
}
setVisible0(eglWindowHandle, false);
+ windowHandle = RealizeWindow(eglWindowHandle);
+ if (0 == windowHandle) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
windowHandleClose = eglWindowHandle;
}
@@ -82,18 +85,9 @@ public class KDWindow extends Window {
}
}
- public void setVisible(boolean visible) {
- if(0!=eglWindowHandle && this.visible!=visible) {
- this.visible=visible;
- setVisible0(eglWindowHandle, visible);
- if ( 0==windowHandle ) {
- windowHandle = RealizeWindow(eglWindowHandle);
- if (0 == windowHandle) {
- throw new NativeWindowException("Error native Window Handle is null");
- }
- }
- clearEventMask();
- }
+ protected void setVisibleImpl() {
+ setVisible0(eglWindowHandle, visible);
+ clearEventMask();
}
public void setSize(int width, int height) {
diff --git a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsDisplay.java b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsDisplay.java
index 000e64b6d..f75c11cfb 100755
--- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsDisplay.java
@@ -47,7 +47,7 @@ public class WindowsDisplay extends Display {
static {
NEWTJNILibLoader.loadNEWT();
- if (!WindowsWindow.initIDs()) {
+ if (!WindowsWindow.initIDs0()) {
throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs");
}
}
@@ -60,22 +60,22 @@ public class WindowsDisplay extends Display {
public WindowsDisplay() {
}
- protected void createNative() {
+ protected void createNative(long handle) {
aDevice = new WindowsGraphicsDevice();
}
protected void closeNative() {
// Can't do .. only at application shutdown
- // UnregisterWindowClass(getWindowClassAtom(), getHInstance());
+ // UnregisterWindowClass0(getWindowClassAtom(), getHInstance());
}
protected void dispatchMessagesNative() {
- DispatchMessages();
+ DispatchMessages0();
}
protected static synchronized int getWindowClassAtom() {
if(0 == windowClassAtom) {
- windowClassAtom = RegisterWindowClass(WINDOW_CLASS_NAME, getHInstance());
+ windowClassAtom = RegisterWindowClass0(WINDOW_CLASS_NAME, getHInstance());
if (0 == windowClassAtom) {
throw new NativeWindowException("Error while registering window class");
}
@@ -85,7 +85,7 @@ public class WindowsDisplay extends Display {
protected static synchronized long getHInstance() {
if(0 == hInstance) {
- hInstance = LoadLibraryW("newt");
+ hInstance = LoadLibraryW0("newt");
if (0 == hInstance) {
throw new NativeWindowException("Error finding HINSTANCE for \"newt\"");
}
@@ -96,10 +96,10 @@ public class WindowsDisplay extends Display {
//----------------------------------------------------------------------
// Internals only
//
- private static native long LoadLibraryW(String libraryName);
- private static native int RegisterWindowClass(String windowClassName, long hInstance);
- private static native void UnregisterWindowClass(int wndClassAtom, long hInstance);
+ private static native long LoadLibraryW0(String libraryName);
+ private static native int RegisterWindowClass0(String windowClassName, long hInstance);
+ private static native void UnregisterWindowClass0(int wndClassAtom, long hInstance);
- private static native void DispatchMessages();
+ private static native void DispatchMessages0();
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java
index b0161cfc2..1b4be0d55 100755
--- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java
+++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java
@@ -47,11 +47,11 @@ public class WindowsScreen extends Screen {
protected void createNative(int index) {
aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
- setScreenSize(getWidthImpl(getIndex()), getHeightImpl(getIndex()));
+ setScreenSize(getWidthImpl0(getIndex()), getHeightImpl0(getIndex()));
}
protected void closeNative() { }
- private native int getWidthImpl(int scrn_idx);
- private native int getHeightImpl(int scrn_idx);
+ private native int getWidthImpl0(int scrn_idx);
+ private native int getHeightImpl0(int scrn_idx);
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
index bec7bfed2..dad3456d7 100755
--- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
@@ -42,7 +42,6 @@ public class WindowsWindow extends Window {
private long hmon;
private long hdc;
private long windowHandleClose;
- private long parentWindowHandle;
// non fullscreen dimensions ..
private int nfs_width, nfs_height, nfs_x, nfs_y;
private final Insets insets = new Insets(0, 0, 0, 0);
@@ -62,8 +61,8 @@ public class WindowsWindow extends Window {
if(hdc!=0) {
throw new NativeWindowException("NEWT Surface handle set HDC "+toHexString(hdc)+" - "+Thread.currentThread().getName()+" ; "+this);
}
- hdc = GetDC(windowHandle);
- hmon = MonitorFromWindow(windowHandle);
+ hdc = GetDC0(windowHandle);
+ hmon = MonitorFromWindow0(windowHandle);
hdcOwner = Thread.currentThread();
}
return res;
@@ -80,7 +79,7 @@ public class WindowsWindow extends Window {
if(hdcOwner != cur) {
throw new NativeWindowException("NEWT Surface handle set HDC "+toHexString(hdc)+" by other thread "+hdcOwner+", this "+cur+" ; "+this);
}
- ReleaseDC(windowHandle, hdc);
+ ReleaseDC0(windowHandle, hdc);
hdc=0;
hdcOwner=null;
}
@@ -93,7 +92,7 @@ public class WindowsWindow extends Window {
public boolean hasDeviceChanged() {
if(0!=windowHandle) {
- long _hmon = MonitorFromWindow(windowHandle);
+ long _hmon = MonitorFromWindow0(windowHandle);
if (hmon != _hmon) {
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
Exception e = new Exception("!!! Window Device Changed "+Thread.currentThread().getName()+
@@ -107,20 +106,19 @@ public class WindowsWindow extends Window {
return false;
}
- protected void createNative(long parentWindowHandle, Capabilities caps) {
+ protected void createNativeImpl() {
WindowsScreen screen = (WindowsScreen) getScreen();
WindowsDisplay display = (WindowsDisplay) screen.getDisplay();
config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen());
if (config == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
- windowHandle = CreateWindow(parentWindowHandle,
+ windowHandle = CreateWindow0(parentWindowHandle,
display.getWindowClassAtom(), display.WINDOW_CLASS_NAME, display.getHInstance(),
0, undecorated, x, y, width, height);
if (windowHandle == 0) {
throw new NativeWindowException("Error creating window");
}
- this.parentWindowHandle = parentWindowHandle;
windowHandleClose = windowHandle;
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
Exception e = new Exception("!!! Window new window handle "+Thread.currentThread().getName()+
@@ -133,12 +131,12 @@ public class WindowsWindow extends Window {
protected void closeNative() {
if (hdc != 0) {
if(windowHandleClose != 0) {
- ReleaseDC(windowHandleClose, hdc);
+ ReleaseDC0(windowHandleClose, hdc);
}
hdc = 0;
}
if(windowHandleClose != 0) {
- DestroyWindow(windowHandleClose);
+ DestroyWindow0(windowHandleClose);
windowHandleClose = 0;
}
}
@@ -148,23 +146,22 @@ public class WindowsWindow extends Window {
super.windowDestroyed();
}
- public void setVisible(boolean visible) {
- if(this.visible!=visible && 0!=windowHandle) {
- this.visible=visible;
- setVisible0(windowHandle, visible);
- }
+ protected void setVisibleImpl() {
+ setVisible0(windowHandle, visible);
}
// @Override
public void setSize(int width, int height) {
if (width != this.width || this.height != height) {
if(!fullscreen) {
- this.width=width;
- this.height=height;
nfs_width=width;
nfs_height=height;
if(0!=windowHandle) {
+ // this width/height will be set by sizeChanged, called by Windows
setSize0(parentWindowHandle, windowHandle, x, y, width, height);
+ } else {
+ this.width=width;
+ this.height=height;
}
}
}
@@ -174,12 +171,14 @@ public class WindowsWindow extends Window {
public void setPosition(int x, int y) {
if ( this.x != x || this.y != y ) {
if(!fullscreen) {
- this.x=x;
- this.y=y;
nfs_x=x;
nfs_y=y;
if(0!=windowHandle) {
+ // this x/y will be set by positionChanged, called by Windows
setPosition0(parentWindowHandle, windowHandle, x , y /*, width, height*/);
+ } else {
+ this.x=x;
+ this.y=y;
}
}
}
@@ -211,7 +210,7 @@ public class WindowsWindow extends Window {
public void requestFocus() {
super.requestFocus();
if (windowHandle != 0L) {
- requestFocus(windowHandle);
+ requestFocus0(windowHandle);
}
}
@@ -222,7 +221,7 @@ public class WindowsWindow extends Window {
}
if (0!=windowHandle && !title.equals(getTitle())) {
super.setTitle(title);
- setTitle(windowHandle, title);
+ setTitle0(windowHandle, title);
}
}
@@ -233,22 +232,22 @@ public class WindowsWindow extends Window {
//----------------------------------------------------------------------
// Internals only
//
- protected static native boolean initIDs();
- private native long CreateWindow(long parentWindowHandle,
+ protected static native boolean initIDs0();
+ private native long CreateWindow0(long parentWindowHandle,
int wndClassAtom, String wndName,
long hInstance, long visualID,
boolean isUndecorated,
int x, int y, int width, int height);
- private native void DestroyWindow(long windowHandle);
- private native long GetDC(long windowHandle);
- private native void ReleaseDC(long windowHandle, long hdc);
- private native long MonitorFromWindow(long windowHandle);
+ private native void DestroyWindow0(long windowHandle);
+ private native long GetDC0(long windowHandle);
+ private native void ReleaseDC0(long windowHandle, long hdc);
+ private native long MonitorFromWindow0(long windowHandle);
private static native void setVisible0(long windowHandle, boolean visible);
private native void setSize0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height);
private static native void setPosition0(long parentWindowHandle, long windowHandle, int x, int y /*, int width, int height*/);
private native void setFullscreen0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height, boolean isUndecorated, boolean on);
- private static native void setTitle(long windowHandle, String title);
- private static native void requestFocus(long windowHandle);
+ private static native void setTitle0(long windowHandle, String title);
+ private static native void requestFocus0(long windowHandle);
private void insetsChanged(int left, int top, int right, int bottom) {
if (left != -1 && top != -1 && right != -1 && bottom != -1) {
@@ -258,24 +257,29 @@ public class WindowsWindow extends Window {
insets.bottom = bottom;
}
}
+
private void sizeChanged(int newWidth, int newHeight) {
- width = newWidth;
- height = newHeight;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
+ if(width != newWidth || height != newHeight) {
+ width = newWidth;
+ height = newHeight;
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
}
- sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
}
private void positionChanged(int newX, int newY) {
- x = newX;
- y = newY;
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
+ if( 0==parentWindowHandle && ( x != newX || y != newY ) ) {
+ x = newX;
+ y = newY;
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
}
- sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
}
/**
diff --git a/src/newt/classes/com/jogamp/newt/impl/x11/X11Display.java b/src/newt/classes/com/jogamp/newt/impl/x11/X11Display.java
index c2de0fe18..3b0868620 100755
--- a/src/newt/classes/com/jogamp/newt/impl/x11/X11Display.java
+++ b/src/newt/classes/com/jogamp/newt/impl/x11/X11Display.java
@@ -43,11 +43,11 @@ public class X11Display extends Display {
static {
NEWTJNILibLoader.loadNEWT();
- if (!initIDs()) {
+ if ( !initIDs0() ) {
throw new NativeWindowException("Failed to initialize X11Display jmethodIDs");
}
- if (!X11Window.initIDs()) {
+ if (!X11Window.initIDs0()) {
throw new NativeWindowException("Failed to initialize X11Window jmethodIDs");
}
}
@@ -60,13 +60,24 @@ public class X11Display extends Display {
public X11Display() {
}
- protected void createNative() {
- long handle= X11Util.createThreadLocalDisplay(name);
- if (handle == 0 ) {
+ protected void createNative(long handle) {
+ if(0 != handle) {
+ // Can't use that Display handle directly,
+ // but we open up a new connection to the same Display by it's name
+ String newName = X11Util.getNameOfDisplay(handle);
+ if(DEBUG) {
+ System.out.println("Changing Display Name (provided handle): "+name+" -> 0x"+
+ Long.toHexString(handle)+" : "+newName);
+ }
+ handle = 0;
+ name = newName;
+ }
+ handle= X11Util.createThreadLocalDisplay(name);
+ if( 0 == handle ) {
throw new RuntimeException("Error creating display: "+name);
}
try {
- CompleteDisplay(handle);
+ CompleteDisplay0(handle);
} catch(RuntimeException e) {
X11Util.closeThreadLocalDisplay(name);
throw e;
@@ -82,7 +93,7 @@ public class X11Display extends Display {
if(0==getHandle()) {
throw new RuntimeException("display handle null");
}
- DispatchMessages(getHandle(), javaObjectAtom, windowDeleteAtom);
+ DispatchMessages0(getHandle(), javaObjectAtom, windowDeleteAtom);
}
protected void lockDisplay() {
@@ -101,11 +112,11 @@ public class X11Display extends Display {
//----------------------------------------------------------------------
// Internals only
//
- private static native boolean initIDs();
+ private static native boolean initIDs0();
- private native void CompleteDisplay(long handle);
+ private native void CompleteDisplay0(long handle);
- private native void DispatchMessages(long display, long javaObjectAtom, long windowDeleteAtom);
+ private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom);
private void displayCompleted(long javaObjectAtom, long windowDeleteAtom) {
this.javaObjectAtom=javaObjectAtom;
diff --git a/src/newt/classes/com/jogamp/newt/impl/x11/X11Screen.java b/src/newt/classes/com/jogamp/newt/impl/x11/X11Screen.java
index 3561bec2a..453d8e5e1 100755
--- a/src/newt/classes/com/jogamp/newt/impl/x11/X11Screen.java
+++ b/src/newt/classes/com/jogamp/newt/impl/x11/X11Screen.java
@@ -47,7 +47,7 @@ public class X11Screen extends Screen {
}
protected void createNative(int index) {
- long handle = GetScreen(display.getHandle(), index);
+ long handle = GetScreen0(display.getHandle(), index);
if (handle == 0 ) {
throw new RuntimeException("Error creating screen: "+index);
}
@@ -62,7 +62,7 @@ public class X11Screen extends Screen {
// Internals only
//
- private native long GetScreen(long dpy, int scrn_idx);
+ private native long GetScreen0(long dpy, int scrn_idx);
private native int getWidth0(long display, int scrn_idx);
private native int getHeight0(long display, int scrn_idx);
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
index 4fe9f77ad..085d1cab7 100755
--- a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
+++ b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
@@ -48,7 +48,7 @@ public class X11Window extends Window {
public X11Window() {
}
- protected void createNative(long parentWindowHandle, Capabilities caps) {
+ protected void createNativeImpl() {
X11Screen screen = (X11Screen) getScreen();
X11Display display = (X11Display) screen.getDisplay();
config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen());
@@ -58,14 +58,13 @@ public class X11Window extends Window {
attachedToParent = 0 != parentWindowHandle ;
X11GraphicsConfiguration x11config = (X11GraphicsConfiguration) config;
long visualID = x11config.getVisualID();
- long w = CreateWindow(parentWindowHandle,
+ long w = CreateWindow0(parentWindowHandle,
display.getHandle(), screen.getIndex(), visualID,
display.getJavaObjectAtom(), display.getWindowDeleteAtom(),
x, y, width, height, undecorated());
if (w == 0 || w!=windowHandle) {
throw new NativeWindowException("Error creating window: "+w);
}
- this.parentWindowHandle = parentWindowHandle;
windowHandleClose = windowHandle;
displayHandleClose = display.getHandle();
}
@@ -73,7 +72,7 @@ public class X11Window extends Window {
protected void closeNative() {
if(0!=displayHandleClose && 0!=windowHandleClose && null!=getScreen() ) {
X11Display display = (X11Display) getScreen().getDisplay();
- CloseWindow(displayHandleClose, windowHandleClose, display.getJavaObjectAtom());
+ CloseWindow0(displayHandleClose, windowHandleClose, display.getJavaObjectAtom());
windowHandleClose = 0;
displayHandleClose = 0;
}
@@ -85,15 +84,9 @@ public class X11Window extends Window {
super.windowDestroyed();
}
- public void setVisible(boolean visible) {
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("X11Window setVisible: "+this.x+"/"+this.y+" "+this.width+"x"+this.height+", fs "+fullscreen+", windowHandle "+windowHandle);
- }
- if(0!=windowHandle && this.visible!=visible) {
- this.visible=visible;
- setVisible0(getDisplayHandle(), windowHandle, visible);
- clearEventMask();
- }
+ protected void setVisibleImpl() {
+ setVisible0(getDisplayHandle(), windowHandle, visible);
+ clearEventMask();
}
public void setSize(int width, int height) {
@@ -102,12 +95,14 @@ public class X11Window extends Window {
}
if (width != this.width || this.height != height) {
if(!fullscreen) {
- this.width = width;
- this.height = height;
nfs_width=width;
nfs_height=height;
if(0!=windowHandle) {
+ // this width/height will be set by windowChanged, called by X11
setSize0(getDisplayHandle(), windowHandle, width, height);
+ } else {
+ this.width = width;
+ this.height = height;
}
}
}
@@ -119,12 +114,14 @@ public class X11Window extends Window {
}
if ( this.x != x || this.y != y ) {
if(!fullscreen) {
- this.x = x;
- this.y = y;
nfs_x=x;
nfs_y=y;
if(0!=windowHandle) {
+ // this x/y will be set by windowChanged, called by X11
setPosition0(parentWindowHandle, getDisplayHandle(), windowHandle, x, y);
+ } else {
+ this.x = x;
+ this.y = y;
}
}
}
@@ -178,11 +175,11 @@ public class X11Window extends Window {
// Internals only
//
- protected static native boolean initIDs();
- private native long CreateWindow(long parentWindowHandle, long display, int screen_index,
+ protected static native boolean initIDs0();
+ private native long CreateWindow0(long parentWindowHandle, long display, int screen_index,
long visualID, long javaObjectAtom, long windowDeleteAtom,
int x, int y, int width, int height, boolean undecorated);
- private native void CloseWindow(long display, long windowHandle, long javaObjectAtom);
+ private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom);
private native void setVisible0(long display, long windowHandle, boolean visible);
private native void setSize0(long display, long windowHandle, int width, int height);
private native void setPosSizeDecor0(long parentWindowHandle, long display, int screen_index, long windowHandle,
@@ -235,7 +232,6 @@ public class X11Window extends Window {
private long windowHandleClose;
private long displayHandleClose;
- private long parentWindowHandle;
private boolean attachedToParent;
// non fullscreen dimensions ..
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index b47b580ed..b5d55aebd 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -82,49 +82,53 @@ public class GLWindow extends Window implements GLAutoDrawable {
glwindows=newglw;
}
- /** Creates a new GLWindow on the local display, screen 0, with a
- dummy visual ID, and with the default GLCapabilities. */
- public static GLWindow create() {
- return create(null, null, false);
+ /** Creates a new GLWindow attaching the given window - not owning the Window. */
+ public static GLWindow create(Window window) {
+ return create(null, window, null, false);
}
- public static GLWindow create(boolean undecorated) {
- return create(null, null, undecorated);
+ /** Creates a new GLWindow attaching a new native child Window of the given <code>parentWindowObject</code>
+ with the given GLCapabilities - owning the Window */
+ public static GLWindow create(Object parentWindowObject, GLCapabilities caps) {
+ return create(parentWindowObject, null, caps, true);
}
- /** Creates a new GLWindow referring to the given window. */
- public static GLWindow create(Window window) {
- return create(window, null, false);
- }
+ /** Creates a new GLWindow attaching a new decorated Window on the local display, screen 0, with a
+ dummy visual ID and given GLCapabilities - owning the window */
public static GLWindow create(GLCapabilities caps) {
- return create(null, caps, false);
+ return create(null, null, caps, false);
}
- /** Creates a new GLWindow on the local display, screen 0, with a
- dummy visual ID, and with the given GLCapabilities. */
+ /** Creates a new GLWindow attaching a new Window on the local display, screen 0, with a
+ dummy visual ID and given GLCapabilities - owning the window */
public static GLWindow create(GLCapabilities caps, boolean undecorated) {
- return create(null, caps, undecorated);
+ return create(null, null, caps, undecorated);
}
/** Either or: window (prio), or caps and undecorated (2nd choice) */
- private static GLWindow create(Window window,
+ private static GLWindow create(Object parentWindowObject, Window window,
GLCapabilities caps,
boolean undecorated) {
- Display display;
boolean ownerOfWinScrDpy=false;
if (window == null) {
if (caps == null) {
caps = new GLCapabilities(null); // default ..
}
ownerOfWinScrDpy = true;
- display = NewtFactory.createDisplay(null); // local display
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- window = NewtFactory.createWindow(screen, caps, undecorated);
+ window = NewtFactory.createWindow(parentWindowObject, caps, undecorated);
}
return new GLWindow(window, ownerOfWinScrDpy);
}
+ public boolean isDestroyed() {
+ return null == window ;
+ }
+
+ public Window getWindow() {
+ return window;
+ }
+
/**
* EXPERIMENTAL<br>
* Enable or disables running the {@link Display#pumpMessages} in the {@link #display()} call.<br>
@@ -150,7 +154,7 @@ public class GLWindow extends Window implements GLAutoDrawable {
runPumpMessages = onoff;
}
- protected void createNative(long parentWindowHandle, Capabilities caps) {
+ protected void createNativeImpl() {
shouldNotCallThis();
}
@@ -204,11 +208,6 @@ public class GLWindow extends Window implements GLAutoDrawable {
/** @param sendDisposeEvent should be false in a [time,reliable] critical shutdown */
public synchronized void destroy(boolean sendDisposeEvent) {
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- Exception e1 = new Exception("GLWindow.destroy "+Thread.currentThread()+", 1: "+this);
- e1.printStackTrace();
- }
-
List newglw = (List) ((ArrayList) glwindows).clone();
newglw.remove(this);
glwindows=newglw;
@@ -224,10 +223,6 @@ public class GLWindow extends Window implements GLAutoDrawable {
drawable = null;
context = null;
window = null;
-
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println("GLWindow.destroy "+Thread.currentThread()+", fin: "+this);
- }
}
public boolean getPerfLogEnabled() { return perfLog; }
@@ -236,13 +231,13 @@ public class GLWindow extends Window implements GLAutoDrawable {
perfLog = v;
}
- public void setVisible(boolean visible) {
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println(Thread.currentThread()+" GLWindow.setVisible("+visible+") START ; isVisible "+this.visible+" ; has context "+(null!=context));
- }
- this.visible=visible;
+ protected void setVisibleImpl() {
+ shouldNotCallThis();
+ }
+
+ public void setVisible(final boolean visible) {
window.setVisible(visible);
- if (visible && context == null) {
+ if (visible && null == context && 0 != window.getWindowHandle()) {
NativeWindow nw;
if (window.getWrappedWindow() != null) {
nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getGraphicsConfiguration());
@@ -256,9 +251,6 @@ public class GLWindow extends Window implements GLAutoDrawable {
context = drawable.createContext(null);
sendReshape = true; // ensure a reshape event is send ..
}
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println(Thread.currentThread()+" GLWindow.setVisible("+visible+") END ; has context "+(null!=context));
- }
}
public Screen getScreen() {
@@ -438,7 +430,14 @@ public class GLWindow extends Window implements GLAutoDrawable {
}
public void display(boolean forceReshape) {
- if(window!=null && drawable!=null && context != null) {
+ if( null == window ) { return; }
+
+ if( null == context && window.isVisible() ) {
+ // retry native window and drawable/context creation
+ setVisible(true);
+ }
+
+ if( null != context ) {
if(runPumpMessages) {
window.getScreen().getDisplay().pumpMessages();
}
@@ -448,7 +447,7 @@ public class GLWindow extends Window implements GLAutoDrawable {
if (sendDestroy) {
destroy();
sendDestroy=false;
- } else {
+ } else if ( window.isVisible() ) {
if(forceReshape) {
sendReshape = true;
}
@@ -553,13 +552,9 @@ public class GLWindow extends Window implements GLAutoDrawable {
private SwapBuffersAction swapBuffersAction = new SwapBuffersAction();
//----------------------------------------------------------------------
- // GLDrawable methods
+ // NativeWindow/Window methods
//
- public NativeWindow getNativeWindow() {
- return null!=drawable ? drawable.getNativeWindow() : null;
- }
-
public synchronized int lockSurface() throws NativeWindowException {
if(null!=drawable) return drawable.getNativeWindow().lockSurface();
return NativeWindow.LOCK_SURFACE_NOT_READY;
@@ -587,12 +582,25 @@ public class GLWindow extends Window implements GLAutoDrawable {
public long getWindowHandle() {
if(null!=drawable) return drawable.getNativeWindow().getWindowHandle();
- return super.getWindowHandle();
+ return window.getWindowHandle();
}
public long getSurfaceHandle() {
if(null!=drawable) return drawable.getNativeWindow().getSurfaceHandle();
- return super.getSurfaceHandle();
+ return window.getSurfaceHandle();
+ }
+
+ public AbstractGraphicsConfiguration getGraphicsConfiguration() {
+ if(null!=drawable) return drawable.getNativeWindow().getGraphicsConfiguration();
+ return window.getGraphicsConfiguration();
+ }
+
+ //----------------------------------------------------------------------
+ // GLDrawable methods
+ //
+
+ public NativeWindow getNativeWindow() {
+ return null!=drawable ? drawable.getNativeWindow() : null;
}
//----------------------------------------------------------------------
diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java
index 2550eef82..e6af747c8 100644
--- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java
+++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java
@@ -123,11 +123,17 @@ public class EDTUtil {
}
public void invokeAndWait(Runnable task) {
+ invoke(false, task);
+ }
+
+ public void invoke(boolean deferred, Runnable task) {
if(task == null) {
return;
}
invokeLater(task);
- waitOnWorker();
+ if(!deferred) {
+ waitOnWorker();
+ }
}
public void waitOnWorker() {
diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m
index 21bc9b2ad..1956b6899 100644
--- a/src/newt/native/MacWindow.m
+++ b/src/newt/native/MacWindow.m
@@ -125,7 +125,7 @@ NS_ENDHANDLER
* Method: initIDs
* Signature: ()Z
*/
-JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_macosx_MacDisplay_initNSApplication
+JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_macosx_MacDisplay_initNSApplication0
(JNIEnv *env, jclass clazz)
{
static int initialized = 0;
@@ -199,7 +199,7 @@ NS_ENDHANDLER
* Method: getWidthImpl
* Signature: (I)I
*/
-JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_macosx_MacScreen_getWidthImpl
+JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_macosx_MacScreen_getWidthImpl0
(JNIEnv *env, jclass clazz, jint screen_idx)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -220,7 +220,7 @@ JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_macosx_MacScreen_getWidthImpl
* Method: getHeightImpl
* Signature: (I)I
*/
-JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_macosx_MacScreen_getHeightImpl
+JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_macosx_MacScreen_getHeightImpl0
(JNIEnv *env, jclass clazz, jint screen_idx)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -241,7 +241,7 @@ JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_macosx_MacScreen_getHeightImpl
* Method: initIDs
* Signature: ()Z
*/
-JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_initIDs
+JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_initIDs0
(JNIEnv *env, jclass clazz)
{
static int initialized = 0;
@@ -338,7 +338,7 @@ NS_ENDHANDLER
* Method: makeKeyAndOrderFront
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_makeKeyAndOrderFront
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_makeKeyAndOrderFront0
(JNIEnv *env, jobject unused, jlong window)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -352,7 +352,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_makeKeyAndOrde
* Method: makeKey
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_makeKey
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_makeKey0
(JNIEnv *env, jobject unused, jlong window)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -366,7 +366,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_makeKey
* Method: orderOut
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_orderOut
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_orderOut0
(JNIEnv *env, jobject unused, jlong window)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -421,7 +421,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_setTitle0
* Method: contentView
* Signature: (J)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_contentView
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_contentView0
(JNIEnv *env, jobject unused, jlong window)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -436,7 +436,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_contentView
* Method: changeContentView
* Signature: (J)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_changeContentView
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_changeContentView0
(JNIEnv *env, jobject jthis, jlong parent, jlong window, jlong jview)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -456,7 +456,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_changeContent
* Method: setContentSize
* Signature: (JII)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_setContentSize
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_setContentSize0
(JNIEnv *env, jobject unused, jlong window, jint w, jint h)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -471,7 +471,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_setContentSize
* Method: setFrameTopLeftPoint
* Signature: (JII)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_setFrameTopLeftPoint
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_setFrameTopLeftPoint0
(JNIEnv *env, jobject unused, jlong parent, jlong window, jint x, jint y)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 488588f52..fabcab1c7 100755
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -922,7 +922,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
* Method: DispatchMessages
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_DispatchMessages
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_DispatchMessages0
(JNIEnv *env, jclass clazz)
{
int i = 0;
@@ -950,7 +950,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_Dispatch
* Method: LoadLibraryW
* Signature: (Ljava/lang/String;)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_LoadLibraryW
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_LoadLibraryW0
(JNIEnv *env, jclass clazz, jstring dllName)
{
jchar* _dllName = NewtCommon_GetNullTerminatedStringChars(env, dllName);
@@ -964,7 +964,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_LoadLib
* Method: RegisterWindowClass
* Signature: (Ljava/lang/String;J)I
*/
-JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_RegisterWindowClass
+JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_RegisterWindowClass0
(JNIEnv *env, jclass clazz, jstring wndClassName, jlong hInstance)
{
ATOM res;
@@ -1004,7 +1004,7 @@ JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_Register
* Method: CleanupWindowResources
* Signature: (java/lang/String;J)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_UnregisterWindowClass
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_UnregisterWindowClass0
(JNIEnv *env, jclass clazz, jint wndClassAtom, jlong hInstance)
{
UnregisterClass(MAKEINTATOM(wndClassAtom), (HINSTANCE) (intptr_t) hInstance);
@@ -1015,7 +1015,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_Unregist
* Method: getWidthImpl
* Signature: (I)I
*/
-JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsScreen_getWidthImpl
+JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsScreen_getWidthImpl0
(JNIEnv *env, jobject obj, jint scrn_idx)
{
return (jint)GetSystemMetrics(SM_CXSCREEN);
@@ -1026,7 +1026,7 @@ JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsScreen_getWidthI
* Method: getHeightImpl
* Signature: (I)I
*/
-JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsScreen_getHeightImpl
+JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsScreen_getHeightImpl0
(JNIEnv *env, jobject obj, jint scrn_idx)
{
return (jint)GetSystemMetrics(SM_CYSCREEN);
@@ -1037,7 +1037,7 @@ JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsScreen_getHeight
* Method: initIDs
* Signature: ()Z
*/
-JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initIDs
+JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initIDs0
(JNIEnv *env, jclass clazz)
{
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)V");
@@ -1070,7 +1070,7 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI
* Method: CreateWindow
* Signature: (JILjava/lang/String;JJZIIII)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWindow
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWindow0
(JNIEnv *env, jobject obj, jlong parent, jint wndClassAtom, jstring jWndName, jlong hInstance, jlong visualID,
jboolean bIsUndecorated,
jint jx, jint jy, jint defaultWidth, jint defaultHeight)
@@ -1151,7 +1151,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWi
* Method: DestroyWindow
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_DestroyWindow
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_DestroyWindow0
(JNIEnv *env, jobject obj, jlong window)
{
DestroyWindow((HWND) (intptr_t) window);
@@ -1162,7 +1162,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_DestroyWi
* Method: GetDC
* Signature: (J)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_GetDC
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_GetDC0
(JNIEnv *env, jobject obj, jlong window)
{
return (jlong) (intptr_t) GetDC((HWND) (intptr_t) window);
@@ -1173,7 +1173,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_GetDC
* Method: ReleaseDC
* Signature: (JJ)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_ReleaseDC
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_ReleaseDC0
(JNIEnv *env, jobject obj, jlong window, jlong dc)
{
ReleaseDC((HWND) (intptr_t) window, (HDC) (intptr_t) dc);
@@ -1184,7 +1184,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_ReleaseDC
* Method: MonitorFromWindow
* Signature: (J)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_MonitorFromWindow
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_MonitorFromWindow0
(JNIEnv *env, jobject obj, jlong window)
{
#if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410 || WINVER >= 0x0500) && !defined(_WIN32_WCE)
@@ -1337,7 +1337,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setFullsc
* Method: setTitle
* Signature: (JLjava/lang/String;)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setTitle
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setTitle0
(JNIEnv *env, jclass clazz, jlong window, jstring title)
{
HWND hwnd = (HWND) (intptr_t) window;
@@ -1355,7 +1355,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setTitle
* Method: requestFocus
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_requestFocus
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_requestFocus0
(JNIEnv *env, jclass clazz, jlong window)
{
NewtWindows_requestFocus ( (HWND) (intptr_t) window ) ;
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index eb52e45bc..abaa3594f 100755
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -236,17 +236,13 @@ static void displayDispatchErrorHandlerEnable(int onoff, JNIEnv * env) {
/*
* Class: com_jogamp_newt_impl_x11_X11Display
* Method: initIDs
- * Signature: ()Z
+ * Signature: (Z)Z
*/
-JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Display_initIDs
+JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Display_initIDs0
(JNIEnv *env, jclass clazz)
{
jclass c;
- if( 0 == XInitThreads() ) {
- fprintf(stderr, "Warning: NEWT X11Window: XInitThreads() failed\n");
- }
-
displayCompletedID = (*env)->GetMethodID(env, clazz, "displayCompleted", "(JJ)V");
if (displayCompletedID == NULL) {
return JNI_FALSE;
@@ -284,7 +280,7 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Display_initIDs
* Method: CompleteDisplay
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_CompleteDisplay
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_CompleteDisplay0
(JNIEnv *env, jobject obj, jlong display)
{
Display * dpy = (Display *)(intptr_t)display;
@@ -431,7 +427,7 @@ static void NewtWindows_setDecorations (Display *dpy, Window w, Bool val) {
* Method: DispatchMessages
* Signature: (JIJJ)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages0
(JNIEnv *env, jobject obj, jlong display, jlong javaObjectAtom, jlong wmDeleteAtom)
{
Display * dpy = (Display *) (intptr_t) display;
@@ -597,7 +593,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
* Method: GetScreen
* Signature: (JI)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Screen_GetScreen
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Screen_GetScreen0
(JNIEnv *env, jobject obj, jlong display, jint screen_index)
{
Display * dpy = (Display *)(intptr_t)display;
@@ -643,7 +639,7 @@ JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_x11_X11Screen_getHeight0
* Method: initIDs
* Signature: ()Z
*/
-JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs
+JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs0
(JNIEnv *env, jclass clazz)
{
windowChangedID = (*env)->GetMethodID(env, clazz, "windowChanged", "(IIII)V");
@@ -671,7 +667,7 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs
* Method: CreateWindow
* Signature: (JJIJIIII)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow0
(JNIEnv *env, jobject obj, jlong parent, jlong display, jint screen_index,
jlong visualID,
jlong javaObjectAtom, jlong windowDeleteAtom,
@@ -800,7 +796,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow
* Method: CloseWindow
* Signature: (JJ)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CloseWindow
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CloseWindow0
(JNIEnv *env, jobject obj, jlong display, jlong window, jlong javaObjectAtom)
{
Display * dpy = (Display *) (intptr_t) display;