diff options
author | JOGAMP DEV TEAM <[email protected]> | 2010-04-22 21:12:36 -0400 |
---|---|---|
committer | JOGAMP DEV TEAM <[email protected]> | 2010-04-22 21:12:36 -0400 |
commit | 1d889ddc4728d1534e310b44fad74a2932d22d39 (patch) | |
tree | 4ad0c3eeb3ef728522ac9459eb12c667301a0c32 /src/newt | |
parent | 8790075f074013aa3c71b96993838cf1117275f1 (diff) | |
parent | a588326d206ff32e5ff5db97560851cb9b826022 (diff) |
Merge branch 'master' of github.com:sgothel/jogl
Diffstat (limited to 'src/newt')
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/Display.java (renamed from src/newt/classes/com/sun/javafx/newt/Display.java) | 61 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/Event.java (renamed from src/newt/classes/com/sun/javafx/newt/Event.java) | 2 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/EventListener.java (renamed from src/newt/classes/com/sun/javafx/newt/EventListener.java) | 2 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/InputEvent.java (renamed from src/newt/classes/com/sun/javafx/newt/InputEvent.java) | 2 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/Insets.java (renamed from src/newt/classes/com/sun/javafx/newt/Insets.java) | 2 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/KeyEvent.java (renamed from src/newt/classes/com/sun/javafx/newt/KeyEvent.java) | 2 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/KeyListener.java (renamed from src/newt/classes/com/sun/javafx/newt/KeyListener.java) | 2 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/MouseEvent.java (renamed from src/newt/classes/com/sun/javafx/newt/MouseEvent.java) | 2 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/MouseListener.java (renamed from src/newt/classes/com/sun/javafx/newt/MouseListener.java) | 2 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/NewtFactory.java (renamed from src/newt/classes/com/sun/javafx/newt/NewtFactory.java) | 4 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/OffscreenWindow.java (renamed from src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java) | 2 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/PaintEvent.java (renamed from src/newt/classes/com/sun/javafx/newt/PaintEvent.java) | 2 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/PaintListener.java (renamed from src/newt/classes/com/sun/javafx/newt/PaintListener.java) | 2 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/Screen.java (renamed from src/newt/classes/com/sun/javafx/newt/Screen.java) | 14 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/Window.java (renamed from src/newt/classes/com/sun/javafx/newt/Window.java) | 242 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/WindowEvent.java (renamed from src/newt/classes/com/sun/javafx/newt/WindowEvent.java) | 2 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/WindowListener.java (renamed from src/newt/classes/com/sun/javafx/newt/WindowListener.java) | 2 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/AWTCanvas.java (renamed from src/newt/classes/com/sun/javafx/newt/awt/AWTCanvas.java) | 6 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/AWTDisplay.java (renamed from src/newt/classes/com/sun/javafx/newt/awt/AWTDisplay.java) | 50 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/AWTScreen.java (renamed from src/newt/classes/com/sun/javafx/newt/awt/AWTScreen.java) | 4 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/AWTWindow.java (renamed from src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java) | 56 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/impl/Debug.java (renamed from src/newt/classes/com/sun/javafx/newt/impl/Debug.java) | 4 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/impl/NEWTJNILibLoader.java (renamed from src/newt/classes/com/sun/javafx/newt/impl/NativeLibLoader.java) | 6 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/intel/gdl/Display.java (renamed from src/newt/classes/com/sun/javafx/newt/intel/gdl/Display.java) | 8 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/intel/gdl/Screen.java (renamed from src/newt/classes/com/sun/javafx/newt/intel/gdl/Screen.java) | 6 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/intel/gdl/Window.java (renamed from src/newt/classes/com/sun/javafx/newt/intel/gdl/Window.java) | 4 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java (renamed from src/newt/classes/com/sun/javafx/newt/macosx/MacDisplay.java) | 10 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/macosx/MacScreen.java (renamed from src/newt/classes/com/sun/javafx/newt/macosx/MacScreen.java) | 4 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/macosx/MacWindow.java (renamed from src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java) | 48 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/opengl/GLWindow.java (renamed from src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java) | 22 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java (renamed from src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Display.java) | 10 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Screen.java (renamed from src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Screen.java) | 5 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Window.java (renamed from src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Window.java) | 8 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java (renamed from src/newt/classes/com/sun/javafx/newt/opengl/kd/KDDisplay.java) | 10 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/opengl/kd/KDScreen.java (renamed from src/newt/classes/com/sun/javafx/newt/opengl/kd/KDScreen.java) | 4 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java (renamed from src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java) | 8 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/util/EDTUtil.java (renamed from src/newt/classes/com/sun/javafx/newt/util/EventDispatchThread.java) | 98 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/util/MainThread.java (renamed from src/newt/classes/com/sun/javafx/newt/util/MainThread.java) | 18 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java (renamed from src/newt/classes/com/sun/javafx/newt/windows/WindowsDisplay.java) | 8 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/windows/WindowsScreen.java (renamed from src/newt/classes/com/sun/javafx/newt/windows/WindowsScreen.java) | 5 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/windows/WindowsWindow.java (renamed from src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java) | 4 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/x11/X11Display.java (renamed from src/newt/classes/com/sun/javafx/newt/x11/X11Display.java) | 16 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/x11/X11Screen.java (renamed from src/newt/classes/com/sun/javafx/newt/x11/X11Screen.java) | 6 | ||||
-rwxr-xr-x | src/newt/classes/com/jogamp/newt/x11/X11Window.java (renamed from src/newt/classes/com/sun/javafx/newt/x11/X11Window.java) | 5 | ||||
-rwxr-xr-x | src/newt/native/BroadcomEGL.c | 16 | ||||
-rw-r--r-- | src/newt/native/IntelGDL.c | 24 | ||||
-rwxr-xr-x | src/newt/native/KDWindow.c | 20 | ||||
-rw-r--r-- | src/newt/native/MacWindow.m | 62 | ||||
-rw-r--r-- | src/newt/native/NewtMacWindow.h | 2 | ||||
-rwxr-xr-x | src/newt/native/NewtMacWindow.m | 2 | ||||
-rwxr-xr-x | src/newt/native/WindowsWindow.c | 74 | ||||
-rwxr-xr-x | src/newt/native/X11Window.c | 194 |
52 files changed, 642 insertions, 532 deletions
diff --git a/src/newt/classes/com/sun/javafx/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index a4b7a4f51..2bc99475c 100755 --- a/src/newt/classes/com/sun/javafx/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -31,11 +31,11 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; import javax.media.nativewindow.*; -import com.sun.javafx.newt.impl.Debug; -import com.sun.javafx.newt.util.EventDispatchThread; +import com.jogamp.newt.impl.Debug; +import com.jogamp.newt.util.EDTUtil; import java.util.*; public abstract class Display { @@ -47,15 +47,15 @@ public abstract class Display { Class displayClass = NewtFactory.getCustomClass(type, "Display"); if(null==displayClass) { if (NativeWindowFactory.TYPE_EGL.equals(type)) { - displayClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDDisplay"); + displayClass = Class.forName("com.jogamp.newt.opengl.kd.KDDisplay"); } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) { - displayClass = Class.forName("com.sun.javafx.newt.windows.WindowsDisplay"); + displayClass = Class.forName("com.jogamp.newt.windows.WindowsDisplay"); } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) { - displayClass = Class.forName("com.sun.javafx.newt.macosx.MacDisplay"); + displayClass = Class.forName("com.jogamp.newt.macosx.MacDisplay"); } else if (NativeWindowFactory.TYPE_X11.equals(type)) { - displayClass = Class.forName("com.sun.javafx.newt.x11.X11Display"); + displayClass = Class.forName("com.jogamp.newt.x11.X11Display"); } else if (NativeWindowFactory.TYPE_AWT.equals(type)) { - displayClass = Class.forName("com.sun.javafx.newt.awt.AWTDisplay"); + displayClass = Class.forName("com.jogamp.newt.awt.AWTDisplay"); } else { throw new RuntimeException("Unknown display type \"" + type + "\""); } @@ -141,11 +141,16 @@ public abstract class Display { display.refCount=1; if(NewtFactory.useEDT()) { - Thread current = Thread.currentThread(); - display.eventDispatchThread = new EventDispatchThread(display, current.getThreadGroup(), current.getName()); - display.eventDispatchThread.start(); final Display f_dpy = display; - display.eventDispatchThread.invokeAndWait(new Runnable() { + Thread current = Thread.currentThread(); + display.edtUtil = new EDTUtil(current.getThreadGroup(), + "Display_"+display.getName()+"-"+current.getName(), + new Runnable() { + public void run() { + f_dpy.pumpMessagesImpl(); + } } ); + display.edt = display.edtUtil.start(); + display.edtUtil.invokeAndWait(new Runnable() { public void run() { f_dpy.createNative(); } @@ -189,7 +194,7 @@ public abstract class Display { } } - public EventDispatchThread getEDT() { return eventDispatchThread; } + public EDTUtil getEDTUtil() { return edtUtil; } public synchronized void destroy() { if(DEBUG) { @@ -201,10 +206,10 @@ public abstract class Display { if(DEBUG) { System.err.println("Display.destroy("+name+") REMOVE: "+this+" "+Thread.currentThread()); } - if(null!=eventDispatchThread) { + if(null!=edtUtil) { final Display f_dpy = this; - final EventDispatchThread f_edt = eventDispatchThread; - eventDispatchThread.invokeAndWait(new Runnable() { + final EDTUtil f_edt = edtUtil; + edtUtil.invokeAndWait(new Runnable() { public void run() { f_dpy.closeNative(); f_edt.stop(); @@ -213,9 +218,9 @@ public abstract class Display { } else { closeNative(); } - if(null!=eventDispatchThread) { - eventDispatchThread.waitUntilStopped(); - eventDispatchThread=null; + if(null!=edtUtil) { + edtUtil.waitUntilStopped(); + edtUtil=null; } aDevice = null; } else { @@ -246,14 +251,13 @@ public abstract class Display { return aDevice; } - public void pumpMessages() { - if(null!=eventDispatchThread) { - dispatchMessages(); - } else { - synchronized(this) { - dispatchMessages(); - } - } + public synchronized void pumpMessages() { + pumpMessagesImpl(); + } + + private void pumpMessagesImpl() { + if(0==refCount) return; + dispatchMessages(); } public String toString() { @@ -268,7 +272,8 @@ public abstract class Display { /** Default impl. nop - Currently only X11 needs a Display lock */ protected void unlockDisplay() { } - protected EventDispatchThread eventDispatchThread = null; + protected EDTUtil edtUtil = null; + protected Thread edt = null; protected String name; protected int refCount; protected AbstractGraphicsDevice aDevice; diff --git a/src/newt/classes/com/sun/javafx/newt/Event.java b/src/newt/classes/com/jogamp/newt/Event.java index 3c045c52b..d42a95735 100644 --- a/src/newt/classes/com/sun/javafx/newt/Event.java +++ b/src/newt/classes/com/jogamp/newt/Event.java @@ -31,7 +31,7 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; public class Event { private boolean isSystemEvent; diff --git a/src/newt/classes/com/sun/javafx/newt/EventListener.java b/src/newt/classes/com/jogamp/newt/EventListener.java index a312752fe..75cb487dd 100644 --- a/src/newt/classes/com/sun/javafx/newt/EventListener.java +++ b/src/newt/classes/com/jogamp/newt/EventListener.java @@ -31,7 +31,7 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; public interface EventListener { diff --git a/src/newt/classes/com/sun/javafx/newt/InputEvent.java b/src/newt/classes/com/jogamp/newt/InputEvent.java index b49c72e75..d4c3f6905 100644 --- a/src/newt/classes/com/sun/javafx/newt/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/InputEvent.java @@ -31,7 +31,7 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; public abstract class InputEvent extends Event { diff --git a/src/newt/classes/com/sun/javafx/newt/Insets.java b/src/newt/classes/com/jogamp/newt/Insets.java index 7d379cd92..e440892f0 100644 --- a/src/newt/classes/com/sun/javafx/newt/Insets.java +++ b/src/newt/classes/com/jogamp/newt/Insets.java @@ -30,7 +30,7 @@ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * */ -package com.sun.javafx.newt; +package com.jogamp.newt; /** * Simple class representing insets. diff --git a/src/newt/classes/com/sun/javafx/newt/KeyEvent.java b/src/newt/classes/com/jogamp/newt/KeyEvent.java index c7450da67..bec77160b 100644 --- a/src/newt/classes/com/sun/javafx/newt/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/KeyEvent.java @@ -31,7 +31,7 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; public class KeyEvent extends InputEvent { diff --git a/src/newt/classes/com/sun/javafx/newt/KeyListener.java b/src/newt/classes/com/jogamp/newt/KeyListener.java index 6f022c45a..28e2b833b 100644 --- a/src/newt/classes/com/sun/javafx/newt/KeyListener.java +++ b/src/newt/classes/com/jogamp/newt/KeyListener.java @@ -31,7 +31,7 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; public interface KeyListener extends EventListener { diff --git a/src/newt/classes/com/sun/javafx/newt/MouseEvent.java b/src/newt/classes/com/jogamp/newt/MouseEvent.java index ede193e1c..d5412c0cc 100644 --- a/src/newt/classes/com/sun/javafx/newt/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/MouseEvent.java @@ -31,7 +31,7 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; public class MouseEvent extends InputEvent { diff --git a/src/newt/classes/com/sun/javafx/newt/MouseListener.java b/src/newt/classes/com/jogamp/newt/MouseListener.java index 3d2031f2a..6d931dd31 100644 --- a/src/newt/classes/com/sun/javafx/newt/MouseListener.java +++ b/src/newt/classes/com/jogamp/newt/MouseListener.java @@ -31,7 +31,7 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; public interface MouseListener extends EventListener { diff --git a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 6e25b19eb..2d5c10c52 100755 --- a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -31,12 +31,12 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; import javax.media.nativewindow.*; import java.util.ArrayList; import java.util.Iterator; -import com.sun.nativewindow.impl.jvm.JVMUtil; +import com.jogamp.common.jvm.JVMUtil; public abstract class NewtFactory { // Work-around for initialization order problems on Mac OS X diff --git a/src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java b/src/newt/classes/com/jogamp/newt/OffscreenWindow.java index 11ce8e6c7..c9c56fc61 100644 --- a/src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java +++ b/src/newt/classes/com/jogamp/newt/OffscreenWindow.java @@ -31,7 +31,7 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; import javax.media.nativewindow.*; diff --git a/src/newt/classes/com/sun/javafx/newt/PaintEvent.java b/src/newt/classes/com/jogamp/newt/PaintEvent.java index b27b969da..51c43725a 100755 --- a/src/newt/classes/com/sun/javafx/newt/PaintEvent.java +++ b/src/newt/classes/com/jogamp/newt/PaintEvent.java @@ -31,7 +31,7 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; /** * diff --git a/src/newt/classes/com/sun/javafx/newt/PaintListener.java b/src/newt/classes/com/jogamp/newt/PaintListener.java index fab5fa35c..6fbc9c8fc 100755 --- a/src/newt/classes/com/sun/javafx/newt/PaintListener.java +++ b/src/newt/classes/com/jogamp/newt/PaintListener.java @@ -31,7 +31,7 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; /** * diff --git a/src/newt/classes/com/sun/javafx/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index 9edd0b719..b393d30de 100755 --- a/src/newt/classes/com/sun/javafx/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -31,9 +31,9 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; -import com.sun.javafx.newt.impl.*; +import com.jogamp.newt.impl.*; import javax.media.nativewindow.*; import java.security.*; @@ -46,15 +46,15 @@ public abstract class Screen { Class screenClass = NewtFactory.getCustomClass(type, "Screen"); if(null==screenClass) { if (NativeWindowFactory.TYPE_EGL.equals(type)) { - screenClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDScreen"); + screenClass = Class.forName("com.jogamp.newt.opengl.kd.KDScreen"); } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) { - screenClass = Class.forName("com.sun.javafx.newt.windows.WindowsScreen"); + screenClass = Class.forName("com.jogamp.newt.windows.WindowsScreen"); } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) { - screenClass = Class.forName("com.sun.javafx.newt.macosx.MacScreen"); + screenClass = Class.forName("com.jogamp.newt.macosx.MacScreen"); } else if (NativeWindowFactory.TYPE_X11.equals(type)) { - screenClass = Class.forName("com.sun.javafx.newt.x11.X11Screen"); + screenClass = Class.forName("com.jogamp.newt.x11.X11Screen"); } else if (NativeWindowFactory.TYPE_AWT.equals(type)) { - screenClass = Class.forName("com.sun.javafx.newt.awt.AWTScreen"); + screenClass = Class.forName("com.jogamp.newt.awt.AWTScreen"); } else { throw new RuntimeException("Unknown window type \"" + type + "\""); } diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 58bd251d2..b1f8b3977 100755 --- a/src/newt/classes/com/sun/javafx/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -31,13 +31,13 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; -import com.sun.javafx.newt.impl.Debug; -import com.sun.javafx.newt.util.EventDispatchThread; +import com.jogamp.newt.impl.Debug; +import com.jogamp.newt.util.EDTUtil; +import com.jogamp.common.util.*; import javax.media.nativewindow.*; -import com.sun.nativewindow.impl.NWReflection; import java.util.ArrayList; import java.util.Iterator; @@ -70,15 +70,15 @@ public abstract class Window implements NativeWindow Class windowClass = NewtFactory.getCustomClass(type, "Window"); if(null==windowClass) { if (NativeWindowFactory.TYPE_EGL.equals(type)) { - windowClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDWindow"); + windowClass = Class.forName("com.jogamp.newt.opengl.kd.KDWindow"); } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) { - windowClass = Class.forName("com.sun.javafx.newt.windows.WindowsWindow"); + windowClass = Class.forName("com.jogamp.newt.windows.WindowsWindow"); } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) { - windowClass = Class.forName("com.sun.javafx.newt.macosx.MacWindow"); + windowClass = Class.forName("com.jogamp.newt.macosx.MacWindow"); } else if (NativeWindowFactory.TYPE_X11.equals(type)) { - windowClass = Class.forName("com.sun.javafx.newt.x11.X11Window"); + windowClass = Class.forName("com.jogamp.newt.x11.X11Window"); } else if (NativeWindowFactory.TYPE_AWT.equals(type)) { - windowClass = Class.forName("com.sun.javafx.newt.awt.AWTWindow"); + windowClass = Class.forName("com.jogamp.newt.awt.AWTWindow"); } else { throw new NativeWindowException("Unknown window type \"" + type + "\""); } @@ -98,10 +98,10 @@ public abstract class Window implements NativeWindow window.invalidate(); window.screen = screen; window.setUndecorated(undecorated||0!=parentWindowHandle); - EventDispatchThread edt = screen.getDisplay().getEDT(); - if(null!=edt) { + EDTUtil edtUtil = screen.getDisplay().getEDTUtil(); + if(null!=edtUtil) { final Window f_win = window; - edt.invokeAndWait(new Runnable() { + edtUtil.invokeAndWait(new Runnable() { public void run() { f_win.createNative(parentWindowHandle, caps); } @@ -109,6 +109,9 @@ public abstract class Window implements NativeWindow } 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(); @@ -127,14 +130,14 @@ public abstract class Window implements NativeWindow if ( argsChecked < cstrArguments.length ) { throw new NativeWindowException("WindowClass "+windowClass+" constructor mismatch at argument #"+argsChecked+"; Constructor: "+getTypeStrList(cstrArgumentTypes)+", arguments: "+getArgsStrList(cstrArguments)); } - Window window = (Window) NWReflection.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ; + Window window = (Window) ReflectionUtil.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ; window.invalidate(); window.screen = screen; window.setUndecorated(undecorated); - EventDispatchThread edt = screen.getDisplay().getEDT(); - if(null!=edt) { + EDTUtil edtUtil = screen.getDisplay().getEDTUtil(); + if(null!=edtUtil) { final Window f_win = window; - edt.invokeAndWait(new Runnable() { + edtUtil.invokeAndWait(new Runnable() { public void run() { f_win.createNative(0, caps); } @@ -142,9 +145,11 @@ public abstract class Window implements NativeWindow } else { window.createNative(0, caps); } + if(DEBUG_WINDOW_EVENT) { + System.out.println("Window.create-2() done ("+Thread.currentThread()+", "+window+")"); + } return window; } catch (Throwable t) { - t.printStackTrace(); throw new NativeWindowException(t); } } @@ -212,15 +217,15 @@ public abstract class Window implements NativeWindow public String toString() { StringBuffer sb = new StringBuffer(); - sb.append(getClass().getName()+"[config "+config+ - ", windowHandle "+toHexString(getWindowHandle())+ - ", surfaceHandle "+toHexString(getSurfaceHandle())+ - ", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ - ", visible "+isVisible()+ - ", undecorated "+undecorated+ - ", fullscreen "+fullscreen+ - ", "+screen+ - ", wrappedWindow "+getWrappedWindow()); + sb.append(getClass().getName()+"[Config "+config+ + "\n, "+screen+ + "\n, WindowHandle "+toHexString(getWindowHandle())+ + "\n, SurfaceHandle "+toHexString(getSurfaceHandle())+ + "\n, Pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ + "\n, Visible "+isVisible()+ + "\n, Undecorated "+undecorated+ + "\n, Fullscreen "+fullscreen+ + "\n, WrappedWindow "+getWrappedWindow()); sb.append(", SurfaceUpdatedListeners num "+surfaceUpdatedListeners.size()+" ["); for (Iterator iter = surfaceUpdatedListeners.iterator(); iter.hasNext(); ) { @@ -264,71 +269,48 @@ public abstract class Window implements NativeWindow // // NativeWindow impl // - private Thread owner; - private int recursionCount; - protected Exception lockedStack = null; /** Recursive and blocking lockSurface() implementation */ public synchronized int lockSurface() { // We leave the ToolkitLock lock to the specializtion's discretion, // ie the implicit JAWTWindow in case of AWTWindow - Thread cur = Thread.currentThread(); - if (owner == cur) { - ++recursionCount; - return LOCK_SUCCESS; - } - while (owner != null) { - try { - wait(); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - owner = cur; - lockedStack = new Exception("NEWT Surface previously locked by "+Thread.currentThread()); + surfaceLock.lock(); screen.getDisplay().lockDisplay(); return LOCK_SUCCESS; } /** Recursive and unblocking unlockSurface() implementation */ public synchronized void unlockSurface() throws NativeWindowException { - Thread cur = Thread.currentThread(); - if (owner != cur) { - lockedStack.printStackTrace(); - throw new NativeWindowException(cur+": Not owner, owner is "+owner); - } - if (recursionCount > 0) { - --recursionCount; - return; - } - owner = null; - lockedStack = null; - screen.getDisplay().unlockDisplay(); - notifyAll(); + surfaceLock.unlock( new Runnable() { + final Screen f_screen = screen; + public void run() { + screen.getDisplay().unlockDisplay(); + } + } ); // We leave the ToolkitLock unlock to the specializtion's discretion, // ie the implicit JAWTWindow in case of AWTWindow } public synchronized boolean isSurfaceLocked() { - return null!=owner; + return surfaceLock.isLocked(); } public synchronized Thread getSurfaceLockOwner() { - return owner; + return surfaceLock.getOwner(); } public synchronized Exception getLockedStack() { - return lockedStack; + return surfaceLock.getLockedStack(); } - public synchronized void destroy() { + public void destroy() { destroy(false); } /** @param deep If true, the linked Screen and Display will be destroyed as well. */ - public synchronized void destroy(boolean deep) { + public void destroy(boolean deep) { if(DEBUG_WINDOW_EVENT) { - System.out.println("Window.destroy() start (deep "+deep+" - "+Thread.currentThread()); + System.out.println("Window.destroy() start (deep "+deep+" - "+Thread.currentThread()+", "+this+")"); } synchronized(surfaceUpdatedListeners) { surfaceUpdatedListeners = new ArrayList(); @@ -342,26 +324,36 @@ public abstract class Window implements NativeWindow synchronized(keyListeners) { keyListeners = new ArrayList(); } - Screen scr = screen; - Display dpy = (null!=screen) ? screen.getDisplay() : null; - EventDispatchThread edt = (null!=dpy) ? dpy.getEDT() : null; - if(null!=edt) { - final Window f_win = this; - edt.invokeAndWait(new Runnable() { - public void run() { - f_win.closeNative(); + synchronized(this) { + destructionLock.lock(); + try { + Display dpy = null; + if( null != screen && 0 != windowHandle ) { + Screen scr = screen; + dpy = (null!=screen) ? screen.getDisplay() : null; + EDTUtil edtUtil = (null!=dpy) ? dpy.getEDTUtil() : null; + if(null!=edtUtil) { + final Window f_win = this; + edtUtil.invokeAndWait(new Runnable() { + public void run() { + f_win.closeNative(); + } + } ); + } else { + closeNative(); + } } - } ); - } else { - closeNative(); - } - invalidate(); - if(deep) { - if(null!=scr) { - scr.destroy(); - } - if(null!=dpy) { - dpy.destroy(); + invalidate(); + if(deep) { + if(null!=screen) { + screen.destroy(); + } + if(null!=dpy) { + dpy.destroy(); + } + } + } finally { + destructionLock.unlock(); } } if(DEBUG_WINDOW_EVENT) { @@ -487,12 +479,12 @@ public abstract class Window implements NativeWindow protected void windowDestroyNotify() { if(DEBUG_WINDOW_EVENT) { - System.out.println("Window.windowDestroyeNotify start "+Thread.currentThread()); + System.out.println("Window.windowDestroyNotify start "+Thread.currentThread()); } sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); - if(!autoDrawableMember) { + if(!autoDrawableMember && !destructionLock.isLocked()) { destroy(); } @@ -505,7 +497,9 @@ public abstract class Window implements NativeWindow if(DEBUG_WINDOW_EVENT) { System.out.println("Window.windowDestroyed "+Thread.currentThread()); } - invalidate(); + if(!destructionLock.isLocked()) { + invalidate(); + } } public abstract void setVisible(boolean visible); @@ -554,6 +548,12 @@ public abstract class Window implements NativeWindow } } + public void removeAllSurfaceUpdatedListener() { + synchronized(surfaceUpdatedListeners) { + surfaceUpdatedListeners = new ArrayList(); + } + } + public SurfaceUpdatedListener[] getSurfaceUpdatedListener() { synchronized(surfaceUpdatedListeners) { return (SurfaceUpdatedListener[]) surfaceUpdatedListeners.toArray(); @@ -926,4 +926,78 @@ public abstract class Window implements NativeWindow } return sb.toString(); } + + // + // Reentrance locking toolkit + // + public static class WindowToolkitLock implements ToolkitLock { + private Thread owner; + private int recursionCount; + private Exception lockedStack = null; + + public Exception getLockedStack() { + return lockedStack; + } + + public Thread getOwner() { + return owner; + } + + public boolean isOwner() { + return isOwner(Thread.currentThread()); + } + + public synchronized boolean isOwner(Thread thread) { + return owner == thread ; + } + + public synchronized boolean isLocked() { + return null != owner; + } + + /** Recursive and blocking lockSurface() implementation */ + public synchronized void lock() { + Thread cur = Thread.currentThread(); + if (owner == cur) { + ++recursionCount; + } + while (owner != null) { + try { + wait(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + owner = cur; + lockedStack = new Exception("Previously locked by "+owner); + } + + + /** Recursive and unblocking unlockSurface() implementation */ + public synchronized void unlock() { + unlock(null); + } + + /** Recursive and unblocking unlockSurface() implementation */ + public synchronized void unlock(Runnable releaseAfterUnlockBeforeNotify) { + Thread cur = Thread.currentThread(); + if (owner != cur) { + lockedStack.printStackTrace(); + throw new RuntimeException(cur+": Not owner, owner is "+owner); + } + if (recursionCount > 0) { + --recursionCount; + return; + } + owner = null; + lockedStack = null; + if(null!=releaseAfterUnlockBeforeNotify) { + releaseAfterUnlockBeforeNotify.run(); + } + notifyAll(); + } + } + private WindowToolkitLock destructionLock = new WindowToolkitLock(); + private WindowToolkitLock surfaceLock = new WindowToolkitLock(); } + diff --git a/src/newt/classes/com/sun/javafx/newt/WindowEvent.java b/src/newt/classes/com/jogamp/newt/WindowEvent.java index c5aa65e3d..1189401af 100644 --- a/src/newt/classes/com/sun/javafx/newt/WindowEvent.java +++ b/src/newt/classes/com/jogamp/newt/WindowEvent.java @@ -31,7 +31,7 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; public class WindowEvent extends Event { public static final int EVENT_WINDOW_RESIZED = 100; diff --git a/src/newt/classes/com/sun/javafx/newt/WindowListener.java b/src/newt/classes/com/jogamp/newt/WindowListener.java index 81624fa75..0ec63435c 100644 --- a/src/newt/classes/com/sun/javafx/newt/WindowListener.java +++ b/src/newt/classes/com/jogamp/newt/WindowListener.java @@ -31,7 +31,7 @@ * */ -package com.sun.javafx.newt; +package com.jogamp.newt; public interface WindowListener extends EventListener { public void windowResized(WindowEvent e); diff --git a/src/newt/classes/com/sun/javafx/newt/awt/AWTCanvas.java b/src/newt/classes/com/jogamp/newt/awt/AWTCanvas.java index 6b8fc43c7..f6ea9acc3 100644 --- a/src/newt/classes/com/sun/javafx/newt/awt/AWTCanvas.java +++ b/src/newt/classes/com/jogamp/newt/awt/AWTCanvas.java @@ -31,9 +31,9 @@ * */ -package com.sun.javafx.newt.awt; +package com.jogamp.newt.awt; -import com.sun.javafx.newt.Window; +import com.jogamp.newt.Window; import java.awt.Canvas; import java.awt.GraphicsDevice; @@ -42,7 +42,7 @@ import java.awt.GraphicsConfiguration; import javax.media.nativewindow.*; import javax.media.nativewindow.awt.*; -import com.sun.javafx.newt.impl.Debug; +import com.jogamp.newt.impl.Debug; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; diff --git a/src/newt/classes/com/sun/javafx/newt/awt/AWTDisplay.java b/src/newt/classes/com/jogamp/newt/awt/AWTDisplay.java index 19f3ed1a8..09ce10017 100644 --- a/src/newt/classes/com/sun/javafx/newt/awt/AWTDisplay.java +++ b/src/newt/classes/com/jogamp/newt/awt/AWTDisplay.java @@ -31,11 +31,11 @@ * */ -package com.sun.javafx.newt.awt; +package com.jogamp.newt.awt; import java.awt.event.*; -import com.sun.javafx.newt.Display; -import com.sun.javafx.newt.Window; +import com.jogamp.newt.Display; +import com.jogamp.newt.Window; import javax.media.nativewindow.*; import javax.media.nativewindow.awt.*; import java.util.*; @@ -66,20 +66,20 @@ public class AWTDisplay extends Display { } if (w != null) { switch (w.getType()) { - case com.sun.javafx.newt.WindowEvent.EVENT_WINDOW_RESIZED: - case com.sun.javafx.newt.WindowEvent.EVENT_WINDOW_MOVED: - case com.sun.javafx.newt.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY: + case com.jogamp.newt.WindowEvent.EVENT_WINDOW_RESIZED: + case com.jogamp.newt.WindowEvent.EVENT_WINDOW_MOVED: + case com.jogamp.newt.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY: w.getWindow().sendWindowEvent(w.getType()); break; - case com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_CLICKED: - case com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_ENTERED: - case com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_EXITED: - case com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_PRESSED: - case com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_RELEASED: - case com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_MOVED: - case com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_DRAGGED: - case com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_WHEEL_MOVED: + case com.jogamp.newt.MouseEvent.EVENT_MOUSE_CLICKED: + case com.jogamp.newt.MouseEvent.EVENT_MOUSE_ENTERED: + case com.jogamp.newt.MouseEvent.EVENT_MOUSE_EXITED: + case com.jogamp.newt.MouseEvent.EVENT_MOUSE_PRESSED: + case com.jogamp.newt.MouseEvent.EVENT_MOUSE_RELEASED: + case com.jogamp.newt.MouseEvent.EVENT_MOUSE_MOVED: + case com.jogamp.newt.MouseEvent.EVENT_MOUSE_DRAGGED: + case com.jogamp.newt.MouseEvent.EVENT_MOUSE_WHEEL_MOVED: { MouseEvent e = (MouseEvent) w.getEvent(); int rotation = 0; @@ -92,9 +92,9 @@ public class AWTDisplay extends Display { } break; - case com.sun.javafx.newt.KeyEvent.EVENT_KEY_PRESSED: - case com.sun.javafx.newt.KeyEvent.EVENT_KEY_RELEASED: - case com.sun.javafx.newt.KeyEvent.EVENT_KEY_TYPED: + case com.jogamp.newt.KeyEvent.EVENT_KEY_PRESSED: + case com.jogamp.newt.KeyEvent.EVENT_KEY_RELEASED: + case com.jogamp.newt.KeyEvent.EVENT_KEY_TYPED: { KeyEvent e = (KeyEvent) w.getEvent(); w.getWindow().sendKeyEvent(w.getType(), convertModifiers(e), @@ -148,19 +148,19 @@ public class AWTDisplay extends Display { private static int convertModifiers(InputEvent e) { int newtMods = 0; int mods = e.getModifiers(); - if ((mods & InputEvent.SHIFT_MASK) != 0) newtMods |= com.sun.javafx.newt.InputEvent.SHIFT_MASK; - if ((mods & InputEvent.CTRL_MASK) != 0) newtMods |= com.sun.javafx.newt.InputEvent.CTRL_MASK; - if ((mods & InputEvent.META_MASK) != 0) newtMods |= com.sun.javafx.newt.InputEvent.META_MASK; - if ((mods & InputEvent.ALT_MASK) != 0) newtMods |= com.sun.javafx.newt.InputEvent.ALT_MASK; - if ((mods & InputEvent.ALT_GRAPH_MASK) != 0) newtMods |= com.sun.javafx.newt.InputEvent.ALT_GRAPH_MASK; + if ((mods & InputEvent.SHIFT_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.SHIFT_MASK; + if ((mods & InputEvent.CTRL_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.CTRL_MASK; + if ((mods & InputEvent.META_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.META_MASK; + if ((mods & InputEvent.ALT_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.ALT_MASK; + if ((mods & InputEvent.ALT_GRAPH_MASK) != 0) newtMods |= com.jogamp.newt.InputEvent.ALT_GRAPH_MASK; return newtMods; } private static int convertButton(MouseEvent e) { switch (e.getButton()) { - case MouseEvent.BUTTON1: return com.sun.javafx.newt.MouseEvent.BUTTON1; - case MouseEvent.BUTTON2: return com.sun.javafx.newt.MouseEvent.BUTTON2; - case MouseEvent.BUTTON3: return com.sun.javafx.newt.MouseEvent.BUTTON3; + case MouseEvent.BUTTON1: return com.jogamp.newt.MouseEvent.BUTTON1; + case MouseEvent.BUTTON2: return com.jogamp.newt.MouseEvent.BUTTON2; + case MouseEvent.BUTTON3: return com.jogamp.newt.MouseEvent.BUTTON3; } return 0; } diff --git a/src/newt/classes/com/sun/javafx/newt/awt/AWTScreen.java b/src/newt/classes/com/jogamp/newt/awt/AWTScreen.java index 9bda5893b..c804bce06 100644 --- a/src/newt/classes/com/sun/javafx/newt/awt/AWTScreen.java +++ b/src/newt/classes/com/jogamp/newt/awt/AWTScreen.java @@ -31,9 +31,9 @@ * */ -package com.sun.javafx.newt.awt; +package com.jogamp.newt.awt; -import com.sun.javafx.newt.*; +import com.jogamp.newt.*; import java.awt.DisplayMode; import javax.media.nativewindow.*; import javax.media.nativewindow.awt.*; diff --git a/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java b/src/newt/classes/com/jogamp/newt/awt/AWTWindow.java index 9725cf08b..7beeed44b 100644 --- a/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java +++ b/src/newt/classes/com/jogamp/newt/awt/AWTWindow.java @@ -31,7 +31,7 @@ * */ -package com.sun.javafx.newt.awt; +package com.jogamp.newt.awt; import java.awt.BorderLayout; import java.awt.Canvas; @@ -47,7 +47,7 @@ import java.awt.event.*; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.*; -import com.sun.javafx.newt.Window; +import com.jogamp.newt.Window; import java.awt.Insets; import javax.media.nativewindow.*; import javax.media.nativewindow.awt.*; @@ -134,18 +134,30 @@ public class AWTWindow extends Window { } } }); + this.windowHandle = 1; // just a marker .. } protected void closeNative() { - runOnEDT(true, new Runnable() { - public void run() { - if(owningFrame && null!=frame) { + this.windowHandle = 0; // just a marker .. + if(null!=container) { + runOnEDT(true, new Runnable() { + public void run() { + container.setVisible(false); + container.remove(canvas); + container.setEnabled(false); + canvas.setEnabled(false); + } + }); + } + if(owningFrame && null!=frame) { + runOnEDT(true, new Runnable() { + public void run() { frame.dispose(); owningFrame=false; + frame = null; } - frame = null; - } - }); + }); + } } public boolean hasDeviceChanged() { @@ -204,7 +216,7 @@ public class AWTWindow extends Window { }); } - public com.sun.javafx.newt.Insets getInsets() { + public com.jogamp.newt.Insets getInsets() { final int insets[] = new int[] { 0, 0, 0, 0 }; runOnEDT(true, new Runnable() { public void run() { @@ -215,7 +227,7 @@ public class AWTWindow extends Window { insets[3] = contInsets.right; } }); - return new com.sun.javafx.newt. + return new com.jogamp.newt. Insets(insets[0],insets[1],insets[2],insets[3]); } @@ -324,7 +336,7 @@ public class AWTWindow extends Window { x = container.getX(); y = container.getY(); } - display.enqueueEvent(window, com.sun.javafx.newt.WindowEvent.EVENT_WINDOW_MOVED, null); + display.enqueueEvent(window, com.jogamp.newt.WindowEvent.EVENT_WINDOW_MOVED, null); } public void componentShown(ComponentEvent e) { @@ -347,7 +359,7 @@ public class AWTWindow extends Window { public void componentResized(ComponentEvent e) { width = canvas.getWidth(); height = canvas.getHeight(); - display.enqueueEvent(window, com.sun.javafx.newt.WindowEvent.EVENT_WINDOW_RESIZED, null); + display.enqueueEvent(window, com.jogamp.newt.WindowEvent.EVENT_WINDOW_RESIZED, null); } public void componentMoved(ComponentEvent e) { @@ -365,39 +377,39 @@ public class AWTWindow extends Window { } public void mouseEntered(MouseEvent e) { - display.enqueueEvent(window, com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_ENTERED, e); + display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_ENTERED, e); } public void mouseExited(MouseEvent e) { - display.enqueueEvent(window, com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_EXITED, e); + display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_EXITED, e); } public void mousePressed(MouseEvent e) { - display.enqueueEvent(window, com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_PRESSED, e); + display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_PRESSED, e); } public void mouseReleased(MouseEvent e) { - display.enqueueEvent(window, com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_RELEASED, e); + display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_RELEASED, e); } public void mouseMoved(MouseEvent e) { - display.enqueueEvent(window, com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_MOVED, e); + display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_MOVED, e); } public void mouseDragged(MouseEvent e) { - display.enqueueEvent(window, com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_DRAGGED, e); + display.enqueueEvent(window, com.jogamp.newt.MouseEvent.EVENT_MOUSE_DRAGGED, e); } public void keyPressed(KeyEvent e) { - display.enqueueEvent(window, com.sun.javafx.newt.KeyEvent.EVENT_KEY_PRESSED, e); + display.enqueueEvent(window, com.jogamp.newt.KeyEvent.EVENT_KEY_PRESSED, e); } public void keyReleased(KeyEvent e) { - display.enqueueEvent(window, com.sun.javafx.newt.KeyEvent.EVENT_KEY_RELEASED, e); + display.enqueueEvent(window, com.jogamp.newt.KeyEvent.EVENT_KEY_RELEASED, e); } public void keyTyped(KeyEvent e) { - display.enqueueEvent(window, com.sun.javafx.newt.KeyEvent.EVENT_KEY_TYPED, e); + display.enqueueEvent(window, com.jogamp.newt.KeyEvent.EVENT_KEY_TYPED, e); } } @@ -415,7 +427,7 @@ public class AWTWindow extends Window { public void windowClosed(WindowEvent e) { } public void windowClosing(WindowEvent e) { - display.enqueueEvent(window, com.sun.javafx.newt.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY, null); + display.enqueueEvent(window, com.jogamp.newt.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY, null); } public void windowDeactivated(WindowEvent e) { } diff --git a/src/newt/classes/com/sun/javafx/newt/impl/Debug.java b/src/newt/classes/com/jogamp/newt/impl/Debug.java index 202d9d5b3..62c261d2e 100644 --- a/src/newt/classes/com/sun/javafx/newt/impl/Debug.java +++ b/src/newt/classes/com/jogamp/newt/impl/Debug.java @@ -37,7 +37,7 @@ * and developed by Kenneth Bradley Russell and Christopher John Kline. */ -package com.sun.javafx.newt.impl; +package com.jogamp.newt.impl; import java.security.*; @@ -54,7 +54,7 @@ public class Debug { verbose = isPropertyDefined("newt.verbose", true); debugAll = isPropertyDefined("newt.debug", true); if (verbose) { - Package p = Package.getPackage("com.sun.javafx.newt"); + Package p = Package.getPackage("com.jogamp.newt"); System.err.println("NEWT specification version " + p.getSpecificationVersion()); System.err.println("NEWT implementation version " + p.getImplementationVersion()); System.err.println("NEWT implementation vendor " + p.getImplementationVendor()); diff --git a/src/newt/classes/com/sun/javafx/newt/impl/NativeLibLoader.java b/src/newt/classes/com/jogamp/newt/impl/NEWTJNILibLoader.java index d96c56f6e..a4d234fd5 100644 --- a/src/newt/classes/com/sun/javafx/newt/impl/NativeLibLoader.java +++ b/src/newt/classes/com/jogamp/newt/impl/NEWTJNILibLoader.java @@ -37,7 +37,7 @@ * and developed by Kenneth Bradley Russell and Christopher John Kline. */ -package com.sun.javafx.newt.impl; +package com.jogamp.newt.impl; // FIXME: refactor Java SE dependencies //import java.awt.Toolkit; @@ -46,9 +46,9 @@ import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashSet; -import com.sun.nativewindow.impl.NativeLibLoaderBase; +import com.jogamp.common.jvm.JNILibLoaderBase; -public class NativeLibLoader extends NativeLibLoaderBase { +public class NEWTJNILibLoader extends JNILibLoaderBase { public static void loadNEWT() { AccessController.doPrivileged(new PrivilegedAction() { diff --git a/src/newt/classes/com/sun/javafx/newt/intel/gdl/Display.java b/src/newt/classes/com/jogamp/newt/intel/gdl/Display.java index b1f0ac6d2..a3e5501c4 100644 --- a/src/newt/classes/com/sun/javafx/newt/intel/gdl/Display.java +++ b/src/newt/classes/com/jogamp/newt/intel/gdl/Display.java @@ -31,16 +31,16 @@ * */ -package com.sun.javafx.newt.intel.gdl; +package com.jogamp.newt.intel.gdl; -import com.sun.javafx.newt.impl.*; +import com.jogamp.newt.impl.*; import javax.media.nativewindow.*; -public class Display extends com.sun.javafx.newt.Display { +public class Display extends com.jogamp.newt.Display { static int initCounter = 0; static { - NativeLibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWT(); if (!Screen.initIDs()) { throw new NativeWindowException("Failed to initialize GDL Screen jmethodIDs"); diff --git a/src/newt/classes/com/sun/javafx/newt/intel/gdl/Screen.java b/src/newt/classes/com/jogamp/newt/intel/gdl/Screen.java index 83d9074e2..873d1d009 100644 --- a/src/newt/classes/com/sun/javafx/newt/intel/gdl/Screen.java +++ b/src/newt/classes/com/jogamp/newt/intel/gdl/Screen.java @@ -31,12 +31,12 @@ * */ -package com.sun.javafx.newt.intel.gdl; +package com.jogamp.newt.intel.gdl; -import com.sun.javafx.newt.impl.*; +import com.jogamp.newt.impl.*; import javax.media.nativewindow.*; -public class Screen extends com.sun.javafx.newt.Screen { +public class Screen extends com.jogamp.newt.Screen { static { Display.initSingleton(); diff --git a/src/newt/classes/com/sun/javafx/newt/intel/gdl/Window.java b/src/newt/classes/com/jogamp/newt/intel/gdl/Window.java index 0332f442a..879fc6134 100644 --- a/src/newt/classes/com/sun/javafx/newt/intel/gdl/Window.java +++ b/src/newt/classes/com/jogamp/newt/intel/gdl/Window.java @@ -31,11 +31,11 @@ * */ -package com.sun.javafx.newt.intel.gdl; +package com.jogamp.newt.intel.gdl; import javax.media.nativewindow.*; -public class Window extends com.sun.javafx.newt.Window { +public class Window extends com.jogamp.newt.Window { static { Display.initSingleton(); } diff --git a/src/newt/classes/com/sun/javafx/newt/macosx/MacDisplay.java b/src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java index cd22b2b36..0b5297685 100755 --- a/src/newt/classes/com/sun/javafx/newt/macosx/MacDisplay.java +++ b/src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java @@ -31,17 +31,17 @@ * */ -package com.sun.javafx.newt.macosx; +package com.jogamp.newt.macosx; import javax.media.nativewindow.*; import javax.media.nativewindow.macosx.*; -import com.sun.javafx.newt.*; -import com.sun.javafx.newt.impl.*; -import com.sun.javafx.newt.util.MainThread; +import com.jogamp.newt.*; +import com.jogamp.newt.impl.*; +import com.jogamp.newt.util.MainThread; public class MacDisplay extends Display { static { - NativeLibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWT(); if(!initNSApplication()) { throw new NativeWindowException("Failed to initialize native Application hook"); diff --git a/src/newt/classes/com/sun/javafx/newt/macosx/MacScreen.java b/src/newt/classes/com/jogamp/newt/macosx/MacScreen.java index 8983b8803..92f8e908c 100755 --- a/src/newt/classes/com/sun/javafx/newt/macosx/MacScreen.java +++ b/src/newt/classes/com/jogamp/newt/macosx/MacScreen.java @@ -31,9 +31,9 @@ * */ -package com.sun.javafx.newt.macosx; +package com.jogamp.newt.macosx; -import com.sun.javafx.newt.*; +import com.jogamp.newt.*; import javax.media.nativewindow.*; public class MacScreen extends Screen { diff --git a/src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java b/src/newt/classes/com/jogamp/newt/macosx/MacWindow.java index 9f501ac9b..52d6fb0c7 100755 --- a/src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java +++ b/src/newt/classes/com/jogamp/newt/macosx/MacWindow.java @@ -31,13 +31,13 @@ * */ -package com.sun.javafx.newt.macosx; +package com.jogamp.newt.macosx; import javax.media.nativewindow.*; -import com.sun.javafx.newt.util.MainThread; -import com.sun.javafx.newt.*; -import com.sun.javafx.newt.impl.*; +import com.jogamp.newt.util.MainThread; +import com.jogamp.newt.*; +import com.jogamp.newt.impl.*; public class MacWindow extends Window { @@ -212,42 +212,16 @@ public class MacWindow extends Window { } } - private ToolkitLock nsViewLock = new ToolkitLock() { - private Thread owner; - private int recursionCount; - - public synchronized void lock() { - Thread cur = Thread.currentThread(); - if (owner == cur) { - ++recursionCount; - return; - } - while (owner != null) { - try { - wait(); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - owner = cur; - } - - public synchronized void unlock() { - if (owner != Thread.currentThread()) { - throw new RuntimeException("Not owner"); - } - if (recursionCount > 0) { - --recursionCount; - return; - } - owner = null; - notifyAll(); - } - }; + private WindowToolkitLock nsViewLock = new WindowToolkitLock(); public synchronized int lockSurface() throws NativeWindowException { nsViewLock.lock(); - return super.lockSurface(); + try { + return super.lockSurface(); + } catch (RuntimeException re) { + nsViewLock.unlock(); + throw re; + } } public void unlockSurface() { diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index e809d2cdc..fec70c99c 100644 --- a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -31,12 +31,12 @@ * */ -package com.sun.javafx.newt.opengl; +package com.jogamp.newt.opengl; -import com.sun.javafx.newt.*; +import com.jogamp.newt.*; import javax.media.nativewindow.*; import javax.media.opengl.*; -import com.sun.opengl.impl.GLDrawableHelper; +import com.jogamp.opengl.impl.GLDrawableHelper; import java.util.*; /** @@ -58,13 +58,14 @@ public class GLWindow extends Window implements GLAutoDrawable { private Window window; private boolean runPumpMessages; - /** Constructor. Do not call this directly -- use {@link - create()} instead. */ + /** + * Constructor. Do not call this directly -- use {@link #create()} instead. + */ protected GLWindow(Window window, boolean ownerOfWinScrDpy) { this.ownerOfWinScrDpy = ownerOfWinScrDpy; this.window = window; this.window.setAutoDrawableClient(true); - this.runPumpMessages = ( null == getScreen().getDisplay().getEDT() ) ; + this.runPumpMessages = ( null == getScreen().getDisplay().getEDTUtil() ) ; window.addWindowListener(new WindowListener() { public void windowResized(WindowEvent e) { sendReshape = true; @@ -145,13 +146,13 @@ public class GLWindow extends Window implements GLAutoDrawable { * Best performance has been achieved with one GLWindow per thread.<br> * * Enabling local pump messages while using the EDT, - * {@link com.sun.javafx.newt.NewtFactory#setUseEDT(boolean)}, + * {@link com.jogamp.newt.NewtFactory#setUseEDT(boolean)}, * will result in an exception. * * @deprecated EXPERIMENTAL, semantic is about to be removed after further verification. */ public void setRunPumpMessages(boolean onoff) { - if( onoff && null!=getScreen().getDisplay().getEDT() ) { + if( onoff && null!=getScreen().getDisplay().getEDTUtil() ) { throw new GLException("GLWindow.setRunPumpMessages(true) - Can't do with EDT on"); } runPumpMessages = onoff; @@ -334,6 +335,9 @@ public class GLWindow extends Window implements GLAutoDrawable { public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { window.removeSurfaceUpdatedListener(l); } + public void removeAllSurfaceUpdatedListener() { + window.removeAllSurfaceUpdatedListener(); + } public SurfaceUpdatedListener[] getSurfaceUpdatedListener() { return window.getSurfaceUpdatedListener(); } @@ -378,7 +382,7 @@ public class GLWindow extends Window implements GLAutoDrawable { } public String toString() { - return "NEWT-GLWindow[ \n\tDrawable: "+drawable+", \n\tWindow: "+window+", \n\tHelper: "+helper+", \n\tFactory: "+factory+"]"; + return "NEWT-GLWindow[ \n\tHelper: "+helper+", \n\tDrawable: "+drawable + /** ", \n\tWindow: "+window+", \n\tFactory: "+factory+ */ "]"; } //---------------------------------------------------------------------- diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Display.java b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java index debe9e9b9..999a407ec 100644 --- a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Display.java +++ b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java @@ -31,17 +31,17 @@ * */ -package com.sun.javafx.newt.opengl.broadcom.egl; +package com.jogamp.newt.opengl.broadcom.egl; -import com.sun.javafx.newt.impl.*; -import com.sun.opengl.impl.egl.*; +import com.jogamp.newt.impl.*; +import com.jogamp.opengl.impl.egl.*; import javax.media.nativewindow.*; import javax.media.nativewindow.egl.*; -public class Display extends com.sun.javafx.newt.Display { +public class Display extends com.jogamp.newt.Display { static { - NativeLibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWT(); if (!Window.initIDs()) { throw new NativeWindowException("Failed to initialize BCEGL Window jmethodIDs"); diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Screen.java b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Screen.java index 28f7211c3..b4f07599b 100755 --- a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Screen.java +++ b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Screen.java @@ -31,12 +31,11 @@ * */ -package com.sun.javafx.newt.opengl.broadcom.egl; +package com.jogamp.newt.opengl.broadcom.egl; -import com.sun.javafx.newt.impl.*; import javax.media.nativewindow.*; -public class Screen extends com.sun.javafx.newt.Screen { +public class Screen extends com.jogamp.newt.Screen { static { Display.initSingleton(); diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Window.java b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Window.java index 11672dde3..185dc97b9 100755 --- a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Window.java +++ b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Window.java @@ -31,16 +31,14 @@ * */ -package com.sun.javafx.newt.opengl.broadcom.egl; +package com.jogamp.newt.opengl.broadcom.egl; -import com.sun.javafx.newt.impl.*; -import com.sun.opengl.impl.egl.*; +import com.jogamp.opengl.impl.egl.*; import javax.media.nativewindow.*; import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLProfile; import javax.media.nativewindow.NativeWindowException; -public class Window extends com.sun.javafx.newt.Window { +public class Window extends com.jogamp.newt.Window { static { Display.initSingleton(); } diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDDisplay.java b/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java index 5aeae75ea..6a28f992b 100755 --- a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDDisplay.java +++ b/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java @@ -31,18 +31,18 @@ * */ -package com.sun.javafx.newt.opengl.kd; +package com.jogamp.newt.opengl.kd; -import com.sun.javafx.newt.*; -import com.sun.javafx.newt.impl.*; -import com.sun.opengl.impl.egl.*; +import com.jogamp.newt.*; +import com.jogamp.newt.impl.*; +import com.jogamp.opengl.impl.egl.*; import javax.media.nativewindow.*; import javax.media.nativewindow.egl.*; public class KDDisplay extends Display { static { - NativeLibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWT(); if (!KDWindow.initIDs()) { throw new NativeWindowException("Failed to initialize KDWindow jmethodIDs"); diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDScreen.java b/src/newt/classes/com/jogamp/newt/opengl/kd/KDScreen.java index 1767c1240..cd53c8152 100755 --- a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDScreen.java +++ b/src/newt/classes/com/jogamp/newt/opengl/kd/KDScreen.java @@ -31,9 +31,9 @@ * */ -package com.sun.javafx.newt.opengl.kd; +package com.jogamp.newt.opengl.kd; -import com.sun.javafx.newt.*; +import com.jogamp.newt.*; import javax.media.nativewindow.*; public class KDScreen extends Screen { diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java b/src/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java index 605e9c064..555f54599 100755 --- a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java @@ -31,11 +31,11 @@ * */ -package com.sun.javafx.newt.opengl.kd; +package com.jogamp.newt.opengl.kd; -import com.sun.javafx.newt.*; -import com.sun.javafx.newt.impl.*; -import com.sun.opengl.impl.egl.*; +import com.jogamp.newt.*; +import com.jogamp.newt.impl.*; +import com.jogamp.opengl.impl.egl.*; import javax.media.nativewindow.*; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; diff --git a/src/newt/classes/com/sun/javafx/newt/util/EventDispatchThread.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java index a98ebab93..f852bcf5c 100644 --- a/src/newt/classes/com/sun/javafx/newt/util/EventDispatchThread.java +++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java @@ -34,36 +34,36 @@ * facility. */ -package com.sun.javafx.newt.util; +package com.jogamp.newt.util; -import com.sun.javafx.newt.Display; -import com.sun.javafx.newt.impl.Debug; +import com.jogamp.newt.Display; +import com.jogamp.newt.impl.Debug; import java.util.*; -public class EventDispatchThread { +public class EDTUtil { public static final boolean DEBUG = Debug.debug("EDT"); private ThreadGroup threadGroup; private volatile boolean shouldStop = false; - private TaskWorker taskWorker = null; - private Object taskWorkerLock = new Object(); + private EventDispatchThread edt = null; + private Object edtLock = new Object(); private ArrayList tasks = new ArrayList(); // one shot tasks - private Display display = null; private String name; - private long edtPollGranularity = 10; + private Runnable pumpMessages; + private long edtPollGranularity = 10; // 10ms, 1/100s - public EventDispatchThread(Display display, ThreadGroup tg, String name) { - this.display = display; + public EDTUtil(ThreadGroup tg, String name, Runnable pumpMessages) { this.threadGroup = tg; - this.name=new String("EDT-Display_"+display.getName()+"-"+name); + this.name=new String("EDT-"+name); + this.pumpMessages=pumpMessages; } public String getName() { return name; } public ThreadGroup getThreadGroup() { return threadGroup; } - public void start() { - start(false); + public Thread start() { + return start(false); } /** @@ -75,52 +75,56 @@ public class EventDispatchThread { * Usefull in combination with externalStimuli=true, * so an external stimuli can call it. */ - public Runnable start(boolean externalStimuli) { - synchronized(taskWorkerLock) { - if(null==taskWorker) { - taskWorker = new TaskWorker(threadGroup, name); + public Thread start(boolean externalStimuli) { + synchronized(edtLock) { + if(null==edt) { + edt = new EventDispatchThread(threadGroup, name); } - if(!taskWorker.isRunning()) { + if(!edt.isRunning()) { shouldStop = false; - taskWorker.start(externalStimuli); + edt.start(externalStimuli); } - taskWorkerLock.notifyAll(); + edtLock.notifyAll(); } - return taskWorker; + return edt; } public void stop() { - synchronized(taskWorkerLock) { - if(null!=taskWorker && taskWorker.isRunning()) { + synchronized(edtLock) { + if(null!=edt && edt.isRunning()) { shouldStop = true; } - taskWorkerLock.notifyAll(); + edtLock.notifyAll(); if(DEBUG) { System.out.println(Thread.currentThread()+": EDT signal STOP"); } } } + public Thread getEDT() { + return edt; + } + public boolean isThreadEDT(Thread thread) { - return null!=taskWorker && taskWorker == thread; + return null!=edt && edt == thread; } public boolean isCurrentThreadEDT() { - return null!=taskWorker && taskWorker == Thread.currentThread(); + return null!=edt && edt == Thread.currentThread(); } public boolean isRunning() { - return null!=taskWorker && taskWorker.isRunning() ; + return null!=edt && edt.isRunning() ; } public void invokeLater(Runnable task) { if(task == null) { return; } - synchronized(taskWorkerLock) { - if(null!=taskWorker && taskWorker.isRunning() && taskWorker != Thread.currentThread() ) { + synchronized(edtLock) { + if(null!=edt && edt.isRunning() && edt != Thread.currentThread() ) { tasks.add(task); - taskWorkerLock.notifyAll(); + edtLock.notifyAll(); } else { // if !running or isEDTThread, do it right away task.run(); @@ -137,10 +141,10 @@ public class EventDispatchThread { } public void waitOnWorker() { - synchronized(taskWorkerLock) { - if(null!=taskWorker && taskWorker.isRunning() && tasks.size()>0 && taskWorker != Thread.currentThread() ) { + synchronized(edtLock) { + if(null!=edt && edt.isRunning() && tasks.size()>0 && edt != Thread.currentThread() ) { try { - taskWorkerLock.wait(); + edtLock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } @@ -149,10 +153,10 @@ public class EventDispatchThread { } public void waitUntilStopped() { - synchronized(taskWorkerLock) { - while(null!=taskWorker && taskWorker.isRunning() && taskWorker != Thread.currentThread() ) { + synchronized(edtLock) { + while(null!=edt && edt.isRunning() && edt != Thread.currentThread() ) { try { - taskWorkerLock.wait(); + edtLock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } @@ -160,11 +164,11 @@ public class EventDispatchThread { } } - class TaskWorker extends Thread { + class EventDispatchThread extends Thread { boolean isRunning = false; boolean externalStimuli = false; - public TaskWorker(ThreadGroup tg, String name) { + public EventDispatchThread(ThreadGroup tg, String name) { super(tg, name); } @@ -183,7 +187,7 @@ public class EventDispatchThread { } /** - * Utilizing taskWorkerLock only for local resources and task execution, + * Utilizing edtLock only for local resources and task execution, * not for event dispatching. */ public void run() { @@ -194,26 +198,26 @@ public class EventDispatchThread { try { // wait for something todo while(!shouldStop && tasks.size()==0) { - synchronized(taskWorkerLock) { + synchronized(edtLock) { if(!shouldStop && tasks.size()==0) { try { - taskWorkerLock.wait(edtPollGranularity); + edtLock.wait(edtPollGranularity); } catch (InterruptedException e) { e.printStackTrace(); } } } - display.pumpMessages(); // event dispatch + pumpMessages.run(); // event dispatch } if(!shouldStop && tasks.size()>0) { - synchronized(taskWorkerLock) { + synchronized(edtLock) { if(!shouldStop && tasks.size()>0) { Runnable task = (Runnable) tasks.remove(0); task.run(); - taskWorkerLock.notifyAll(); + edtLock.notifyAll(); } } - display.pumpMessages(); // event dispatch + pumpMessages.run(); // event dispatch } } catch (Throwable t) { // handle errors .. @@ -227,8 +231,8 @@ public class EventDispatchThread { isRunning = !shouldStop; } if(!isRunning) { - synchronized(taskWorkerLock) { - taskWorkerLock.notifyAll(); + synchronized(edtLock) { + edtLock.notifyAll(); } } if(DEBUG) { diff --git a/src/newt/classes/com/sun/javafx/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java index abfe3f0c7..daa09edce 100644 --- a/src/newt/classes/com/sun/javafx/newt/util/MainThread.java +++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java @@ -34,7 +34,7 @@ * facility. */ -package com.sun.javafx.newt.util; +package com.jogamp.newt.util; import java.util.*; import java.lang.reflect.Method; @@ -43,10 +43,10 @@ import java.security.*; import javax.media.nativewindow.*; -import com.sun.javafx.newt.*; -import com.sun.javafx.newt.impl.*; -import com.sun.javafx.newt.macosx.MacDisplay; -import com.sun.nativewindow.impl.NWReflection; +import com.jogamp.common.util.*; +import com.jogamp.newt.*; +import com.jogamp.newt.impl.*; +import com.jogamp.newt.macosx.MacDisplay; /** * NEWT Utility class MainThread<P> @@ -64,7 +64,7 @@ import com.sun.nativewindow.impl.NWReflection; * * To support your NEWT Window platform, * you have to pass your <i>main thread</i> actions to {@link #invoke invoke(..)}, - * have a look at the {@link com.sun.javafx.newt.macosx.MacWindow MacWindow} implementation.<br> + * have a look at the {@link com.jogamp.newt.macosx.MacWindow MacWindow} implementation.<br> * <i>TODO</i>: Some hardcoded dependencies exist in this implementation, * where you have to patch this code or factor it out. <P> * @@ -77,7 +77,7 @@ import com.sun.nativewindow.impl.NWReflection; * * Test case on Mac OS X (or any other platform): <PRE> - java -XstartOnFirstThread com.sun.javafx.newt.util.MainThread demos.es1.RedSquare -GL2 -GL2 -GL2 -GL2 + java -XstartOnFirstThread com.jogamp.newt.util.MainThread demos.es1.RedSquare -GL2 -GL2 -GL2 -GL2 </PRE> * Which starts 4 threads, each with a window and OpenGL rendering.<br> */ @@ -116,7 +116,7 @@ public class MainThread { // start user app .. try { - Class mainClass = NWReflection.getClass(mainClassName, true); + Class mainClass = ReflectionUtil.getClass(mainClassName, true); if(null==mainClass) { throw new RuntimeException(new ClassNotFoundException("MainThread couldn't find main class "+mainClassName)); } @@ -159,7 +159,7 @@ public class MainThread { System.arraycopy(args, 1, mainClassArgs, 0, args.length-1); } - NativeLibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWT(); shouldStop = false; tasks = new ArrayList(); diff --git a/src/newt/classes/com/sun/javafx/newt/windows/WindowsDisplay.java b/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java index 80485ed67..281022901 100755 --- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsDisplay.java +++ b/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java @@ -31,12 +31,12 @@ * */ -package com.sun.javafx.newt.windows; +package com.jogamp.newt.windows; import javax.media.nativewindow.*; import javax.media.nativewindow.windows.*; -import com.sun.javafx.newt.*; -import com.sun.javafx.newt.impl.*; +import com.jogamp.newt.*; +import com.jogamp.newt.impl.*; public class WindowsDisplay extends Display { @@ -45,7 +45,7 @@ public class WindowsDisplay extends Display { private static long hInstance; static { - NativeLibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWT(); if (!WindowsWindow.initIDs()) { throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs"); diff --git a/src/newt/classes/com/sun/javafx/newt/windows/WindowsScreen.java b/src/newt/classes/com/jogamp/newt/windows/WindowsScreen.java index 87ae1b49d..aea3cd439 100755 --- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsScreen.java +++ b/src/newt/classes/com/jogamp/newt/windows/WindowsScreen.java @@ -31,10 +31,9 @@ * */ -package com.sun.javafx.newt.windows; +package com.jogamp.newt.windows; -import com.sun.javafx.newt.*; -import com.sun.javafx.newt.impl.*; +import com.jogamp.newt.*; import javax.media.nativewindow.*; public class WindowsScreen extends Screen { diff --git a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/newt/classes/com/jogamp/newt/windows/WindowsWindow.java index 1b5bf80cf..4a468ae86 100755 --- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java +++ b/src/newt/classes/com/jogamp/newt/windows/WindowsWindow.java @@ -31,10 +31,10 @@ * */ -package com.sun.javafx.newt.windows; +package com.jogamp.newt.windows; import javax.media.nativewindow.*; -import com.sun.javafx.newt.*; +import com.jogamp.newt.*; public class WindowsWindow extends Window { diff --git a/src/newt/classes/com/sun/javafx/newt/x11/X11Display.java b/src/newt/classes/com/jogamp/newt/x11/X11Display.java index ae23c4423..c8faefbf1 100755 --- a/src/newt/classes/com/sun/javafx/newt/x11/X11Display.java +++ b/src/newt/classes/com/jogamp/newt/x11/X11Display.java @@ -31,17 +31,17 @@ * */ -package com.sun.javafx.newt.x11; +package com.jogamp.newt.x11; import javax.media.nativewindow.*; import javax.media.nativewindow.x11.*; -import com.sun.javafx.newt.*; -import com.sun.javafx.newt.impl.*; -import com.sun.nativewindow.impl.x11.X11Util; +import com.jogamp.newt.*; +import com.jogamp.newt.impl.*; +import com.jogamp.nativewindow.impl.x11.X11Util; public class X11Display extends Display { static { - NativeLibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWT(); if (!initIDs()) { throw new NativeWindowException("Failed to initialize X11Display jmethodIDs"); @@ -61,7 +61,7 @@ public class X11Display extends Display { } protected void createNative() { - long handle= X11Util.getThreadLocalDisplay(name); + long handle= X11Util.createThreadLocalDisplay(name); if (handle == 0 ) { throw new RuntimeException("Error creating display: "+name); } @@ -75,9 +75,7 @@ public class X11Display extends Display { } protected void closeNative() { - if(0==X11Util.closeThreadLocalDisplay(name)) { - throw new NativeWindowException(this+" was not mapped"); - } + X11Util.closeThreadLocalDisplay(name); } protected void dispatchMessages() { diff --git a/src/newt/classes/com/sun/javafx/newt/x11/X11Screen.java b/src/newt/classes/com/jogamp/newt/x11/X11Screen.java index cee576e2c..e053d99c0 100755 --- a/src/newt/classes/com/sun/javafx/newt/x11/X11Screen.java +++ b/src/newt/classes/com/jogamp/newt/x11/X11Screen.java @@ -31,11 +31,9 @@ * */ -package com.sun.javafx.newt.x11; +package com.jogamp.newt.x11; -import com.sun.javafx.newt.*; -import com.sun.javafx.newt.impl.*; -import javax.media.nativewindow.*; +import com.jogamp.newt.*; import javax.media.nativewindow.x11.*; public class X11Screen extends Screen { diff --git a/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java b/src/newt/classes/com/jogamp/newt/x11/X11Window.java index f46ae9564..cc3aa58a2 100755 --- a/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java +++ b/src/newt/classes/com/jogamp/newt/x11/X11Window.java @@ -31,10 +31,9 @@ * */ -package com.sun.javafx.newt.x11; +package com.jogamp.newt.x11; -import com.sun.javafx.newt.*; -import com.sun.javafx.newt.impl.*; +import com.jogamp.newt.*; import javax.media.nativewindow.*; import javax.media.nativewindow.x11.*; diff --git a/src/newt/native/BroadcomEGL.c b/src/newt/native/BroadcomEGL.c index 55688f9d1..9aac90abb 100755 --- a/src/newt/native/BroadcomEGL.c +++ b/src/newt/native/BroadcomEGL.c @@ -41,7 +41,7 @@ #include <stdio.h> #include <string.h> -#include "com_sun_javafx_newt_opengl_broadcom_egl_Window.h" +#include "com_jogamp_newt_opengl_broadcom_egl_Window.h" #include "EventListener.h" #include "MouseEvent.h" @@ -72,7 +72,7 @@ static jmethodID windowCreatedID = NULL; * Display */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Display_DispatchMessages +JNIEXPORT void JNICALL Java_com_jogamp_newt_opengl_broadcom_egl_Display_DispatchMessages (JNIEnv *env, jobject obj) { // FIXME: n/a @@ -80,7 +80,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Display_Disp (void) obj; } -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Display_CreateDisplay +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_opengl_broadcom_egl_Display_CreateDisplay (JNIEnv *env, jobject obj, jint width, jint height) { (void) env; @@ -94,7 +94,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Display_Cre return (jlong) (intptr_t) dpy; } -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Display_DestroyDisplay +JNIEXPORT void JNICALL Java_com_jogamp_newt_opengl_broadcom_egl_Display_DestroyDisplay (JNIEnv *env, jobject obj, jlong display) { EGLDisplay dpy = (EGLDisplay)(intptr_t)display; @@ -111,7 +111,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Display_Dest * Window */ -JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Window_initIDs +JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_opengl_broadcom_egl_Window_initIDs (JNIEnv *env, jclass clazz) { windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(III)V"); @@ -123,7 +123,7 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Window_i return JNI_TRUE; } -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Window_CreateWindow +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_opengl_broadcom_egl_Window_CreateWindow (JNIEnv *env, jobject obj, jlong display, jboolean chromaKey, jint width, jint height) { EGLDisplay dpy = (EGLDisplay)(intptr_t)display; @@ -167,7 +167,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Window_Crea return (jlong) (intptr_t) window; } -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Window_CloseWindow +JNIEXPORT void JNICALL Java_com_jogamp_newt_opengl_broadcom_egl_Window_CloseWindow (JNIEnv *env, jobject obj, jlong display, jlong window) { EGLDisplay dpy = (EGLDisplay) (intptr_t) display; @@ -180,7 +180,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Window_Close DBG_PRINT( "[CloseWindow] X\n"); } -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_egl_Window_SwapWindow +JNIEXPORT void JNICALL Java_com_jogamp_newt_opengl_broadcom_egl_Window_SwapWindow (JNIEnv *env, jobject obj, jlong display, jlong window) { EGLDisplay dpy = (EGLDisplay) (intptr_t) display; diff --git a/src/newt/native/IntelGDL.c b/src/newt/native/IntelGDL.c index 1bc43cd0e..7857b594f 100644 --- a/src/newt/native/IntelGDL.c +++ b/src/newt/native/IntelGDL.c @@ -37,9 +37,9 @@ #include <stdio.h> #include <string.h> -#include "com_sun_javafx_newt_intel_gdl_Display.h" -#include "com_sun_javafx_newt_intel_gdl_Screen.h" -#include "com_sun_javafx_newt_intel_gdl_Window.h" +#include "com_jogamp_newt_intel_gdl_Display.h" +#include "com_jogamp_newt_intel_gdl_Screen.h" +#include "com_jogamp_newt_intel_gdl_Window.h" #include "EventListener.h" #include "MouseEvent.h" @@ -123,7 +123,7 @@ static void JNI_ThrowNew(JNIEnv *env, const char *throwable, const char* message * Display */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Display_DispatchMessages +JNIEXPORT void JNICALL Java_com_jogamp_newt_intel_gdl_Display_DispatchMessages (JNIEnv *env, jobject obj, jlong displayHandle, jobject focusedWindow) { // FIXME: n/a @@ -138,7 +138,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Display_DispatchMessag } */ } -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_intel_gdl_Display_CreateDisplay +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_intel_gdl_Display_CreateDisplay (JNIEnv *env, jobject obj) { gdl_ret_t retval; @@ -171,7 +171,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_intel_gdl_Display_CreateDisplay return (jlong) (intptr_t) p_driver_info; } -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Display_DestroyDisplay +JNIEXPORT void JNICALL Java_com_jogamp_newt_intel_gdl_Display_DestroyDisplay (JNIEnv *env, jobject obj, jlong displayHandle) { gdl_driver_info_t * p_driver_info = (gdl_driver_info_t *) (intptr_t) displayHandle; @@ -190,7 +190,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Display_DestroyDisplay * Screen */ -JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_intel_gdl_Screen_initIDs +JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_intel_gdl_Screen_initIDs (JNIEnv *env, jclass clazz) { screenCreatedID = (*env)->GetMethodID(env, clazz, "screenCreated", "(II)V"); @@ -202,7 +202,7 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_intel_gdl_Screen_initIDs return JNI_TRUE; } -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Screen_GetScreenInfo +JNIEXPORT void JNICALL Java_com_jogamp_newt_intel_gdl_Screen_GetScreenInfo (JNIEnv *env, jobject obj, jlong displayHandle, jint idx) { gdl_driver_info_t * p_driver_info = (gdl_driver_info_t *) (intptr_t) displayHandle; @@ -234,7 +234,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Screen_GetScreenInfo * Window */ -JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_intel_gdl_Window_initIDs +JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_intel_gdl_Window_initIDs (JNIEnv *env, jclass clazz) { updateBoundsID = (*env)->GetMethodID(env, clazz, "updateBounds", "(IIII)V"); @@ -246,7 +246,7 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_intel_gdl_Window_initIDs return JNI_TRUE; } -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_intel_gdl_Window_CreateSurface +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_intel_gdl_Window_CreateSurface (JNIEnv *env, jobject obj, jlong displayHandle, jint scr_width, jint scr_height, jint x, jint y, jint width, jint height) { gdl_driver_info_t * p_driver_info = (gdl_driver_info_t *) (intptr_t) displayHandle; @@ -339,7 +339,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_intel_gdl_Window_CreateSurface return (jlong) (intptr_t) plane; } -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Window_CloseSurface +JNIEXPORT void JNICALL Java_com_jogamp_newt_intel_gdl_Window_CloseSurface (JNIEnv *env, jobject obj, jlong display, jlong surface) { gdl_plane_id_t plane = (gdl_plane_id_t) (intptr_t) surface ; @@ -348,7 +348,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Window_CloseSurface DBG_PRINT("[CloseSurface] plane %d\n", plane); } -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Window_SetBounds0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_intel_gdl_Window_SetBounds0 (JNIEnv *env, jobject obj, jlong surface, jint scr_width, jint scr_height, jint x, jint y, jint width, jint height) { gdl_plane_id_t plane = (gdl_plane_id_t) (intptr_t) surface ; diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c index 6c7aa7731..15bef7582 100755 --- a/src/newt/native/KDWindow.c +++ b/src/newt/native/KDWindow.c @@ -64,7 +64,7 @@ #include <KD/kd.h> #include <KD/NV_extwindowprops.h> -#include "com_sun_javafx_newt_opengl_kd_KDWindow.h" +#include "com_jogamp_newt_opengl_kd_KDWindow.h" #include "EventListener.h" #include "MouseEvent.h" @@ -103,7 +103,7 @@ static jmethodID sendKeyEventID = NULL; * Display */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_kd_KDDisplay_DispatchMessages +JNIEXPORT void JNICALL Java_com_jogamp_newt_opengl_kd_KDDisplay_DispatchMessages (JNIEnv *env, jobject obj) { const KDEvent * evt; @@ -200,7 +200,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_kd_KDDisplay_DispatchMess * Window */ -JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_initIDs +JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_opengl_kd_KDWindow_initIDs (JNIEnv *env, jclass clazz) { #ifdef VERBOSE_ON @@ -228,7 +228,7 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_initIDs return JNI_TRUE; } -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_CreateWindow +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_opengl_kd_KDWindow_CreateWindow (JNIEnv *env, jobject obj, jlong display, jintArray jAttrs) { jint * attrs = NULL; @@ -270,7 +270,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_CreateWindow return (jlong) (intptr_t) window; } -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_RealizeWindow +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_opengl_kd_KDWindow_RealizeWindow (JNIEnv *env, jobject obj, jlong window) { KDWindow *w = (KDWindow*) (intptr_t) window; @@ -285,7 +285,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_RealizeWindo return (jlong) (intptr_t) nativeWindow; } -JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_CloseWindow +JNIEXPORT jint JNICALL Java_com_jogamp_newt_opengl_kd_KDWindow_CloseWindow (JNIEnv *env, jobject obj, jlong window, jlong juserData) { KDWindow *w = (KDWindow*) (intptr_t) window; @@ -299,11 +299,11 @@ JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_CloseWindow } /* - * Class: com_sun_javafx_newt_opengl_kd_KDWindow + * Class: com_jogamp_newt_opengl_kd_KDWindow * Method: setVisible0 * Signature: (JJZ)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_setVisible0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_opengl_kd_KDWindow_setVisible0 (JNIEnv *env, jobject obj, jlong window, jboolean visible) { KDWindow *w = (KDWindow*) (intptr_t) window; @@ -312,7 +312,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_setVisible0 DBG_PRINT( "[setVisible] v=%d\n", visible); } -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_setFullScreen0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_opengl_kd_KDWindow_setFullScreen0 (JNIEnv *env, jobject obj, jlong window, jboolean fullscreen) { KDWindow *w = (KDWindow*) (intptr_t) window; @@ -323,7 +323,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_setFullScreen (void)res; } -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_kd_KDWindow_setSize0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_opengl_kd_KDWindow_setSize0 (JNIEnv *env, jobject obj, jlong window, jint width, jint height) { KDWindow *w = (KDWindow*) (intptr_t) window; diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 1749805c8..f0ebfc0a0 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -33,7 +33,7 @@ #import <inttypes.h> -#import "com_sun_javafx_newt_macosx_MacWindow.h" +#import "com_jogamp_newt_macosx_MacWindow.h" #import "NewtMacWindow.h" #import "EventListener.h" @@ -121,11 +121,11 @@ NS_ENDHANDLER } /* - * Class: com_sun_javafx_newt_macosx_MacDisplay + * Class: com_jogamp_newt_macosx_MacDisplay * Method: initIDs * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_macosx_MacDisplay_initNSApplication +JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_macosx_MacDisplay_initNSApplication (JNIEnv *env, jclass clazz) { static int initialized = 0; @@ -155,11 +155,11 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_macosx_MacDisplay_initNSAppl } /* - * Class: com_sun_javafx_newt_macosx_MacDisplay + * Class: com_jogamp_newt_macosx_MacDisplay * Method: dispatchMessages0 * Signature: ()V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_macosx_MacDisplay_dispatchMessages0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_macosx_MacDisplay_dispatchMessages0 (JNIEnv *env, jobject unused, jlong window, jint eventMask) { NSEvent* event = NULL; @@ -195,11 +195,11 @@ NS_ENDHANDLER } /* - * Class: com_sun_javafx_newt_macosx_MacScreen + * Class: com_jogamp_newt_macosx_MacScreen * Method: getWidthImpl * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_macosx_MacScreen_getWidthImpl +JNIEXPORT jint JNICALL Java_com_jogamp_newt_macosx_MacScreen_getWidthImpl (JNIEnv *env, jclass clazz, jint screen_idx) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -216,11 +216,11 @@ JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_macosx_MacScreen_getWidthImpl } /* - * Class: com_sun_javafx_newt_macosx_MacScreen + * Class: com_jogamp_newt_macosx_MacScreen * Method: getHeightImpl * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_macosx_MacScreen_getHeightImpl +JNIEXPORT jint JNICALL Java_com_jogamp_newt_macosx_MacScreen_getHeightImpl (JNIEnv *env, jclass clazz, jint screen_idx) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -237,11 +237,11 @@ JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_macosx_MacScreen_getHeightImpl } /* - * Class: com_sun_javafx_newt_macosx_MacWindow + * Class: com_jogamp_newt_macosx_MacWindow * Method: initIDs * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_initIDs +JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_macosx_MacWindow_initIDs (JNIEnv *env, jclass clazz) { static int initialized = 0; @@ -258,11 +258,11 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_initIDs } /* - * Class: com_sun_javafx_newt_macosx_MacWindow + * Class: com_jogamp_newt_macosx_MacWindow * Method: createWindow0 * Signature: (JIIIIZIIIJ)J */ -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_createWindow0 +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_macosx_MacWindow_createWindow0 (JNIEnv *env, jobject jthis, jlong parent, jint x, jint y, jint w, jint h, jboolean fullscreen, jint styleMask, jint bufferingType, jint screen_idx, jlong jview) { @@ -334,11 +334,11 @@ NS_ENDHANDLER } /* - * Class: com_sun_javafx_newt_macosx_MacWindow + * Class: com_jogamp_newt_macosx_MacWindow * Method: makeKeyAndOrderFront * Signature: (J)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_makeKeyAndOrderFront +JNIEXPORT void JNICALL Java_com_jogamp_newt_macosx_MacWindow_makeKeyAndOrderFront (JNIEnv *env, jobject unused, jlong window) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -348,11 +348,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_makeKeyAndOrder } /* - * Class: com_sun_javafx_newt_macosx_MacWindow + * Class: com_jogamp_newt_macosx_MacWindow * Method: makeKey * Signature: (J)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_makeKey +JNIEXPORT void JNICALL Java_com_jogamp_newt_macosx_MacWindow_makeKey (JNIEnv *env, jobject unused, jlong window) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -362,11 +362,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_makeKey } /* - * Class: com_sun_javafx_newt_macosx_MacWindow + * Class: com_jogamp_newt_macosx_MacWindow * Method: orderOut * Signature: (J)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_orderOut +JNIEXPORT void JNICALL Java_com_jogamp_newt_macosx_MacWindow_orderOut (JNIEnv *env, jobject unused, jlong window) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -376,11 +376,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_orderOut } /* - * Class: com_sun_javafx_newt_macosx_MacWindow + * Class: com_jogamp_newt_macosx_MacWindow * Method: close0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_close0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_macosx_MacWindow_close0 (JNIEnv *env, jobject unused, jlong window) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -401,11 +401,11 @@ NS_ENDHANDLER } /* - * Class: com_sun_javafx_newt_macosx_MacWindow + * Class: com_jogamp_newt_macosx_MacWindow * Method: setTitle0 * Signature: (JLjava/lang/String;)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_setTitle0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_macosx_MacWindow_setTitle0 (JNIEnv *env, jobject unused, jlong window, jstring title) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -417,11 +417,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_setTitle0 } /* - * Class: com_sun_javafx_newt_macosx_MacWindow + * Class: com_jogamp_newt_macosx_MacWindow * Method: contentView * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_contentView +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_macosx_MacWindow_contentView (JNIEnv *env, jobject unused, jlong window) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -432,11 +432,11 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_contentView } /* - * Class: com_sun_javafx_newt_macosx_MacWindow + * Class: com_jogamp_newt_macosx_MacWindow * Method: changeContentView * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_changeContentView +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_macosx_MacWindow_changeContentView (JNIEnv *env, jobject jthis, jlong parent, jlong window, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -452,11 +452,11 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_changeContentV } /* - * Class: com_sun_javafx_newt_macosx_MacWindow + * Class: com_jogamp_newt_macosx_MacWindow * Method: setContentSize * Signature: (JII)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_setContentSize +JNIEXPORT void JNICALL Java_com_jogamp_newt_macosx_MacWindow_setContentSize (JNIEnv *env, jobject unused, jlong window, jint w, jint h) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -467,11 +467,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_setContentSize } /* - * Class: com_sun_javafx_newt_macosx_MacWindow + * Class: com_jogamp_newt_macosx_MacWindow * Method: setFrameTopLeftPoint * Signature: (JII)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_setFrameTopLeftPoint +JNIEXPORT void JNICALL Java_com_jogamp_newt_macosx_MacWindow_setFrameTopLeftPoint (JNIEnv *env, jobject unused, jlong parent, jlong window, jint x, jint y) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index e19be2ed8..560cfe408 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -55,7 +55,7 @@ @end -@interface NewtMacWindow : NSWindow +@interface NewtMacWindow : NSWindow <NSWindowDelegate> { } diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 146c04de1..3d8d32a40 100755 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -441,7 +441,7 @@ static jint mods2JavaMods(NSUInteger mods) } (*env)->CallVoidMethod(env, javaWindowObject, windowDestroyNotifyID); - // Will be called by Window.java (*env)->CallVoidMethod(env, javaWindowObject, windowDestroyedID); + (*env)->CallVoidMethod(env, javaWindowObject, windowDestroyedID); // No OSX hook for DidClose, so do it here // EOL .. (*env)->DeleteGlobalRef(env, javaWindowObject); diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 5445ca372..67da99b1f 100755 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -89,7 +89,7 @@ #define MONITOR_DEFAULTTONEAREST 2 #endif -#include "com_sun_javafx_newt_windows_WindowsWindow.h" +#include "com_jogamp_newt_windows_WindowsWindow.h" #include "EventListener.h" #include "MouseEvent.h" @@ -902,11 +902,11 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, } /* - * Class: com_sun_javafx_newt_windows_WindowsDisplay + * Class: com_jogamp_newt_windows_WindowsDisplay * Method: DispatchMessages * Signature: ()V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsDisplay_DispatchMessages +JNIEXPORT void JNICALL Java_com_jogamp_newt_windows_WindowsDisplay_DispatchMessages (JNIEnv *env, jclass clazz) { int i = 0; @@ -925,11 +925,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsDisplay_DispatchM } /* - * Class: com_sun_javafx_newt_windows_WindowsDisplay + * Class: com_jogamp_newt_windows_WindowsDisplay * Method: LoadLibraryW * Signature: (Ljava/lang/String;)J */ -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsDisplay_LoadLibraryW +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_windows_WindowsDisplay_LoadLibraryW (JNIEnv *env, jclass clazz, jstring dllName) { jchar* _dllName = GetNullTerminatedStringChars(env, dllName); @@ -939,11 +939,11 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsDisplay_LoadLibr } /* - * Class: com_sun_javafx_newt_windows_WindowsDisplay + * Class: com_jogamp_newt_windows_WindowsDisplay * Method: RegisterWindowClass * Signature: (Ljava/lang/String;J)I */ -JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_windows_WindowsDisplay_RegisterWindowClass +JNIEXPORT jint JNICALL Java_com_jogamp_newt_windows_WindowsDisplay_RegisterWindowClass (JNIEnv *env, jclass clazz, jstring wndClassName, jlong hInstance) { ATOM res; @@ -979,44 +979,44 @@ JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_windows_WindowsDisplay_RegisterW } /* - * Class: com_sun_javafx_newt_windows_WindowsDisplay + * Class: com_jogamp_newt_windows_WindowsDisplay * Method: CleanupWindowResources * Signature: (java/lang/String;J)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsDisplay_UnregisterWindowClass +JNIEXPORT void JNICALL Java_com_jogamp_newt_windows_WindowsDisplay_UnregisterWindowClass (JNIEnv *env, jclass clazz, jint wndClassAtom, jlong hInstance) { UnregisterClass(MAKEINTATOM(wndClassAtom), (HINSTANCE) (intptr_t) hInstance); } /* - * Class: com_sun_javafx_newt_windows_WindowsScreen + * Class: com_jogamp_newt_windows_WindowsScreen * Method: getWidthImpl * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_windows_WindowsScreen_getWidthImpl +JNIEXPORT jint JNICALL Java_com_jogamp_newt_windows_WindowsScreen_getWidthImpl (JNIEnv *env, jobject obj, jint scrn_idx) { return (jint)GetSystemMetrics(SM_CXSCREEN); } /* - * Class: com_sun_javafx_newt_windows_WindowsScreen + * Class: com_jogamp_newt_windows_WindowsScreen * Method: getWidthImpl * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_windows_WindowsScreen_getHeightImpl +JNIEXPORT jint JNICALL Java_com_jogamp_newt_windows_WindowsScreen_getHeightImpl (JNIEnv *env, jobject obj, jint scrn_idx) { return (jint)GetSystemMetrics(SM_CYSCREEN); } /* - * Class: com_sun_javafx_newt_windows_WindowsWindow + * Class: com_jogamp_newt_windows_WindowsWindow * Method: initIDs * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_initIDs +JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_windows_WindowsWindow_initIDs (JNIEnv *env, jclass clazz) { sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)V"); @@ -1045,11 +1045,11 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_initID } /* - * Class: com_sun_javafx_newt_windows_WindowsWindow + * Class: com_jogamp_newt_windows_WindowsWindow * Method: CreateWindow * Signature: (JILjava/lang/String;JJZIIII)J */ -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_CreateWindow +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_windows_WindowsWindow_CreateWindow (JNIEnv *env, jobject obj, jlong parent, jint wndClassAtom, jstring jWndName, jlong hInstance, jlong visualID, jboolean bIsUndecorated, jint jx, jint jy, jint defaultWidth, jint defaultHeight) @@ -1113,44 +1113,44 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_CreateWin } /* - * Class: com_sun_javafx_newt_windows_WindowsWindow + * Class: com_jogamp_newt_windows_WindowsWindow * Method: DestroyWindow * Signature: (J)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_DestroyWindow +JNIEXPORT void JNICALL Java_com_jogamp_newt_windows_WindowsWindow_DestroyWindow (JNIEnv *env, jobject obj, jlong window) { DestroyWindow((HWND) (intptr_t) window); } /* - * Class: com_sun_javafx_newt_windows_WindowsWindow + * Class: com_jogamp_newt_windows_WindowsWindow * Method: GetDC * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_GetDC +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_windows_WindowsWindow_GetDC (JNIEnv *env, jobject obj, jlong window) { return (jlong) (intptr_t) GetDC((HWND) (intptr_t) window); } /* - * Class: com_sun_javafx_newt_windows_WindowsWindow + * Class: com_jogamp_newt_windows_WindowsWindow * Method: ReleaseDC * Signature: (JJ)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_ReleaseDC +JNIEXPORT void JNICALL Java_com_jogamp_newt_windows_WindowsWindow_ReleaseDC (JNIEnv *env, jobject obj, jlong window, jlong dc) { ReleaseDC((HWND) (intptr_t) window, (HDC) (intptr_t) dc); } /* - * Class: com_sun_javafx_newt_windows_WindowsWindow + * Class: com_jogamp_newt_windows_WindowsWindow * Method: MonitorFromWindow * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_MonitorFromWindow +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_windows_WindowsWindow_MonitorFromWindow (JNIEnv *env, jobject obj, jlong window) { #if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410 || WINVER >= 0x0500) && !defined(_WIN32_WCE) @@ -1161,11 +1161,11 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_MonitorFr } /* - * Class: com_sun_javafx_newt_windows_WindowsWindow + * Class: com_jogamp_newt_windows_WindowsWindow * Method: setVisible0 * Signature: (JZ)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setVisible0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_windows_WindowsWindow_setVisible0 (JNIEnv *_env, jclass clazz, jlong window, jboolean visible) { HWND hWnd = (HWND) (intptr_t) window; @@ -1178,11 +1178,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setVisible } /* - * Class: com_sun_javafx_newt_windows_WindowsWindow + * Class: com_jogamp_newt_windows_WindowsWindow * Method: setSize0 * Signature: (JII)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setSize0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_windows_WindowsWindow_setSize0 (JNIEnv *env, jobject obj, jlong parent, jlong window, jint x, jint y, jint width, jint height) { HWND hwndP = (HWND) (intptr_t) parent; @@ -1215,11 +1215,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setSize0 } /* - * Class: com_sun_javafx_newt_windows_WindowsWindow + * Class: com_jogamp_newt_windows_WindowsWindow * Method: setPosition * Signature: (JII)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setPosition +JNIEXPORT void JNICALL Java_com_jogamp_newt_windows_WindowsWindow_setPosition (JNIEnv *env, jobject obj, jlong parent, jlong window, jint x, jint y) { UINT flags = SWP_NOACTIVATE | SWP_NOSIZE; @@ -1236,11 +1236,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setPositio } /* - * Class: com_sun_javafx_newt_windows_WindowsWindow + * Class: com_jogamp_newt_windows_WindowsWindow * Method: setFullscreen * Signature: (JIIIIZZ)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setFullscreen0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_windows_WindowsWindow_setFullscreen0 (JNIEnv *env, jobject obj, jlong parent, jlong window, jint x, jint y, jint width, jint height, jboolean bIsUndecorated, jboolean on) { UINT flags; @@ -1272,11 +1272,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setFullscr } /* - * Class: com_sun_javafx_newt_windows_WindowsWindow + * Class: com_jogamp_newt_windows_WindowsWindow * Method: setTitle * Signature: (JLjava/lang/String;)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setTitle +JNIEXPORT void JNICALL Java_com_jogamp_newt_windows_WindowsWindow_setTitle (JNIEnv *env, jclass clazz, jlong window, jstring title) { HWND hwnd = (HWND) (intptr_t) window; @@ -1290,11 +1290,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setTitle } /* - * Class: com_sun_javafx_newt_windows_WindowsWindow + * Class: com_jogamp_newt_windows_WindowsWindow * Method: requestFocus * Signature: (J)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_requestFocus +JNIEXPORT void JNICALL Java_com_jogamp_newt_windows_WindowsWindow_requestFocus (JNIEnv *env, jclass clazz, jlong window) { HWND hwnd = (HWND) (intptr_t) window; diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index b6b2bbe26..27ca8e6a0 100755 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -46,7 +46,7 @@ #include <X11/Xutil.h> #include <X11/keysym.h> -#include "com_sun_javafx_newt_x11_X11Window.h" +#include "com_jogamp_newt_x11_X11Window.h" #include "EventListener.h" #include "MouseEvent.h" @@ -149,12 +149,25 @@ static jint X11KeySym2NewtVKey(KeySym keySym) { return keySym; } -static const char * const ClazzNameRuntimeException = - "java/lang/RuntimeException"; +static void _FatalError(JNIEnv *env, const char* msg, ...) +{ + char buffer[512]; + va_list ap; + + va_start(ap, msg); + vsnprintf(buffer, sizeof(buffer), msg, ap); + va_end(ap); + + fprintf(stderr, buffer); + fprintf(stderr, "\n"); + (*env)->FatalError(env, buffer); +} + +static const char * const ClazzNameRuntimeException = "java/lang/RuntimeException"; static jclass runtimeExceptionClz=NULL; static const char * const ClazzNameNewtWindow = - "com/sun/javafx/newt/Window"; + "com/jogamp/newt/Window"; static jclass newtWindowClz=NULL; static jmethodID windowChangedID = NULL; @@ -186,18 +199,51 @@ static void _throwNewRuntimeException(Display * unlockDisplay, JNIEnv *env, cons * Display */ + +static JNIEnv * x11ErrorHandlerJNIEnv = NULL; +static XErrorHandler origErrorHandler = NULL ; + +static int displayDispatchErrorHandler(Display *dpy, XErrorEvent *e) +{ + fprintf(stderr, "Warning: NEWT X11 Error: DisplayDispatch %p, Code 0x%X\n", dpy, e->error_code); + + if (e->error_code == BadAtom) + { + fprintf(stderr, " BadAtom (%p): Atom probably already removed\n", e->resourceid); + } else if (e->error_code == BadWindow) + { + fprintf(stderr, " BadWindow (%p): Window probably already removed\n", e->resourceid); + } else { + _throwNewRuntimeException(NULL, x11ErrorHandlerJNIEnv, "NEWT X11 Error: Display %p, Code 0x%X", dpy, e->error_code); + } + + return 0; +} + +static void displayDispatchErrorHandlerEnable(int onoff, JNIEnv * env) { + if(onoff) { + if(NULL==origErrorHandler) { + x11ErrorHandlerJNIEnv = env; + origErrorHandler = XSetErrorHandler(displayDispatchErrorHandler); + } + } else { + XSetErrorHandler(origErrorHandler); + origErrorHandler = NULL; + } +} + /* - * Class: com_sun_javafx_newt_x11_X11Display + * Class: com_jogamp_newt_x11_X11Display * Method: initIDs * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_x11_X11Display_initIDs +JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_x11_X11Display_initIDs (JNIEnv *env, jclass clazz) { jclass c; if( 0 == XInitThreads() ) { - fprintf(stderr, "Warning: XInitThreads() failed\n"); + fprintf(stderr, "Warning: NEWT X11Window: XInitThreads() failed\n"); } displayCompletedID = (*env)->GetMethodID(env, clazz, "displayCompleted", "(JJ)V"); @@ -208,28 +254,24 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_x11_X11Display_initIDs if(NULL==newtWindowClz) { c = (*env)->FindClass(env, ClazzNameNewtWindow); if(NULL==c) { - fprintf(stderr, "FatalError: NEWT X11Window: can't find %s\n", ClazzNameNewtWindow); - return JNI_FALSE; + _FatalError(env, "NEWT X11Window: can't find %s", ClazzNameNewtWindow); } newtWindowClz = (jclass)(*env)->NewGlobalRef(env, c); (*env)->DeleteLocalRef(env, c); if(NULL==newtWindowClz) { - fprintf(stderr, "FatalError: NEWT X11Window: can't use %s\n", ClazzNameNewtWindow); - return JNI_FALSE; + _FatalError(env, "NEWT X11Window: can't use %s", ClazzNameNewtWindow); } } if(NULL==runtimeExceptionClz) { c = (*env)->FindClass(env, ClazzNameRuntimeException); if(NULL==c) { - fprintf(stderr, "FatalError: NEWT X11Window: can't find %s\n", ClazzNameRuntimeException); - return JNI_FALSE; + _FatalError(env, "NEWT X11Window: can't find %s", ClazzNameRuntimeException); } runtimeExceptionClz = (jclass)(*env)->NewGlobalRef(env, c); (*env)->DeleteLocalRef(env, c); if(NULL==runtimeExceptionClz) { - fprintf(stderr, "FatalError: NEWT X11Window: can't use %s\n", ClazzNameRuntimeException); - return JNI_FALSE; + _FatalError(env, "NEWT X11Window: can't use %s", ClazzNameRuntimeException); } } @@ -237,43 +279,45 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_x11_X11Display_initIDs } /* - * Class: com_sun_javafx_newt_x11_X11Display + * Class: com_jogamp_newt_x11_X11Display * Method: LockDisplay * Signature: (J)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Display_LockDisplay +JNIEXPORT void JNICALL Java_com_jogamp_newt_x11_X11Display_LockDisplay (JNIEnv *env, jobject obj, jlong display) { Display * dpy = (Display *)(intptr_t)display; if(dpy==NULL) { - _throwNewRuntimeException(NULL, env, "given display connection is NULL\n"); + _FatalError(env, "invalid display connection.."); } XLockDisplay(dpy) ; + // DBG_PRINT1( "X11: LockDisplay 0x%X\n", dpy); } /* - * Class: com_sun_javafx_newt_x11_X11Display + * Class: com_jogamp_newt_x11_X11Display * Method: UnlockDisplay * Signature: (J)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Display_UnlockDisplay +JNIEXPORT void JNICALL Java_com_jogamp_newt_x11_X11Display_UnlockDisplay (JNIEnv *env, jobject obj, jlong display) { Display * dpy = (Display *)(intptr_t)display; if(dpy==NULL) { - _throwNewRuntimeException(NULL, env, "given display connection is NULL\n"); + _FatalError(env, "invalid display connection.."); } XUnlockDisplay(dpy) ; + // DBG_PRINT1( "X11: UnlockDisplay 0x%X\n", dpy); } /* - * Class: com_sun_javafx_newt_x11_X11Display + * Class: com_jogamp_newt_x11_X11Display * Method: CompleteDisplay * Signature: (J)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Display_CompleteDisplay +JNIEXPORT void JNICALL Java_com_jogamp_newt_x11_X11Display_CompleteDisplay (JNIEnv *env, jobject obj, jlong display) { Display * dpy = (Display *)(intptr_t)display; @@ -281,19 +325,19 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Display_CompleteDisplay jlong windowDeleteAtom; if(dpy==NULL) { - _throwNewRuntimeException(NULL, env, "given display connection is NULL\n"); + _FatalError(env, "invalid display connection.."); } XLockDisplay(dpy) ; javaObjectAtom = (jlong) XInternAtom(dpy, "JOGL_JAVA_OBJECT", False); if(None==javaObjectAtom) { - _throwNewRuntimeException(dpy, env, "could not create Atom JOGL_JAVA_OBJECT, bail out!\n"); + _throwNewRuntimeException(dpy, env, "could not create Atom JOGL_JAVA_OBJECT, bail out!"); return; } windowDeleteAtom = (jlong) XInternAtom(dpy, "WM_DELETE_WINDOW", False); if(None==windowDeleteAtom) { - _throwNewRuntimeException(dpy, env, "could not create Atom WM_DELETE_WINDOW, bail out!\n"); + _throwNewRuntimeException(dpy, env, "could not create Atom WM_DELETE_WINDOW, bail out!"); return; } @@ -323,14 +367,13 @@ static uintptr_t getPtrOut32Long(unsigned long * src) { } static void setJavaWindowProperty(JNIEnv *env, Display *dpy, Window window, jlong javaObjectAtom, jobject jwindow) { - unsigned long jogl_java_object_data[2]; + unsigned long jogl_java_object_data[2]; // X11 is based on 'unsigned long' int nitems_32 = putPtrIn32Long( jogl_java_object_data, (uintptr_t) jwindow); { jobject test = (jobject) getPtrOut32Long(jogl_java_object_data); if( ! (jwindow==test) ) { - _throwNewRuntimeException(dpy, env, "Internal Error .. Encoded Window ref not the same %p != %p !\n", jwindow, test); - return; + _FatalError(env, "Internal Error .. Encoded Window ref not the same %p != %p !", jwindow, test); } } @@ -356,14 +399,13 @@ static jobject getJavaWindowProperty(JNIEnv *env, Display *dpy, Window window, j &nitems_return, &bytes_after_return, &jogl_java_object_data_pp); if ( Success != res ) { - _throwNewRuntimeException(dpy, env, "could not fetch Atom JOGL_JAVA_OBJECT window property (res %d) nitems_return %ld, bytes_after_return %ld, bail out!\n", - res, nitems_return, bytes_after_return); + fprintf(stderr, "Warning: NEWT X11Window: Could not fetch Atom JOGL_JAVA_OBJECT window property (res %d) nitems_return %ld, bytes_after_return %ld, result 0!\n", res, nitems_return, bytes_after_return); return NULL; } if(actual_type_return!=(Atom)javaObjectAtom || nitems_return<nitems_32 || NULL==jogl_java_object_data_pp) { XFree(jogl_java_object_data_pp); - _throwNewRuntimeException(dpy, env, "could not fetch Atom JOGL_JAVA_OBJECT window property (res %d) nitems_return %ld, bytes_after_return %ld, actual_type_return %ld, JOGL_JAVA_OBJECT %ld, bail out!\n", + fprintf(stderr, "Warning: NEWT X11Window: Fetched invalid Atom JOGL_JAVA_OBJECT window property (res %d) nitems_return %ld, bytes_after_return %ld, actual_type_return %ld, JOGL_JAVA_OBJECT %ld, result 0!\n", res, nitems_return, bytes_after_return, (long)actual_type_return, javaObjectAtom); return NULL; } @@ -374,18 +416,18 @@ static jobject getJavaWindowProperty(JNIEnv *env, Display *dpy, Window window, j #ifdef VERBOSE_ON if(JNI_FALSE == (*env)->IsInstanceOf(env, jwindow, newtWindowClz)) { - _throwNewRuntimeException(NULL, env, "fetched Atom JOGL_JAVA_OBJECT window is not a NEWT Window: javaWindow 0x%X !\n", jwindow); + _throwNewRuntimeException(dpy, env, "fetched Atom JOGL_JAVA_OBJECT window is not a NEWT Window: javaWindow 0x%X !", jwindow); } #endif return jwindow; } /* - * Class: com_sun_javafx_newt_x11_X11Display + * Class: com_jogamp_newt_x11_X11Display * Method: DispatchMessages * Signature: (JIJJ)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Display_DispatchMessages +JNIEXPORT void JNICALL Java_com_jogamp_newt_x11_X11Display_DispatchMessages (JNIEnv *env, jobject obj, jlong display, jlong javaObjectAtom, jlong wmDeleteAtom) { Display * dpy = (Display *) (intptr_t) display; @@ -405,10 +447,12 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Display_DispatchMessages XLockDisplay(dpy) ; - // num_events = XPending(dpy); // XEventsQueued(dpy, QueuedAfterFlush); // I/O Flush .. - // num_events = XEventsQueued(dpy, QueuedAlready); // Better, no I/O .. - if ( 0 >= XEventsQueued(dpy, QueuedAlready) ) { + // num_events = XPending(dpy); // I/O Flush .. + // num_events = XEventsQueued(dpy, QueuedAfterFlush); // I/O Flush only of no already queued events are available + // num_events = XEventsQueued(dpy, QueuedAlready); // no I/O Flush at all, doesn't work on some cards (eg ATI) + if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { XUnlockDisplay(dpy) ; + // DBG_PRINT1( "X11: DispatchMessages 0x%X - Leave 1\n", dpy); return; } @@ -416,19 +460,26 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Display_DispatchMessages num_events--; if( 0==evt.xany.window ) { - _throwNewRuntimeException(dpy, env, "event window NULL, bail out!\n"); + _throwNewRuntimeException(dpy, env, "event window NULL, bail out!"); return ; } if(dpy!=evt.xany.display) { - _throwNewRuntimeException(dpy, env, "wrong display, bail out!\n"); + _throwNewRuntimeException(dpy, env, "wrong display, bail out!"); return ; } + + displayDispatchErrorHandlerEnable(1, env); + jwindow = getJavaWindowProperty(env, dpy, evt.xany.window, javaObjectAtom); + displayDispatchErrorHandlerEnable(0, env); + if(NULL==jwindow) { - // just leave .. _throwNewRuntimeException(env, "could not fetch Java Window object, bail out!\n"); + fprintf(stderr, "Warning: NEWT X11 DisplayDispatch %p, Couldn't handle event %d for invalid X11 window %p\n", + dpy, evt.type, evt.xany.window); XUnlockDisplay(dpy) ; + // DBG_PRINT1( "X11: DispatchMessages 0x%X - Leave 2\n", dpy); return; } @@ -446,6 +497,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Display_DispatchMessages } XUnlockDisplay(dpy) ; + // DBG_PRINT3( "X11: DispatchMessages 0x%X - Window %p, Event %d\n", dpy, jwindow, evt.type); switch(evt.type) { case ButtonPress: @@ -532,19 +584,18 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Display_DispatchMessages */ /* - * Class: com_sun_javafx_newt_x11_X11Screen + * Class: com_jogamp_newt_x11_X11Screen * Method: GetScreen * Signature: (JI)J */ -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Screen_GetScreen +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_x11_X11Screen_GetScreen (JNIEnv *env, jobject obj, jlong display, jint screen_index) { Display * dpy = (Display *)(intptr_t)display; Screen * scrn= NULL; if(dpy==NULL) { - _throwNewRuntimeException(NULL, env, "invalid display connection..\n"); - return 0; + _FatalError(env, "invalid display connection.."); } XLockDisplay(dpy); @@ -559,14 +610,14 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Screen_GetScreen return (jlong) (intptr_t) scrn; } -JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_x11_X11Screen_getWidth0 +JNIEXPORT jint JNICALL Java_com_jogamp_newt_x11_X11Screen_getWidth0 (JNIEnv *env, jobject obj, jlong display, jint scrn_idx) { Display * dpy = (Display *) (intptr_t) display; return (jint) XDisplayWidth( dpy, scrn_idx); } -JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_x11_X11Screen_getHeight0 +JNIEXPORT jint JNICALL Java_com_jogamp_newt_x11_X11Screen_getHeight0 (JNIEnv *env, jobject obj, jlong display, jint scrn_idx) { Display * dpy = (Display *) (intptr_t) display; @@ -579,11 +630,11 @@ JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_x11_X11Screen_getHeight0 */ /* - * Class: com_sun_javafx_newt_x11_X11Window + * Class: com_jogamp_newt_x11_X11Window * Method: initIDs * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_x11_X11Window_initIDs +JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_x11_X11Window_initIDs (JNIEnv *env, jclass clazz) { windowChangedID = (*env)->GetMethodID(env, clazz, "windowChanged", "(IIII)V"); @@ -605,11 +656,11 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_x11_X11Window_initIDs } /* - * Class: com_sun_javafx_newt_x11_X11Window + * Class: com_jogamp_newt_x11_X11Window * Method: CreateWindow * Signature: (JJIJIIII)J */ -JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow +JNIEXPORT jlong JNICALL Java_com_jogamp_newt_x11_X11Window_CreateWindow (JNIEnv *env, jobject obj, jlong parent, jlong display, jint screen_index, jlong visualID, jlong javaObjectAtom, jlong windowDeleteAtom, @@ -635,12 +686,11 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow DBG_PRINT4( "X11: CreateWindow %x/%d %dx%d\n", x, y, width, height); if(dpy==NULL) { - _throwNewRuntimeException(NULL, env, "invalid display connection..\n"); - return 0; + _FatalError(env, "invalid display connection.."); } if(visualID<0) { - _throwNewRuntimeException(NULL, env, "invalid VisualID ..\n"); + _throwNewRuntimeException(NULL, env, "invalid VisualID .."); return 0; } @@ -648,7 +698,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow XSync(dpy, False); - scrn = ScreenOfDisplay(dpy, screen_index); + scrn = ScreenOfDisplay(dpy, scrn_idx); // try given VisualID on screen memset(&visualTemplate, 0, sizeof(XVisualInfo)); @@ -667,7 +717,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow if (visual==NULL) { - _throwNewRuntimeException(dpy, env, "could not query Visual by given VisualID, bail out!\n"); + _throwNewRuntimeException(dpy, env, "could not query Visual by given VisualID, bail out!"); return 0; } @@ -734,11 +784,11 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow } /* - * Class: com_sun_javafx_newt_x11_X11Window + * Class: com_jogamp_newt_x11_X11Window * Method: CloseWindow * Signature: (JJ)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_CloseWindow +JNIEXPORT void JNICALL Java_com_jogamp_newt_x11_X11Window_CloseWindow (JNIEnv *env, jobject obj, jlong display, jlong window, jlong javaObjectAtom) { Display * dpy = (Display *) (intptr_t) display; @@ -746,18 +796,17 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_CloseWindow jobject jwindow; if(dpy==NULL) { - _throwNewRuntimeException(NULL, env, "invalid display connection..\n"); - return; + _FatalError(env, "invalid display connection.."); } XLockDisplay(dpy) ; jwindow = getJavaWindowProperty(env, dpy, w, javaObjectAtom); if(NULL==jwindow) { - _throwNewRuntimeException(dpy, env, "could not fetch Java Window object, bail out!\n"); + _throwNewRuntimeException(dpy, env, "could not fetch Java Window object, bail out!"); return; } if ( JNI_FALSE == (*env)->IsSameObject(env, jwindow, obj) ) { - _throwNewRuntimeException(dpy, env, "Internal Error .. Window global ref not the same!\n"); + _throwNewRuntimeException(dpy, env, "Internal Error .. Window global ref not the same!"); return; } (*env)->DeleteGlobalRef(env, jwindow); @@ -779,11 +828,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_CloseWindow } /* - * Class: com_sun_javafx_newt_x11_X11Window + * Class: com_jogamp_newt_x11_X11Window * Method: setVisible0 * Signature: (JJZ)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setVisible0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_x11_X11Window_setVisible0 (JNIEnv *env, jobject obj, jlong display, jlong window, jboolean visible) { Display * dpy = (Display *) (intptr_t) display; @@ -791,8 +840,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setVisible0 DBG_PRINT1( "X11: setVisible0 vis %d\n", visible); if(dpy==NULL) { - _throwNewRuntimeException(NULL, env, "invalid display connection..\n"); - return; + _FatalError(env, "invalid display connection.."); } XLockDisplay(dpy) ; @@ -823,11 +871,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setVisible0 #endif /* - * Class: com_sun_javafx_newt_x11_X11Window + * Class: com_jogamp_newt_x11_X11Window * Method: setSize0 * Signature: (JIJIIIIIZ)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setSize0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_x11_X11Window_setSize0 (JNIEnv *env, jobject obj, jlong jparent, jlong display, jint screen_index, jlong window, jint x, jint y, jint width, jint height, jint decorationToggle, jboolean setVisible) { Display * dpy = (Display *) (intptr_t) display; @@ -840,8 +888,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setSize0 DBG_PRINT6( "X11: setSize0 %d/%d %dx%d, dec %d, vis %d\n", x, y, width, height, decorationToggle, setVisible); if(dpy==NULL) { - _throwNewRuntimeException(NULL, env, "invalid display connection..\n"); - return; + _FatalError(env, "invalid display connection.."); } XLockDisplay(dpy) ; @@ -887,11 +934,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setSize0 } /* - * Class: com_sun_javafx_newt_x11_X11Window + * Class: com_jogamp_newt_x11_X11Window * Method: setPosition0 * Signature: (JJII)V */ -JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setPosition0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_x11_X11Window_setPosition0 (JNIEnv *env, jobject obj, jlong display, jlong window, jint x, jint y) { Display * dpy = (Display *) (intptr_t) display; @@ -900,8 +947,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setPosition0 DBG_PRINT2( "X11: setPos0 . XConfigureWindow %d/%d\n", x, y); if(dpy==NULL) { - _throwNewRuntimeException(NULL, env, "invalid display connection..\n"); - return; + _FatalError(env, "invalid display connection.."); } XLockDisplay(dpy) ; |