aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt')
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/Display.java24
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/NewtFactory.java108
-rw-r--r--src/newt/classes/com/jogamp/newt/OffscreenWindow.java7
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/Screen.java16
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/Window.java191
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java109
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java63
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java28
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/intel/gdl/Display.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java23
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java8
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/macosx/MacScreen.java6
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java137
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Display.java6
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java20
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/opengl/kd/KDDisplay.java7
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java22
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/windows/WindowsDisplay.java20
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java6
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java86
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/x11/X11Display.java31
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/x11/X11Screen.java4
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/x11/X11Window.java38
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java102
-rw-r--r--src/newt/classes/com/jogamp/newt/util/EDTUtil.java8
-rw-r--r--src/newt/native/MacWindow.m22
-rwxr-xr-xsrc/newt/native/WindowsWindow.c28
-rwxr-xr-xsrc/newt/native/X11Window.c20
31 files changed, 654 insertions, 500 deletions
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java
index abd03d13d..6705db970 100755
--- a/src/newt/classes/com/jogamp/newt/Display.java
+++ b/src/newt/classes/com/jogamp/newt/Display.java
@@ -125,8 +125,11 @@ public abstract class Display {
}
/** Make sure to reuse a Display with the same name */
- protected static Display create(String type, String name) {
+ protected static Display create(String type, String name, final long handle) {
try {
+ if(null==name && 0!=handle) {
+ name="wrapping-0x"+Long.toHexString(handle); // may change within implementation ..
+ }
if(DEBUG) {
dumpDisplayMap("Display.create("+getFQName(type, name)+") BEGIN");
}
@@ -152,11 +155,11 @@ public abstract class Display {
display.edt = display.edtUtil.start();
display.edtUtil.invokeAndWait(new Runnable() {
public void run() {
- f_dpy.createNative();
+ f_dpy.createNative(handle);
}
} );
} else {
- display.createNative();
+ display.createNative(handle);
}
if(null==display.aDevice) {
throw new RuntimeException("Display.createNative() failed to instanciate an AbstractGraphicsDevice");
@@ -182,19 +185,6 @@ public abstract class Display {
}
}
- protected static Display wrapHandle(String type, String name, AbstractGraphicsDevice aDevice) {
- try {
- Class displayClass = getDisplayClass(type);
- Display display = (Display) displayClass.newInstance();
- display.name=name;
- display.type=type;
- display.aDevice=aDevice;
- return display;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
public EDTUtil getEDTUtil() { return edtUtil; }
public synchronized void destroy() {
@@ -234,7 +224,7 @@ public abstract class Display {
}
}
- protected abstract void createNative();
+ protected abstract void createNative(long handle);
protected abstract void closeNative();
public final String getType() {
diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java
index 183acb3df..7860197ef 100755
--- a/src/newt/classes/com/jogamp/newt/NewtFactory.java
+++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java
@@ -78,14 +78,14 @@ public abstract class NewtFactory {
* Create a Display entity, incl native creation
*/
public static Display createDisplay(String name) {
- return Display.create(NativeWindowFactory.getNativeWindowType(true), name);
+ return Display.create(NativeWindowFactory.getNativeWindowType(true), name, 0);
}
/**
* Create a Display entity using the given implementation type, incl native creation
*/
public static Display createDisplay(String type, String name) {
- return Display.create(type, name);
+ return Display.create(type, name, 0);
}
/**
@@ -106,77 +106,99 @@ public abstract class NewtFactory {
* Create a top level Window entity, incl native creation
*/
public static Window createWindow(Screen screen, Capabilities caps) {
- return Window.create(NativeWindowFactory.getNativeWindowType(true), 0, screen, caps, false);
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), null, 0, screen, caps, false);
}
/**
* Create a top level Window entity, incl native creation
*/
public static Window createWindow(Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(NativeWindowFactory.getNativeWindowType(true), 0, screen, caps, undecorated);
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), null, 0, screen, caps, undecorated);
}
/**
- * Create a child Window entity attached to the given parent, incl native creation<br>
+ * Create a child Window entity attached to the given parent, incl native creation.<br>
+ * The Screen and Display information is regenrated utilizing the parents information.<br>
* <p>
* In case <code>parentWindowObject</code> is a {@link javax.media.nativewindow.NativeWindow},<br>
* we create a child {@link com.jogamp.newt.Window},
- * utilizing {@link com.jogamp.newt.NewtFactory#createWindow(long, com.jogamp.newt.Screen, javax.media.nativewindow.Capabilities, boolean)}
- * passing the parent's native window handle retrieved via {@link javax.media.nativewindow.NativeWindow#getWindowHandle()}.<br></p>
+ * utilizing {@link com.jogamp.newt.NewtFactory#createWindowImpl(java.lang.String, javax.media.nativewindow.NativeWindow, com.jogamp.newt.Screen, javax.media.nativewindow.Capabilities, boolean)}<br></p>.
* <p>
* In case <code>parentWindowObject</code> is even a {@link com.jogamp.newt.Window}, the following applies:<br>
* {@link com.jogamp.newt.event.WindowEvent#EVENT_WINDOW_RESIZED} is not propagated to the child window for e.g. layout<br>,
* you have to add an appropriate {@link com.jogamp.newt.event.WindowListener} for this use case.<br>
* However, {@link com.jogamp.newt.event.WindowEvent#EVENT_WINDOW_DESTROY_NOTIFY} is propagated to the child window, so it will be closed properly.<br>
- * In case <code>parentWindowObject</code> is a different {@javax.media.nativewindow.NativeWindow} implementation,<br>
+ * The parents visibility is passed to the new Window<br></p>
+ * <p>
+ * In case <code>parentWindowObject</code> is a different {@link javax.media.nativewindow.NativeWindow} implementation,<br>
* you have to handle all events appropriatly.<br></p>
* <p>
* In case <code>parentWindowObject</code> is a {@link java.awt.Component},<br>
- * we utilize the {@link com.jogamp.newt.impl.awt.AWTNewtFactory#createNativeChildWindow(Object, com.jogamp.newt.Screen, com.jogamp.newt.Capabilities, boolean)}
+ * we utilize the {@link com.jogamp.newt.impl.awt.AWTNewtFactory#createNativeChildWindow(Object, com.jogamp.newt.Capabilities, boolean)}
* factory method.<br>
* The factory adds a {@link com.jogamp.newt.event.WindowListener} to propagate {@link com.jogamp.newt.event.WindowEvent}'s so
- * your NEWT Window integrates into the AWT layout.<br></p>
+ * your NEWT Window integrates into the AWT layout.<br>
+ * The parents visibility is passed to the new Window<br></p>
*
* @param parentWindowObject either a NativeWindow or java.awt.Component
* @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always
*
* @see com.jogamp.newt.NewtFactory#createWindow(long, com.jogamp.newt.Screen, javax.media.nativewindow.Capabilities, boolean)
- * @see com.jogamp.newt.impl.awt.AWTNewtFactory#createNativeChildWindow(java.lang.Object, com.jogamp.newt.Screen, javax.media.nativewindow.Capabilities, boolean)
+ * @see com.jogamp.newt.impl.awt.AWTNewtFactory#createNativeChildWindow(java.lang.Object, javax.media.nativewindow.Capabilities, boolean)
*/
- public static Window createWindow(Object parentWindowObject, Screen screen, Capabilities caps, boolean undecorated) {
+ public static Window createWindow(Object parentWindowObject, Capabilities caps, boolean undecorated) {
+ final String type = NativeWindowFactory.getNativeWindowType(true);
if(null==parentWindowObject) {
- throw new RuntimeException("Null parentWindowObject");
+ return createWindowImpl(type, null, null, caps, undecorated);
}
if(parentWindowObject instanceof NativeWindow) {
- NativeWindow nativeParentWindow = (NativeWindow) parentWindowObject;
- nativeParentWindow.lockSurface();
- long parentWindowHandle = nativeParentWindow.getWindowHandle();
- nativeParentWindow.unlockSurface();
- final Window win = createWindow(parentWindowHandle, screen, caps, undecorated);
- if ( nativeParentWindow instanceof Window) {
- final Window f_nativeParentWindow = (Window) nativeParentWindow ;
- f_nativeParentWindow.addWindowListener(new WindowAdapter() {
+ NativeWindow nParentWindow = (NativeWindow) parentWindowObject;
+
+ Display display=null;
+ Screen screen=null;
+ Window parentWindow=null;
+
+ if ( nParentWindow instanceof Window ) {
+ parentWindow = (Window) nParentWindow ;
+ Screen nParentScreen = parentWindow.getScreen();
+ Display nParentDisplay = nParentScreen.getDisplay();
+ display = NewtFactory.wrapDisplay(type, nParentDisplay.getHandle());
+ screen = NewtFactory.createScreen(type, display, nParentScreen.getIndex());
+ } else {
+ AbstractGraphicsConfiguration nParentConfig = nParentWindow.getGraphicsConfiguration();
+ AbstractGraphicsScreen nParentScreen = nParentConfig.getScreen();
+ AbstractGraphicsDevice nParentDevice = nParentScreen.getDevice();
+ display = NewtFactory.wrapDisplay(type, nParentDevice.getHandle());
+ screen = NewtFactory.createScreen(type, display, nParentScreen.getIndex());
+ }
+ final Window win = createWindowImpl(type, nParentWindow, screen, caps, undecorated);
+
+ win.setSize(nParentWindow.getWidth(), nParentWindow.getHeight());
+ if ( null != parentWindow ) {
+ parentWindow.addWindowListener(new WindowAdapter() {
public void windowDestroyNotify(WindowEvent e) {
win.sendEvent(e);
}
});
+ win.setVisible(parentWindow.isVisible());
}
return win;
} else {
if(ReflectionUtil.instanceOf(parentWindowObject, "java.awt.Component")) {
if(ReflectionUtil.isClassAvailable("com.jogamp.newt.impl.awt.AWTNewtFactory")) {
- return (Window) ReflectionUtil.callStaticMethod("com.jogamp.newt.impl.awt.AWTNewtFactory",
- "createNativeChildWindow",
- new Class[] { Object.class, Screen.class, Capabilities.class, java.lang.Boolean.TYPE},
- new Object[] { parentWindowObject, screen, caps, new Boolean(undecorated) } );
+ return (Window) ReflectionUtil.callStaticMethod(
+ "com.jogamp.newt.impl.awt.AWTNewtFactory",
+ "createNativeChildWindow",
+ new Class[] { Object.class, Capabilities.class, java.lang.Boolean.TYPE},
+ new Object[] { parentWindowObject, caps, new Boolean(undecorated) } );
}
}
}
throw new RuntimeException("No NEWT child Window factory method for parent object: "+parentWindowObject);
}
- public static Window createWindow(Object parentWindowObject, Screen screen, Capabilities caps) {
- return createWindow(parentWindowObject, screen, caps, false);
+ protected static Window createWindowImpl(String type, NativeWindow parentNativeWindow, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(type, parentNativeWindow, 0, screen, caps, undecorated);
}
/**
@@ -186,14 +208,7 @@ public abstract class NewtFactory {
* @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always
*/
public static Window createWindow(long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) {
- if(0==parentWindowHandle) {
- throw new RuntimeException("Null parentWindowHandle");
- }
- return Window.create(NativeWindowFactory.getNativeWindowType(true), parentWindowHandle, screen, caps, undecorated);
- }
-
- public static Window createWindow(long parentWindowHandle, Screen screen, Capabilities caps) {
- return createWindow(parentWindowHandle, screen, caps, false);
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), null, parentWindowHandle, screen, caps, undecorated);
}
/**
@@ -213,7 +228,7 @@ public abstract class NewtFactory {
* @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always
*/
public static Window createWindow(String type, Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(type, 0, screen, caps, undecorated);
+ return Window.create(type, null, 0, screen, caps, undecorated);
}
public static Window createWindow(String type, Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
@@ -223,25 +238,8 @@ public abstract class NewtFactory {
/**
* Instantiate a Display entity using the native handle.
*/
- public static Display wrapDisplay(String name, AbstractGraphicsDevice device) {
- return Display.wrapHandle(NativeWindowFactory.getNativeWindowType(true), name, device);
- }
-
- /**
- * Instantiate a Screen entity using the native handle.
- */
- public static Screen wrapScreen(Display display, AbstractGraphicsScreen screen) {
- return Screen.wrapHandle(NativeWindowFactory.getNativeWindowType(true), display, screen);
- }
-
- /**
- * Instantiate a Window entity using the native handle.
- */
- public static Window wrapWindow(Screen screen, AbstractGraphicsConfiguration config,
- long windowHandle, boolean fullscreen, boolean visible,
- int x, int y, int width, int height) {
- return Window.wrapHandle(NativeWindowFactory.getNativeWindowType(true), screen, config,
- windowHandle, fullscreen, visible, x, y, width, height);
+ public static Display wrapDisplay(String type, long handle) {
+ return Display.create(type, null, handle);
}
private static final boolean instanceOf(Object obj, String clazzName) {
diff --git a/src/newt/classes/com/jogamp/newt/OffscreenWindow.java b/src/newt/classes/com/jogamp/newt/OffscreenWindow.java
index c9c56fc61..5b957afa5 100644
--- a/src/newt/classes/com/jogamp/newt/OffscreenWindow.java
+++ b/src/newt/classes/com/jogamp/newt/OffscreenWindow.java
@@ -44,7 +44,7 @@ public class OffscreenWindow extends Window implements SurfaceChangeable {
static long nextWindowHandle = 0x100; // start here - a marker
- protected void createNative(long parentWindowHandle, Capabilities caps) {
+ protected void createNativeImpl() {
if(0!=parentWindowHandle) {
throw new NativeWindowException("OffscreenWindow does not support window parenting");
}
@@ -83,10 +83,7 @@ public class OffscreenWindow extends Window implements SurfaceChangeable {
return surfaceHandle;
}
- public void setVisible(boolean visible) {
- if(!visible) {
- this.visible = visible;
- }
+ protected void setVisibleImpl() {
}
public void setSize(int width, int height) {
diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java
index 7bf520332..26342519e 100755
--- a/src/newt/classes/com/jogamp/newt/Screen.java
+++ b/src/newt/classes/com/jogamp/newt/Screen.java
@@ -67,7 +67,9 @@ public abstract class Screen {
if(usrWidth<0 || usrHeight<0) {
usrWidth = Debug.getIntProperty("newt.ws.swidth", true, localACC);
usrHeight = Debug.getIntProperty("newt.ws.sheight", true, localACC);
- System.out.println("User screen size "+usrWidth+"x"+usrHeight);
+ if(usrWidth>0 || usrHeight>0) {
+ System.out.println("User screen size "+usrWidth+"x"+usrHeight);
+ }
}
Class screenClass = getScreenClass(type);
Screen screen = (Screen) screenClass.newInstance();
@@ -88,18 +90,6 @@ public abstract class Screen {
aScreen = null;
}
- protected static Screen wrapHandle(String type, Display display, AbstractGraphicsScreen aScreen) {
- try {
- Class screenClass = getScreenClass(type);
- Screen screen = (Screen) screenClass.newInstance();
- screen.display = display;
- screen.aScreen = aScreen;
- return screen;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
protected abstract void createNative(int index);
protected abstract void closeNative();
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index 869ca2cf3..978b7f068 100755
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -88,8 +88,12 @@ public abstract class Window implements NativeWindow
return windowClass;
}
- protected static Window create(String type, final long parentWindowHandle, Screen screen, final Capabilities caps, boolean undecorated) {
+ protected static Window create(String type, NativeWindow parentNativeWindow, long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) {
try {
+ if(null==screen) {
+ Display display = NewtFactory.createDisplay(type, null); // local display
+ screen = NewtFactory.createScreen(type, display, 0); // screen 0
+ }
Class windowClass;
if(caps.isOnscreen()) {
windowClass = getWindowClass(type);
@@ -98,22 +102,11 @@ public abstract class Window implements NativeWindow
}
Window window = (Window) windowClass.newInstance();
window.invalidate();
- window.screen = screen;
+ window.parentNativeWindow = parentNativeWindow;
+ window.parentWindowHandle = parentWindowHandle;
+ window.screen = screen;
+ window.caps = (Capabilities)caps.clone();
window.setUndecorated(undecorated||0!=parentWindowHandle);
- EDTUtil edtUtil = screen.getDisplay().getEDTUtil();
- if(null!=edtUtil) {
- final Window f_win = window;
- edtUtil.invokeAndWait(new Runnable() {
- public void run() {
- f_win.createNative(parentWindowHandle, caps);
- }
- } );
- } else {
- window.createNative(parentWindowHandle, caps);
- }
- if(DEBUG_WINDOW_EVENT) {
- System.out.println("Window.create-1() done ("+Thread.currentThread()+", "+window+")");
- }
return window;
} catch (Throwable t) {
t.printStackTrace();
@@ -121,7 +114,7 @@ public abstract class Window implements NativeWindow
}
}
- protected static Window create(String type, Object[] cstrArguments, Screen screen, final Capabilities caps, boolean undecorated) {
+ protected static Window create(String type, Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
try {
Class windowClass = getWindowClass(type);
Class[] cstrArgumentTypes = getCustomConstructorArgumentTypes(windowClass);
@@ -134,52 +127,15 @@ public abstract class Window implements NativeWindow
}
Window window = (Window) ReflectionUtil.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ;
window.invalidate();
- window.screen = screen;
+ window.screen = screen;
+ window.caps = (Capabilities)caps.clone();
window.setUndecorated(undecorated);
- EDTUtil edtUtil = screen.getDisplay().getEDTUtil();
- if(null!=edtUtil) {
- final Window f_win = window;
- edtUtil.invokeAndWait(new Runnable() {
- public void run() {
- f_win.createNative(0, caps);
- }
- } );
- } else {
- window.createNative(0, caps);
- }
- if(DEBUG_WINDOW_EVENT) {
- System.out.println("Window.create-2() done ("+Thread.currentThread()+", "+window+")");
- }
return window;
} catch (Throwable t) {
throw new NativeWindowException(t);
}
}
- protected static Window wrapHandle(String type, Screen screen, AbstractGraphicsConfiguration config,
- long windowHandle, boolean fullscreen, boolean visible,
- int x, int y, int width, int height)
- {
- try {
- Class windowClass = getWindowClass(type);
- Window window = (Window) windowClass.newInstance();
- window.invalidate();
- window.screen = screen;
- window.config = config;
- window.windowHandle = windowHandle;
- window.fullscreen=fullscreen;
- window.visible=visible;
- window.x=x;
- window.y=y;
- window.width=width;
- window.height=height;
- return window;
- } catch (Throwable t) {
- t.printStackTrace();
- throw new NativeWindowException(t);
- }
- }
-
public static String toHexString(int hex) {
return "0x" + Integer.toHexString(hex);
}
@@ -190,6 +146,10 @@ public abstract class Window implements NativeWindow
protected Screen screen;
+ private NativeWindow parentNativeWindow;
+ protected long parentWindowHandle;
+
+ protected Capabilities caps;
protected AbstractGraphicsConfiguration config;
protected long windowHandle;
protected boolean fullscreen, visible;
@@ -199,16 +159,53 @@ public abstract class Window implements NativeWindow
protected String title = "Newt Window";
protected boolean undecorated = false;
+ private synchronized boolean createNative() {
+ if( null==screen || 0!=windowHandle || !visible ) {
+ // NOP .. or already done
+ return 0 != windowHandle ;
+ }
+ EDTUtil edtUtil = screen.getDisplay().getEDTUtil();
+ if( null != edtUtil && !edtUtil.isCurrentThreadEDT() ) {
+ throw new NativeWindowException("EDT enabled but not on EDT");
+ }
+
+ if(DEBUG_WINDOW_EVENT) {
+ System.out.println("Window.createNative() START ("+Thread.currentThread()+", "+this+")");
+ }
+ if(validateParentWindowHandle()) {
+ createNativeImpl();
+ setVisibleImpl();
+ }
+ if(DEBUG_WINDOW_EVENT) {
+ System.out.println("Window.createNative() END ("+Thread.currentThread()+", "+this+")");
+ }
+ return 0 != windowHandle ;
+ }
+
+ private boolean validateParentWindowHandle() {
+ boolean ok = true;
+ if(null!=parentNativeWindow) {
+ try {
+ parentNativeWindow.lockSurface();
+ } catch (NativeWindowException nwe) {
+ // parent native window not ready .. just skip action for now
+ ok = false;
+ }
+ if(ok) {
+ parentWindowHandle = parentNativeWindow.getWindowHandle();
+ parentNativeWindow.unlockSurface();
+ if(0==parentWindowHandle) {
+ throw new NativeWindowException("Parent native window handle is NULL, after succesful locking: "+parentNativeWindow);
+ }
+ }
+ }
+ return ok;
+ }
+
/**
* Create native windowHandle, ie creates a new native invisible window.
- *
- * The parentWindowHandle may be null, in which case no window parenting
- * is requested.
- *
- * Shall use the capabilities to determine the graphics configuration
- * and shall set the chosen capabilities.
*/
- protected abstract void createNative(long parentWindowHandle, Capabilities caps);
+ protected abstract void createNativeImpl();
protected abstract void closeNative();
@@ -371,18 +368,25 @@ public abstract class Window implements NativeWindow
e.printStackTrace();
}
screen = null;
+ parentNativeWindow = null;
+ parentWindowHandle = 0;
+ caps = null;
windowHandle = 0;
fullscreen=false;
visible=false;
eventMask = 0;
// Default position and dimension will be re-set immediately by user
- width = 100;
- height = 100;
+ width = 128;
+ height = 128;
x=0;
y=0;
}
+ public boolean isDestroyed() {
+ return null == screen ;
+ }
+
public boolean surfaceSwap() {
return false;
}
@@ -506,7 +510,62 @@ public abstract class Window implements NativeWindow
}
}
- public abstract void setVisible(boolean visible);
+ /**
+ * <p>
+ * <code>setVisible</code> makes the window visible if <code>visible</code> is true,
+ * otherwise the window becomes invisible.<br></p>
+ * <p>
+ * The <code>setVisible(true)</code> is responsible to actual create the native window.<br></p>
+ * <p>
+ * In case this window is a child window and a parent {@link javax.media.nativewindow.NativeWindow} is being used,<br>
+ * the parent's {@link javax.media.nativewindow.NativeWindow} handle is retrieved via {@link javax.media.nativewindow.NativeWindow#getWindowHandle()}.<br>
+ * If this action fails, ie if the parent {@link javax.media.nativewindow.NativeWindow} is not valid yet,<br>
+ * no native window is created yet and <code>setVisible(true)</code> shall be repeated when it is.<br></p>
+ */
+ public void setVisible(final boolean visible) {
+ setVisible(visible, false);
+ }
+
+ public void setVisible(final boolean visible, boolean deferred) {
+ if(!isDestroyed()) {
+ EDTUtil edtUtil = screen.getDisplay().getEDTUtil();
+ if(null!=edtUtil) {
+ edtUtil.invoke(deferred, new Runnable() {
+ public void run() {
+ setVisibleTask(visible);
+ }
+ });
+ } else {
+ setVisibleTask(visible);
+ }
+ }
+ }
+
+ private synchronized void setVisibleTask(final boolean visible) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("setVisibleTask: START ("+Thread.currentThread()+") "+this.x+"/"+this.y+" "+this.width+"x"+this.height+", fs "+fullscreen+", windowHandle "+windowHandle+", visible: "+this.visible+" -> "+visible);
+ }
+ int didit = 0;
+ if(0==windowHandle && visible) {
+ this.visible = visible;
+ didit = 01;
+ if( createNative() ) {
+ didit = 11;
+ }
+ } else if(this.visible != visible) {
+ this.visible = visible;
+ didit = 2;
+ if(0 != windowHandle) {
+ setVisibleImpl();
+ didit = 22;
+ }
+ }
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("setVisibleTask: END ("+Thread.currentThread()+") didit "+didit+", "+this.x+"/"+this.y+" "+this.width+"x"+this.height+", fs "+fullscreen+", windowHandle "+windowHandle+", visible: "+visible);
+ }
+ }
+
+ protected abstract void setVisibleImpl();
/**
* Sets the size of the client area of the window, excluding decorations
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java
index 9fd3d604b..3abe6531a 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java
@@ -136,6 +136,7 @@ public abstract class AWTAdapter implements java.util.EventListener
/**
* Create a pipeline adapter, AWT EventListener.<br>
* Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream window.<br>
+ * This is only supported with EDT enabled!
*/
public AWTAdapter(com.jogamp.newt.Window downstream) {
if(null==downstream) {
@@ -143,6 +144,9 @@ public abstract class AWTAdapter implements java.util.EventListener
}
this.newtListener = null;
this.newtWindow = downstream;
+ if( null == newtWindow.getScreen().getDisplay().getEDTUtil() ) {
+ throw new RuntimeException("EDT not enabled");
+ }
}
/**
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java
index 49d9bf0f2..01f0457e3 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java
@@ -52,11 +52,11 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter
}
public void windowActivated(java.awt.event.WindowEvent e) {
- // no propagation to NEWT child window ?? FIXME: Maybe yes in case of a 100% Opaque one ?
+ // no propagation to NEWT child window
}
public void windowDeactivated(java.awt.event.WindowEvent e) {
- // no propagation to NEWT child window ?? FIXME: Maybe yes in case of a 100% Opaque one ?
+ // no propagation to NEWT child window
}
}
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
index 2a5312d0b..fd6ceddae 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
@@ -31,8 +31,13 @@
*/
package com.jogamp.newt.event.awt;
-public class AWTWindowAdapter extends AWTAdapter implements java.awt.event.ComponentListener, java.awt.event.WindowListener
+public class AWTWindowAdapter
+ extends AWTAdapter
+ implements java.awt.event.ComponentListener, java.awt.event.WindowListener, java.awt.event.HierarchyListener
{
+ java.awt.Component awtComponent;
+ WindowClosingListener windowClosingListener;
+
public AWTWindowAdapter(com.jogamp.newt.event.WindowListener newtListener) {
super(newtListener);
}
@@ -46,13 +51,35 @@ public class AWTWindowAdapter extends AWTAdapter implements java.awt.event.Compo
}
public AWTAdapter addTo(java.awt.Component awtComponent) {
+ this.awtComponent = awtComponent;
awtComponent.addComponentListener(this);
+ awtComponent.addHierarchyListener(this);
+ addWindowClosingListenerTo(getWindow(awtComponent));
if(awtComponent instanceof java.awt.Window) {
((java.awt.Window)awtComponent).addWindowListener(this);
}
return this;
}
+ static java.awt.Window getWindow(java.awt.Component comp) {
+ while( null != comp && !(comp instanceof java.awt.Window) ) {
+ comp = comp.getParent();
+ }
+ if(comp instanceof java.awt.Window) {
+ return (java.awt.Window) comp;
+ }
+ return null;
+ }
+
+ void addWindowClosingListenerTo(java.awt.Window win) {
+ if( null == windowClosingListener ) {
+ windowClosingListener = new WindowClosingListener();
+ }
+ if( null != win ) {
+ win.addWindowListener(windowClosingListener);
+ }
+ }
+
public void componentResized(java.awt.event.ComponentEvent e) {
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
if(null!=newtListener) {
@@ -72,11 +99,19 @@ public class AWTWindowAdapter extends AWTAdapter implements java.awt.event.Compo
}
public void componentShown(java.awt.event.ComponentEvent e) {
- // n/a
+ if(null==newtListener) {
+ if(!newtWindow.isDestroyed()) {
+ newtWindow.setVisible(true, true /* deferred */);
+ }
+ }
}
public void componentHidden(java.awt.event.ComponentEvent e) {
- // n/a
+ if(null==newtListener) {
+ if(!newtWindow.isDestroyed()) {
+ newtWindow.setVisible(false, true /* deferred */);
+ }
+ }
}
public void windowActivated(java.awt.event.WindowEvent e) {
@@ -88,18 +123,9 @@ public class AWTWindowAdapter extends AWTAdapter implements java.awt.event.Compo
}
}
- public void windowClosed(java.awt.event.WindowEvent e) {
- // n/a
- }
+ public void windowClosed(java.awt.event.WindowEvent e) { }
- public void windowClosing(java.awt.event.WindowEvent e) {
- com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
- if(null!=newtListener) {
- ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyNotify(event);
- } else {
- enqueueEvent(event);
- }
- }
+ public void windowClosing(java.awt.event.WindowEvent e) { }
public void windowDeactivated(java.awt.event.WindowEvent e) {
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
@@ -110,17 +136,56 @@ public class AWTWindowAdapter extends AWTAdapter implements java.awt.event.Compo
}
}
- public void windowDeiconified(java.awt.event.WindowEvent e) {
- // n/a
+ public void windowDeiconified(java.awt.event.WindowEvent e) { }
+
+ public void windowIconified(java.awt.event.WindowEvent e) { }
+
+ public void windowOpened(java.awt.event.WindowEvent e) { }
+
+ public void hierarchyChanged(java.awt.event.HierarchyEvent e) {
+ if( null == newtListener ) {
+ long bits = e.getChangeFlags();
+ java.awt.Component changed = e.getChanged();
+ if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) {
+ final boolean visible = changed.isVisible();
+ if(!newtWindow.isDestroyed()) {
+ newtWindow.setVisible(visible, true /* deferred */);
+ }
+ } else if( 0 != ( java.awt.event.HierarchyEvent.PARENT_CHANGED & bits ) ) {
+ if(awtComponent == changed) {
+ java.awt.Window win = getWindow(changed);
+ if(null != win) {
+ addWindowClosingListenerTo(win);
+ } else {
+ java.awt.Component parent = e.getChangedParent();
+ if(parent instanceof java.awt.Window) {
+ ((java.awt.Window)parent).removeWindowListener(this);
+ if( null != windowClosingListener ) {
+ ((java.awt.Window)parent).removeWindowListener(windowClosingListener);
+ }
+ }
+ }
+ }
+ }
+ }
}
- public void windowIconified(java.awt.event.WindowEvent e) {
- // n/a
- }
+ class WindowClosingListener implements java.awt.event.WindowListener {
+ public void windowClosing(java.awt.event.WindowEvent e) {
+ com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(null!=newtListener) {
+ ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyNotify(event);
+ } else {
+ enqueueEvent(event);
+ }
+ }
- public void windowOpened(java.awt.event.WindowEvent e) {
- // n/a
+ public void windowActivated(java.awt.event.WindowEvent e) { }
+ public void windowClosed(java.awt.event.WindowEvent e) { }
+ public void windowDeactivated(java.awt.event.WindowEvent e) { }
+ public void windowDeiconified(java.awt.event.WindowEvent e) { }
+ public void windowIconified(java.awt.event.WindowEvent e) { }
+ public void windowOpened(java.awt.event.WindowEvent e) { }
}
-
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java
index f54e66f07..b0b518c59 100644
--- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java
@@ -44,7 +44,7 @@ public class AWTDisplay extends Display {
public AWTDisplay() {
}
- protected void createNative() {
+ protected void createNative(long handle) {
aDevice = (AWTGraphicsDevice) AWTGraphicsDevice.createDevice(null); // default
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java
index b42730a81..e0f86b1a9 100644
--- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java
+++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java
@@ -42,11 +42,13 @@ import javax.media.nativewindow.*;
import javax.media.nativewindow.awt.*;
import com.jogamp.newt.event.awt.AWTParentWindowAdapter;
+import com.jogamp.newt.Display;
import com.jogamp.newt.Screen;
import com.jogamp.newt.Window;
import com.jogamp.newt.NewtFactory;
+import com.jogamp.common.util.ReflectionUtil;
-public class AWTNewtFactory {
+public class AWTNewtFactory extends NewtFactory {
/**
* Wraps an AWT component into a {@link javax.media.nativewindow.NativeWindow} utilizing the {@link javax.media.nativewindow.NativeWindowFactory},<br>
@@ -60,19 +62,20 @@ public class AWTNewtFactory {
*
* @param awtCompObject must be of type java.awt.Component
*/
- public static NativeWindow getNativeWindow(Object awtCompObject) {
+ public static NativeWindow getNativeWindow(Object awtCompObject, Capabilities capsRequested) {
if(null==awtCompObject) {
throw new NativeWindowException("Null AWT Component");
}
if( ! (awtCompObject instanceof java.awt.Component) ) {
throw new NativeWindowException("AWT Component not a java.awt.Component");
}
- java.awt.Component awtComp = (java.awt.Component) awtCompObject;
- DefaultGraphicsDevice dummyDevice = new DefaultGraphicsDevice("AWTNewtBridge");
- DefaultGraphicsScreen dummyScreen = new DefaultGraphicsScreen(dummyDevice, 0);
- Capabilities dummyCaps = new Capabilities();
- DefaultGraphicsConfiguration dummyConfig = new DefaultGraphicsConfiguration(dummyScreen, dummyCaps, dummyCaps);
- NativeWindow awtNative = NativeWindowFactory.getNativeWindow(awtComp, dummyConfig);
+ return getNativeWindow( (java.awt.Component) awtCompObject, capsRequested );
+ }
+
+ public static NativeWindow getNativeWindow(java.awt.Component awtComp, Capabilities capsRequested) {
+ DefaultGraphicsConfiguration config =
+ AWTGraphicsConfiguration.create(awtComp, (Capabilities) capsRequested.clone(), capsRequested);
+ NativeWindow awtNative = NativeWindowFactory.getNativeWindow(awtComp, config); // a JAWTWindow
return awtNative;
}
@@ -84,30 +87,52 @@ public class AWTNewtFactory {
* The actual wrapping implementation is {@link com.jogamp.nativewindow.impl.jawt.JAWTWindow}.<br></p>
* <p>
* Second we create a child {@link com.jogamp.newt.Window},
- * utilizing {@link com.jogamp.newt.NewtFactory#createWindow(long, com.jogamp.newt.Screen, javax.media.nativewindow.Capabilities, boolean)},
- * passing the AWT parent's native window handle retrieved via {@link com.jogamp.nativewindow.impl.jawt.JAWTWindow#getWindowHandle()}.<br></p>
+ * utilizing {@link com.jogamp.newt.NewtFactory#createWindowImpl(java.lang.String, javax.media.nativewindow.NativeWindow, com.jogamp.newt.Screen, javax.media.nativewindow.Capabilities, boolean)},
+ * passing the created {@link javax.media.nativewindow.NativeWindow}.<br></p>
* <p>
* Third we attach a {@link com.jogamp.newt.event.awt.AWTParentWindowAdapter} to the given AWT component.<br>
* The adapter passes window related events to our new child window, look at the implementation<br></p>
*
+ * <p>
+ * Forth we pass the parents visibility to the new Window<br></p>
+ *
* @param awtParentObject must be of type java.awt.Component
* @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always
+ * @return The successful created child window, or null if the AWT parent is not ready yet (no valid peers)
*/
- public static Window createNativeChildWindow(Object awtParentObject, Screen newtScreen, Capabilities newtCaps, boolean undecorated) {
- NativeWindow parent = getNativeWindow(awtParentObject); // also checks java.awt.Component type
+ public static Window createNativeChildWindow(Object awtParentObject, Capabilities newtCaps, boolean undecorated) {
+ if( null == awtParentObject ) {
+ throw new NativeWindowException("Null AWT Parent Component");
+ }
+ if( ! (awtParentObject instanceof java.awt.Component) ) {
+ throw new NativeWindowException("AWT Parent Component not a java.awt.Component");
+ }
java.awt.Component awtParent = (java.awt.Component) awtParentObject;
+
+ // Generate a complete JAWT NativeWindow from the AWT Component
+ NativeWindow parent = getNativeWindow(awtParent, newtCaps);
if(null==parent) {
throw new NativeWindowException("Null NativeWindow from parent: "+awtParent);
}
- parent.lockSurface();
- long windowHandle = parent.getWindowHandle();
- parent.unlockSurface();
- if(0==windowHandle) {
- throw new NativeWindowException("Null window handle: "+parent);
- }
- Window window = NewtFactory.createWindow(windowHandle, newtScreen, newtCaps, undecorated);
+
+ // Get parent's NativeWindow details
+ AWTGraphicsConfiguration parentConfig = (AWTGraphicsConfiguration) parent.getGraphicsConfiguration();
+ AWTGraphicsScreen parentScreen = (AWTGraphicsScreen) parentConfig.getScreen();
+ AWTGraphicsDevice parentDevice = (AWTGraphicsDevice) parentScreen.getDevice();
+
+ // Prep NEWT's Display and Screen according to the parent
+ final String type = NativeWindowFactory.getNativeWindowType(true);
+ Display display = NewtFactory.wrapDisplay(type, parentDevice.getHandle());
+ Screen screen = NewtFactory.createScreen(type, display, parentScreen.getIndex());
+
+ // NEWT Window creation and add event handler for proper propagation AWT -> NEWT
+ // and copy size/visible state
+ Window window = NewtFactory.createWindowImpl(type, parent, screen, newtCaps, undecorated);
new AWTParentWindowAdapter(window).addTo(awtParent);
+ window.setSize(awtParent.getWidth(), awtParent.getHeight());
+ window.setVisible(awtParent.isVisible());
+
return window;
}
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java
index bc04f2523..b98a6fa20 100644
--- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java
@@ -34,6 +34,7 @@
package com.jogamp.newt.impl.awt;
import com.jogamp.newt.event.awt.*;
+import com.jogamp.newt.util.EDTUtil;
import java.awt.BorderLayout;
import java.awt.Canvas;
@@ -94,7 +95,7 @@ public class AWTWindow extends Window {
});
}
- protected void createNative(long parentWindowHandle, final Capabilities caps) {
+ protected void createNativeImpl() {
if(0!=parentWindowHandle) {
throw new RuntimeException("Window parenting not supported in AWT, use AWTWindow(Frame) cstr for wrapping instead");
@@ -175,7 +176,7 @@ public class AWTWindow extends Window {
return res;
}
- public void setVisible(final boolean visible) {
+ protected void setVisibleImpl() {
runOnEDT(true, new Runnable() {
public void run() {
container.setVisible(visible);
@@ -209,14 +210,16 @@ public class AWTWindow extends Window {
nfs_width=width;
nfs_height=height;
}
- /** An AWT event on setSize() would bring us in a deadlock situation, hence invokeLater() */
- runOnEDT(false, new Runnable() {
- public void run() {
- Insets insets = container.getInsets();
- container.setSize(width + insets.left + insets.right,
- height + insets.top + insets.bottom);
- }
- });
+ if(null!=container) {
+ /** An AWT event on setSize() would bring us in a deadlock situation, hence invokeLater() */
+ runOnEDT(false, new Runnable() {
+ public void run() {
+ Insets insets = container.getInsets();
+ container.setSize(width + insets.left + insets.right,
+ height + insets.top + insets.bottom);
+ }
+ });
+ }
}
public com.jogamp.newt.Insets getInsets() {
@@ -302,8 +305,9 @@ public class AWTWindow extends Window {
super.sendMouseEvent(eventType, modifiers, x, y, button, rotation);
}
- private static void runOnEDT(boolean wait, Runnable r) {
- if (EventQueue.isDispatchThread()) {
+ private void runOnEDT(boolean wait, Runnable r) {
+ EDTUtil edtUtil = screen.getDisplay().getEDTUtil();
+ if ( ( null != edtUtil && edtUtil.isCurrentThreadEDT() ) || EventQueue.isDispatchThread() ) {
r.run();
} else {
try {
diff --git a/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Display.java b/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Display.java
index d19aaf796..ac27da9ef 100644
--- a/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Display.java
+++ b/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Display.java
@@ -58,10 +58,10 @@ public class Display extends com.jogamp.newt.Display {
public Display() {
}
- protected void createNative() {
+ protected void createNative(long handle) {
synchronized(Display.class) {
if(0==initCounter) {
- displayHandle = CreateDisplay();
+ displayHandle = (0 == handle) ? CreateDisplay() : handle;
if(0==displayHandle) {
throw new NativeWindowException("Couldn't initialize GDL Display");
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java b/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java
index cb52618b2..7b867db21 100644
--- a/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java
+++ b/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java
@@ -45,7 +45,7 @@ public class Window extends com.jogamp.newt.Window {
static long nextWindowHandle = 1;
- protected void createNative(long parentWindowHandle, Capabilities caps) {
+ protected void createNativeImpl() {
if(0!=parentWindowHandle) {
throw new NativeWindowException("GDL Window does not support window parenting");
}
@@ -59,6 +59,11 @@ public class Window extends com.jogamp.newt.Window {
synchronized(Window.class) {
windowHandle = nextWindowHandle++;
+
+ surfaceHandle = CreateSurface(aDevice.getHandle(), screen.getWidth(), screen.getHeight(), x, y, width, height);
+ if (surfaceHandle == 0) {
+ throw new NativeWindowException("Error creating window");
+ }
}
}
@@ -72,19 +77,9 @@ public class Window extends com.jogamp.newt.Window {
}
}
- public void setVisible(boolean visible) {
- if(this.visible!=visible) {
- this.visible=visible;
- if(visible && 0==surfaceHandle) {
- synchronized(Window.class) {
- AbstractGraphicsDevice aDevice = screen.getDisplay().getGraphicsDevice();
- surfaceHandle = CreateSurface(aDevice.getHandle(), screen.getWidth(), screen.getHeight(), x, y, width, height);
- }
- if (surfaceHandle == 0) {
- throw new NativeWindowException("Error creating window");
- }
- ((Display)screen.getDisplay()).setFocus(this);
- }
+ protected void setVisibleImpl() {
+ if(visible) {
+ ((Display)screen.getDisplay()).setFocus(this);
}
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java b/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java
index 68242bba7..6e1119a9d 100755
--- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java
@@ -43,10 +43,10 @@ public class MacDisplay extends Display {
static {
NEWTJNILibLoader.loadNEWT();
- if(!initNSApplication()) {
+ if(!initNSApplication0()) {
throw new NativeWindowException("Failed to initialize native Application hook");
}
- if(!MacWindow.initIDs()) {
+ if(!MacWindow.initIDs0()) {
throw new NativeWindowException("Failed to initialize jmethodIDs");
}
if(DEBUG) System.out.println("MacDisplay.init App and IDs OK "+Thread.currentThread().getName());
@@ -70,13 +70,13 @@ public class MacDisplay extends Display {
MainThread.invoke(false, dispatchAction);
}
- protected void createNative() {
+ protected void createNative(long handle) {
aDevice = new MacOSXGraphicsDevice();
}
protected void closeNative() { }
- private static native boolean initNSApplication();
+ private static native boolean initNSApplication0();
protected native void dispatchMessages0();
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/macosx/MacScreen.java b/src/newt/classes/com/jogamp/newt/impl/macosx/MacScreen.java
index ce9254857..d7deb13ee 100755
--- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacScreen.java
+++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacScreen.java
@@ -46,11 +46,11 @@ public class MacScreen extends Screen {
protected void createNative(int index) {
aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
- setScreenSize(getWidthImpl(getIndex()), getHeightImpl(getIndex()));
+ setScreenSize(getWidthImpl0(getIndex()), getHeightImpl0(getIndex()));
}
protected void closeNative() { }
- private static native int getWidthImpl(int scrn_idx);
- private static native int getHeightImpl(int scrn_idx);
+ private static native int getWidthImpl0(int scrn_idx);
+ private static native int getHeightImpl0(int scrn_idx);
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
index 963c0c0a7..93c2b14bb 100755
--- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
@@ -130,7 +130,6 @@ public class MacWindow extends Window {
private static final int NSModeSwitchFunctionKey = 0xF747;
private volatile long surfaceHandle;
- private long parentWindowHandle;
// non fullscreen dimensions ..
private int nfs_width, nfs_height, nfs_x, nfs_y;
@@ -143,8 +142,7 @@ public class MacWindow extends Window {
public MacWindow() {
}
- protected void createNative(long parentWindowHandle, Capabilities caps) {
- this.parentWindowHandle=parentWindowHandle;
+ protected void createNativeImpl() {
config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
if (config == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
@@ -193,7 +191,7 @@ public class MacWindow extends Window {
public void run() {
nsViewLock.lock();
try {
- createWindow(parentWindowHandle, false);
+ createWindow(false);
} finally {
nsViewLock.unlock();
}
@@ -237,13 +235,13 @@ public class MacWindow extends Window {
try {
if(DEBUG_IMPLEMENTATION) System.out.println("MacWindow.VisibleAction "+visible+" "+Thread.currentThread().getName());
if (visible) {
- createWindow(parentWindowHandle, false);
+ createWindow(false);
if (windowHandle != 0) {
- makeKeyAndOrderFront(windowHandle);
+ makeKeyAndOrderFront0(windowHandle);
}
} else {
if (windowHandle != 0) {
- orderOut(windowHandle);
+ orderOut0(windowHandle);
}
}
} finally {
@@ -253,8 +251,7 @@ public class MacWindow extends Window {
}
private VisibleAction visibleAction = new VisibleAction();
- public void setVisible(boolean visible) {
- this.visible = visible;
+ protected void setVisibleImpl() {
MainThread.invoke(true, visibleAction);
}
@@ -282,7 +279,7 @@ public class MacWindow extends Window {
nsViewLock.lock();
try {
if (windowHandle != 0) {
- makeKey(windowHandle);
+ makeKey0(windowHandle);
}
} finally {
nsViewLock.unlock();
@@ -301,7 +298,7 @@ public class MacWindow extends Window {
nsViewLock.lock();
try {
if (windowHandle != 0) {
- setContentSize(windowHandle, width, height);
+ setContentSize0(windowHandle, width, height);
}
} finally {
nsViewLock.unlock();
@@ -311,13 +308,19 @@ public class MacWindow extends Window {
private SizeAction sizeAction = new SizeAction();
public void setSize(int width, int height) {
- this.width=width;
- this.height=height;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
+ if (width != this.width || this.height != height) {
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ if (0 != windowHandle) {
+ // this width/height will be set by sizeChanged, called by OSX
+ MainThread.invoke(true, sizeAction);
+ } else {
+ this.width=width;
+ this.height=height;
+ }
+ }
}
- MainThread.invoke(true, sizeAction);
}
class PositionAction implements Runnable {
@@ -325,7 +328,7 @@ public class MacWindow extends Window {
nsViewLock.lock();
try {
if (windowHandle != 0) {
- setFrameTopLeftPoint(parentWindowHandle, windowHandle, x, y);
+ setFrameTopLeftPoint0(parentWindowHandle, windowHandle, x, y);
}
} finally {
nsViewLock.unlock();
@@ -335,13 +338,19 @@ public class MacWindow extends Window {
private PositionAction positionAction = new PositionAction();
public void setPosition(int x, int y) {
- this.x=x;
- this.y=y;
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
+ if ( this.x != x || this.y != y ) {
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ if (0 != windowHandle) {
+ // this x/y will be set by positionChanged, called by OSX
+ MainThread.invoke(true, positionAction);
+ } else {
+ this.x=x;
+ this.y=y;
+ }
+ }
}
- MainThread.invoke(true, positionAction);
}
class FullscreenAction implements Runnable {
@@ -351,9 +360,9 @@ public class MacWindow extends Window {
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
System.err.println("MacWindow fs: "+fullscreen+" "+x+"/"+y+" "+width+"x"+height);
}
- createWindow(parentWindowHandle, true);
+ createWindow(true);
if (windowHandle != 0) {
- makeKeyAndOrderFront(windowHandle);
+ makeKeyAndOrderFront0(windowHandle);
}
} finally {
nsViewLock.unlock();
@@ -382,19 +391,21 @@ public class MacWindow extends Window {
}
private void sizeChanged(int newWidth, int newHeight) {
- if (DEBUG_IMPLEMENTATION) {
- System.out.println(Thread.currentThread().getName()+" Size changed to " + newWidth + ", " + newHeight);
- }
- width = newWidth;
- height = newHeight;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
- }
- if (DEBUG_IMPLEMENTATION) {
- System.out.println(" Posted WINDOW_RESIZED event");
+ if(width != newWidth || height != newHeight) {
+ if (DEBUG_IMPLEMENTATION) {
+ System.out.println(Thread.currentThread().getName()+" Size changed to " + newWidth + ", " + newHeight);
+ }
+ width = newWidth;
+ height = newHeight;
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ }
+ if (DEBUG_IMPLEMENTATION) {
+ System.out.println(" Posted WINDOW_RESIZED event");
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
}
- sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
}
private void insetsChanged(int left, int top, int right, int bottom) {
@@ -411,19 +422,21 @@ public class MacWindow extends Window {
}
private void positionChanged(int newX, int newY) {
- if (DEBUG_IMPLEMENTATION) {
- System.out.println(Thread.currentThread().getName()+" Position changed to " + newX + ", " + newY);
- }
- x = newX;
- y = newY;
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
- }
- if (DEBUG_IMPLEMENTATION) {
- System.out.println(" Posted WINDOW_MOVED event");
+ if( 0==parentWindowHandle && ( x != newX || y != newY ) ) {
+ if (DEBUG_IMPLEMENTATION) {
+ System.out.println(Thread.currentThread().getName()+" Position changed to " + newX + ", " + newY);
+ }
+ x = newX;
+ y = newY;
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ }
+ if (DEBUG_IMPLEMENTATION) {
+ System.out.println(" Posted WINDOW_MOVED event");
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
}
- sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
}
private void focusChanged(boolean focusGained) {
@@ -525,13 +538,13 @@ public class MacWindow extends Window {
super.sendKeyEvent(eventType, modifiers, key, keyChar);
}
- private void createWindow(long parentWindowHandle, boolean recreate) {
+ private void createWindow(boolean recreate) {
if(0!=windowHandle && !recreate) {
return;
}
if(0!=windowHandle) {
// save the view .. close the window
- surfaceHandle = changeContentView(parentWindowHandle, windowHandle, 0);
+ surfaceHandle = changeContentView0(parentWindowHandle, windowHandle, 0);
if(recreate && 0==surfaceHandle) {
throw new NativeWindowException("Internal Error - recreate, window but no view");
}
@@ -550,27 +563,27 @@ public class MacWindow extends Window {
if (windowHandle == 0) {
throw new NativeWindowException("Could create native window "+Thread.currentThread().getName()+" "+this);
}
- surfaceHandle = contentView(windowHandle);
+ surfaceHandle = contentView0(windowHandle);
setTitle0(windowHandle, getTitle());
// don't make the window visible on window creation
-// makeKeyAndOrderFront(windowHandle);
+// makeKeyAndOrderFront0(windowHandle);
sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
sendWindowEvent(WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
}
- protected static native boolean initIDs();
+ protected static native boolean initIDs0();
private native long createWindow0(long parentWindowHandle, int x, int y, int w, int h,
boolean fullscreen, int windowStyle,
int backingStoreType,
int screen_idx, long view);
- private native void makeKeyAndOrderFront(long window);
- private native void makeKey(long window);
- private native void orderOut(long window);
+ private native void makeKeyAndOrderFront0(long window);
+ private native void makeKey0(long window);
+ private native void orderOut0(long window);
private native void close0(long window);
private native void setTitle0(long window, String title);
- private native long contentView(long window);
- private native long changeContentView(long parentWindowHandle, long window, long view);
- private native void setContentSize(long window, int w, int h);
- private native void setFrameTopLeftPoint(long parentWindowHandle, long window, int x, int y);
+ private native long contentView0(long window);
+ private native long changeContentView0(long parentWindowHandle, long window, long view);
+ private native void setContentSize0(long window, int w, int h);
+ private native void setFrameTopLeftPoint0(long parentWindowHandle, long window, int x, int y);
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Display.java b/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Display.java
index c2d323e56..c08499359 100644
--- a/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Display.java
+++ b/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Display.java
@@ -56,8 +56,10 @@ public class Display extends com.jogamp.newt.Display {
public Display() {
}
- protected void createNative() {
- long handle = CreateDisplay(Screen.fixedWidth, Screen.fixedHeight);
+ protected void createNative(long handle) {
+ if( 0 == handle ) {
+ handle = CreateDisplay(Screen.fixedWidth, Screen.fixedHeight);
+ }
if (handle == EGL.EGL_NO_DISPLAY) {
throw new NativeWindowException("BC EGL CreateDisplay failed");
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java b/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java
index 9e1ead40e..b25ed4ee8 100755
--- a/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java
+++ b/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java
@@ -46,7 +46,7 @@ public class Window extends com.jogamp.newt.Window {
public Window() {
}
- protected void createNative(long parentWindowHandle, Capabilities caps) {
+ protected void createNativeImpl() {
if(0!=parentWindowHandle) {
throw new RuntimeException("Window parenting not supported (yet)");
}
@@ -57,6 +57,11 @@ public class Window extends com.jogamp.newt.Window {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
setSizeImpl(getScreen().getWidth(), getScreen().getHeight());
+
+ windowHandle = realizeWindow(true, width, height);
+ if (0 == windowHandle) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
}
protected void closeNative() {
@@ -65,18 +70,7 @@ public class Window extends com.jogamp.newt.Window {
}
}
- public void setVisible(boolean visible) {
- if(this.visible!=visible) {
- this.visible=visible;
- if ( 0==windowHandle ) {
- windowHandle = realizeWindow(true, width, height);
- if (0 == windowHandle) {
- throw new NativeWindowException("Error native Window Handle is null");
- }
- }
- clearEventMask();
- }
- }
+ protected void setVisibleImpl() { }
public void setSize(int width, int height) {
System.err.println("setSize "+width+"x"+height+" n/a in BroadcomEGL");
diff --git a/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDDisplay.java b/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDDisplay.java
index 2ab30773f..bb5f1cc7a 100755
--- a/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDDisplay.java
@@ -57,9 +57,12 @@ public class KDDisplay extends Display {
public KDDisplay() {
}
- protected void createNative() {
+ protected void createNative(long handle) {
// FIXME: map name to EGL_*_DISPLAY
- long handle = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
+ // FIXME: what do to with external handle ?
+ if(0==handle) {
+ handle = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
+ }
if (handle == EGL.EGL_NO_DISPLAY) {
throw new NativeWindowException("eglGetDisplay failed");
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java b/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java
index 5f1068cad..f60abb7cd 100755
--- a/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java
@@ -54,7 +54,7 @@ public class KDWindow extends Window {
public KDWindow() {
}
- protected void createNative(long parentWindowHandle, Capabilities caps) {
+ protected void createNativeImpl() {
if(0!=parentWindowHandle) {
throw new RuntimeException("Window parenting not supported (yet)");
}
@@ -66,12 +66,15 @@ public class KDWindow extends Window {
GLCapabilities eglCaps = (GLCapabilities)config.getChosenCapabilities();
int[] eglAttribs = EGLGraphicsConfiguration.GLCapabilities2AttribList(eglCaps);
- windowHandle = 0;
eglWindowHandle = CreateWindow(getDisplayHandle(), eglAttribs);
if (eglWindowHandle == 0) {
throw new NativeWindowException("Error creating egl window: "+config);
}
setVisible0(eglWindowHandle, false);
+ windowHandle = RealizeWindow(eglWindowHandle);
+ if (0 == windowHandle) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
windowHandleClose = eglWindowHandle;
}
@@ -82,18 +85,9 @@ public class KDWindow extends Window {
}
}
- public void setVisible(boolean visible) {
- if(0!=eglWindowHandle && this.visible!=visible) {
- this.visible=visible;
- setVisible0(eglWindowHandle, visible);
- if ( 0==windowHandle ) {
- windowHandle = RealizeWindow(eglWindowHandle);
- if (0 == windowHandle) {
- throw new NativeWindowException("Error native Window Handle is null");
- }
- }
- clearEventMask();
- }
+ protected void setVisibleImpl() {
+ setVisible0(eglWindowHandle, visible);
+ clearEventMask();
}
public void setSize(int width, int height) {
diff --git a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsDisplay.java b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsDisplay.java
index 000e64b6d..f75c11cfb 100755
--- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsDisplay.java
@@ -47,7 +47,7 @@ public class WindowsDisplay extends Display {
static {
NEWTJNILibLoader.loadNEWT();
- if (!WindowsWindow.initIDs()) {
+ if (!WindowsWindow.initIDs0()) {
throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs");
}
}
@@ -60,22 +60,22 @@ public class WindowsDisplay extends Display {
public WindowsDisplay() {
}
- protected void createNative() {
+ protected void createNative(long handle) {
aDevice = new WindowsGraphicsDevice();
}
protected void closeNative() {
// Can't do .. only at application shutdown
- // UnregisterWindowClass(getWindowClassAtom(), getHInstance());
+ // UnregisterWindowClass0(getWindowClassAtom(), getHInstance());
}
protected void dispatchMessagesNative() {
- DispatchMessages();
+ DispatchMessages0();
}
protected static synchronized int getWindowClassAtom() {
if(0 == windowClassAtom) {
- windowClassAtom = RegisterWindowClass(WINDOW_CLASS_NAME, getHInstance());
+ windowClassAtom = RegisterWindowClass0(WINDOW_CLASS_NAME, getHInstance());
if (0 == windowClassAtom) {
throw new NativeWindowException("Error while registering window class");
}
@@ -85,7 +85,7 @@ public class WindowsDisplay extends Display {
protected static synchronized long getHInstance() {
if(0 == hInstance) {
- hInstance = LoadLibraryW("newt");
+ hInstance = LoadLibraryW0("newt");
if (0 == hInstance) {
throw new NativeWindowException("Error finding HINSTANCE for \"newt\"");
}
@@ -96,10 +96,10 @@ public class WindowsDisplay extends Display {
//----------------------------------------------------------------------
// Internals only
//
- private static native long LoadLibraryW(String libraryName);
- private static native int RegisterWindowClass(String windowClassName, long hInstance);
- private static native void UnregisterWindowClass(int wndClassAtom, long hInstance);
+ private static native long LoadLibraryW0(String libraryName);
+ private static native int RegisterWindowClass0(String windowClassName, long hInstance);
+ private static native void UnregisterWindowClass0(int wndClassAtom, long hInstance);
- private static native void DispatchMessages();
+ private static native void DispatchMessages0();
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java
index b0161cfc2..1b4be0d55 100755
--- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java
+++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsScreen.java
@@ -47,11 +47,11 @@ public class WindowsScreen extends Screen {
protected void createNative(int index) {
aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
- setScreenSize(getWidthImpl(getIndex()), getHeightImpl(getIndex()));
+ setScreenSize(getWidthImpl0(getIndex()), getHeightImpl0(getIndex()));
}
protected void closeNative() { }
- private native int getWidthImpl(int scrn_idx);
- private native int getHeightImpl(int scrn_idx);
+ private native int getWidthImpl0(int scrn_idx);
+ private native int getHeightImpl0(int scrn_idx);
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
index bec7bfed2..dad3456d7 100755
--- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
@@ -42,7 +42,6 @@ public class WindowsWindow extends Window {
private long hmon;
private long hdc;
private long windowHandleClose;
- private long parentWindowHandle;
// non fullscreen dimensions ..
private int nfs_width, nfs_height, nfs_x, nfs_y;
private final Insets insets = new Insets(0, 0, 0, 0);
@@ -62,8 +61,8 @@ public class WindowsWindow extends Window {
if(hdc!=0) {
throw new NativeWindowException("NEWT Surface handle set HDC "+toHexString(hdc)+" - "+Thread.currentThread().getName()+" ; "+this);
}
- hdc = GetDC(windowHandle);
- hmon = MonitorFromWindow(windowHandle);
+ hdc = GetDC0(windowHandle);
+ hmon = MonitorFromWindow0(windowHandle);
hdcOwner = Thread.currentThread();
}
return res;
@@ -80,7 +79,7 @@ public class WindowsWindow extends Window {
if(hdcOwner != cur) {
throw new NativeWindowException("NEWT Surface handle set HDC "+toHexString(hdc)+" by other thread "+hdcOwner+", this "+cur+" ; "+this);
}
- ReleaseDC(windowHandle, hdc);
+ ReleaseDC0(windowHandle, hdc);
hdc=0;
hdcOwner=null;
}
@@ -93,7 +92,7 @@ public class WindowsWindow extends Window {
public boolean hasDeviceChanged() {
if(0!=windowHandle) {
- long _hmon = MonitorFromWindow(windowHandle);
+ long _hmon = MonitorFromWindow0(windowHandle);
if (hmon != _hmon) {
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
Exception e = new Exception("!!! Window Device Changed "+Thread.currentThread().getName()+
@@ -107,20 +106,19 @@ public class WindowsWindow extends Window {
return false;
}
- protected void createNative(long parentWindowHandle, Capabilities caps) {
+ protected void createNativeImpl() {
WindowsScreen screen = (WindowsScreen) getScreen();
WindowsDisplay display = (WindowsDisplay) screen.getDisplay();
config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen());
if (config == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
- windowHandle = CreateWindow(parentWindowHandle,
+ windowHandle = CreateWindow0(parentWindowHandle,
display.getWindowClassAtom(), display.WINDOW_CLASS_NAME, display.getHInstance(),
0, undecorated, x, y, width, height);
if (windowHandle == 0) {
throw new NativeWindowException("Error creating window");
}
- this.parentWindowHandle = parentWindowHandle;
windowHandleClose = windowHandle;
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
Exception e = new Exception("!!! Window new window handle "+Thread.currentThread().getName()+
@@ -133,12 +131,12 @@ public class WindowsWindow extends Window {
protected void closeNative() {
if (hdc != 0) {
if(windowHandleClose != 0) {
- ReleaseDC(windowHandleClose, hdc);
+ ReleaseDC0(windowHandleClose, hdc);
}
hdc = 0;
}
if(windowHandleClose != 0) {
- DestroyWindow(windowHandleClose);
+ DestroyWindow0(windowHandleClose);
windowHandleClose = 0;
}
}
@@ -148,23 +146,22 @@ public class WindowsWindow extends Window {
super.windowDestroyed();
}
- public void setVisible(boolean visible) {
- if(this.visible!=visible && 0!=windowHandle) {
- this.visible=visible;
- setVisible0(windowHandle, visible);
- }
+ protected void setVisibleImpl() {
+ setVisible0(windowHandle, visible);
}
// @Override
public void setSize(int width, int height) {
if (width != this.width || this.height != height) {
if(!fullscreen) {
- this.width=width;
- this.height=height;
nfs_width=width;
nfs_height=height;
if(0!=windowHandle) {
+ // this width/height will be set by sizeChanged, called by Windows
setSize0(parentWindowHandle, windowHandle, x, y, width, height);
+ } else {
+ this.width=width;
+ this.height=height;
}
}
}
@@ -174,12 +171,14 @@ public class WindowsWindow extends Window {
public void setPosition(int x, int y) {
if ( this.x != x || this.y != y ) {
if(!fullscreen) {
- this.x=x;
- this.y=y;
nfs_x=x;
nfs_y=y;
if(0!=windowHandle) {
+ // this x/y will be set by positionChanged, called by Windows
setPosition0(parentWindowHandle, windowHandle, x , y /*, width, height*/);
+ } else {
+ this.x=x;
+ this.y=y;
}
}
}
@@ -211,7 +210,7 @@ public class WindowsWindow extends Window {
public void requestFocus() {
super.requestFocus();
if (windowHandle != 0L) {
- requestFocus(windowHandle);
+ requestFocus0(windowHandle);
}
}
@@ -222,7 +221,7 @@ public class WindowsWindow extends Window {
}
if (0!=windowHandle && !title.equals(getTitle())) {
super.setTitle(title);
- setTitle(windowHandle, title);
+ setTitle0(windowHandle, title);
}
}
@@ -233,22 +232,22 @@ public class WindowsWindow extends Window {
//----------------------------------------------------------------------
// Internals only
//
- protected static native boolean initIDs();
- private native long CreateWindow(long parentWindowHandle,
+ protected static native boolean initIDs0();
+ private native long CreateWindow0(long parentWindowHandle,
int wndClassAtom, String wndName,
long hInstance, long visualID,
boolean isUndecorated,
int x, int y, int width, int height);
- private native void DestroyWindow(long windowHandle);
- private native long GetDC(long windowHandle);
- private native void ReleaseDC(long windowHandle, long hdc);
- private native long MonitorFromWindow(long windowHandle);
+ private native void DestroyWindow0(long windowHandle);
+ private native long GetDC0(long windowHandle);
+ private native void ReleaseDC0(long windowHandle, long hdc);
+ private native long MonitorFromWindow0(long windowHandle);
private static native void setVisible0(long windowHandle, boolean visible);
private native void setSize0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height);
private static native void setPosition0(long parentWindowHandle, long windowHandle, int x, int y /*, int width, int height*/);
private native void setFullscreen0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height, boolean isUndecorated, boolean on);
- private static native void setTitle(long windowHandle, String title);
- private static native void requestFocus(long windowHandle);
+ private static native void setTitle0(long windowHandle, String title);
+ private static native void requestFocus0(long windowHandle);
private void insetsChanged(int left, int top, int right, int bottom) {
if (left != -1 && top != -1 && right != -1 && bottom != -1) {
@@ -258,24 +257,29 @@ public class WindowsWindow extends Window {
insets.bottom = bottom;
}
}
+
private void sizeChanged(int newWidth, int newHeight) {
- width = newWidth;
- height = newHeight;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
+ if(width != newWidth || height != newHeight) {
+ width = newWidth;
+ height = newHeight;
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
}
- sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
}
private void positionChanged(int newX, int newY) {
- x = newX;
- y = newY;
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
+ if( 0==parentWindowHandle && ( x != newX || y != newY ) ) {
+ x = newX;
+ y = newY;
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
}
- sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
}
/**
diff --git a/src/newt/classes/com/jogamp/newt/impl/x11/X11Display.java b/src/newt/classes/com/jogamp/newt/impl/x11/X11Display.java
index c2de0fe18..3b0868620 100755
--- a/src/newt/classes/com/jogamp/newt/impl/x11/X11Display.java
+++ b/src/newt/classes/com/jogamp/newt/impl/x11/X11Display.java
@@ -43,11 +43,11 @@ public class X11Display extends Display {
static {
NEWTJNILibLoader.loadNEWT();
- if (!initIDs()) {
+ if ( !initIDs0() ) {
throw new NativeWindowException("Failed to initialize X11Display jmethodIDs");
}
- if (!X11Window.initIDs()) {
+ if (!X11Window.initIDs0()) {
throw new NativeWindowException("Failed to initialize X11Window jmethodIDs");
}
}
@@ -60,13 +60,24 @@ public class X11Display extends Display {
public X11Display() {
}
- protected void createNative() {
- long handle= X11Util.createThreadLocalDisplay(name);
- if (handle == 0 ) {
+ protected void createNative(long handle) {
+ if(0 != handle) {
+ // Can't use that Display handle directly,
+ // but we open up a new connection to the same Display by it's name
+ String newName = X11Util.getNameOfDisplay(handle);
+ if(DEBUG) {
+ System.out.println("Changing Display Name (provided handle): "+name+" -> 0x"+
+ Long.toHexString(handle)+" : "+newName);
+ }
+ handle = 0;
+ name = newName;
+ }
+ handle= X11Util.createThreadLocalDisplay(name);
+ if( 0 == handle ) {
throw new RuntimeException("Error creating display: "+name);
}
try {
- CompleteDisplay(handle);
+ CompleteDisplay0(handle);
} catch(RuntimeException e) {
X11Util.closeThreadLocalDisplay(name);
throw e;
@@ -82,7 +93,7 @@ public class X11Display extends Display {
if(0==getHandle()) {
throw new RuntimeException("display handle null");
}
- DispatchMessages(getHandle(), javaObjectAtom, windowDeleteAtom);
+ DispatchMessages0(getHandle(), javaObjectAtom, windowDeleteAtom);
}
protected void lockDisplay() {
@@ -101,11 +112,11 @@ public class X11Display extends Display {
//----------------------------------------------------------------------
// Internals only
//
- private static native boolean initIDs();
+ private static native boolean initIDs0();
- private native void CompleteDisplay(long handle);
+ private native void CompleteDisplay0(long handle);
- private native void DispatchMessages(long display, long javaObjectAtom, long windowDeleteAtom);
+ private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom);
private void displayCompleted(long javaObjectAtom, long windowDeleteAtom) {
this.javaObjectAtom=javaObjectAtom;
diff --git a/src/newt/classes/com/jogamp/newt/impl/x11/X11Screen.java b/src/newt/classes/com/jogamp/newt/impl/x11/X11Screen.java
index 3561bec2a..453d8e5e1 100755
--- a/src/newt/classes/com/jogamp/newt/impl/x11/X11Screen.java
+++ b/src/newt/classes/com/jogamp/newt/impl/x11/X11Screen.java
@@ -47,7 +47,7 @@ public class X11Screen extends Screen {
}
protected void createNative(int index) {
- long handle = GetScreen(display.getHandle(), index);
+ long handle = GetScreen0(display.getHandle(), index);
if (handle == 0 ) {
throw new RuntimeException("Error creating screen: "+index);
}
@@ -62,7 +62,7 @@ public class X11Screen extends Screen {
// Internals only
//
- private native long GetScreen(long dpy, int scrn_idx);
+ private native long GetScreen0(long dpy, int scrn_idx);
private native int getWidth0(long display, int scrn_idx);
private native int getHeight0(long display, int scrn_idx);
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
index 4fe9f77ad..085d1cab7 100755
--- a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
+++ b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
@@ -48,7 +48,7 @@ public class X11Window extends Window {
public X11Window() {
}
- protected void createNative(long parentWindowHandle, Capabilities caps) {
+ protected void createNativeImpl() {
X11Screen screen = (X11Screen) getScreen();
X11Display display = (X11Display) screen.getDisplay();
config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen());
@@ -58,14 +58,13 @@ public class X11Window extends Window {
attachedToParent = 0 != parentWindowHandle ;
X11GraphicsConfiguration x11config = (X11GraphicsConfiguration) config;
long visualID = x11config.getVisualID();
- long w = CreateWindow(parentWindowHandle,
+ long w = CreateWindow0(parentWindowHandle,
display.getHandle(), screen.getIndex(), visualID,
display.getJavaObjectAtom(), display.getWindowDeleteAtom(),
x, y, width, height, undecorated());
if (w == 0 || w!=windowHandle) {
throw new NativeWindowException("Error creating window: "+w);
}
- this.parentWindowHandle = parentWindowHandle;
windowHandleClose = windowHandle;
displayHandleClose = display.getHandle();
}
@@ -73,7 +72,7 @@ public class X11Window extends Window {
protected void closeNative() {
if(0!=displayHandleClose && 0!=windowHandleClose && null!=getScreen() ) {
X11Display display = (X11Display) getScreen().getDisplay();
- CloseWindow(displayHandleClose, windowHandleClose, display.getJavaObjectAtom());
+ CloseWindow0(displayHandleClose, windowHandleClose, display.getJavaObjectAtom());
windowHandleClose = 0;
displayHandleClose = 0;
}
@@ -85,15 +84,9 @@ public class X11Window extends Window {
super.windowDestroyed();
}
- public void setVisible(boolean visible) {
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("X11Window setVisible: "+this.x+"/"+this.y+" "+this.width+"x"+this.height+", fs "+fullscreen+", windowHandle "+windowHandle);
- }
- if(0!=windowHandle && this.visible!=visible) {
- this.visible=visible;
- setVisible0(getDisplayHandle(), windowHandle, visible);
- clearEventMask();
- }
+ protected void setVisibleImpl() {
+ setVisible0(getDisplayHandle(), windowHandle, visible);
+ clearEventMask();
}
public void setSize(int width, int height) {
@@ -102,12 +95,14 @@ public class X11Window extends Window {
}
if (width != this.width || this.height != height) {
if(!fullscreen) {
- this.width = width;
- this.height = height;
nfs_width=width;
nfs_height=height;
if(0!=windowHandle) {
+ // this width/height will be set by windowChanged, called by X11
setSize0(getDisplayHandle(), windowHandle, width, height);
+ } else {
+ this.width = width;
+ this.height = height;
}
}
}
@@ -119,12 +114,14 @@ public class X11Window extends Window {
}
if ( this.x != x || this.y != y ) {
if(!fullscreen) {
- this.x = x;
- this.y = y;
nfs_x=x;
nfs_y=y;
if(0!=windowHandle) {
+ // this x/y will be set by windowChanged, called by X11
setPosition0(parentWindowHandle, getDisplayHandle(), windowHandle, x, y);
+ } else {
+ this.x = x;
+ this.y = y;
}
}
}
@@ -178,11 +175,11 @@ public class X11Window extends Window {
// Internals only
//
- protected static native boolean initIDs();
- private native long CreateWindow(long parentWindowHandle, long display, int screen_index,
+ protected static native boolean initIDs0();
+ private native long CreateWindow0(long parentWindowHandle, long display, int screen_index,
long visualID, long javaObjectAtom, long windowDeleteAtom,
int x, int y, int width, int height, boolean undecorated);
- private native void CloseWindow(long display, long windowHandle, long javaObjectAtom);
+ private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom);
private native void setVisible0(long display, long windowHandle, boolean visible);
private native void setSize0(long display, long windowHandle, int width, int height);
private native void setPosSizeDecor0(long parentWindowHandle, long display, int screen_index, long windowHandle,
@@ -235,7 +232,6 @@ public class X11Window extends Window {
private long windowHandleClose;
private long displayHandleClose;
- private long parentWindowHandle;
private boolean attachedToParent;
// non fullscreen dimensions ..
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index b47b580ed..b5d55aebd 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -82,49 +82,53 @@ public class GLWindow extends Window implements GLAutoDrawable {
glwindows=newglw;
}
- /** Creates a new GLWindow on the local display, screen 0, with a
- dummy visual ID, and with the default GLCapabilities. */
- public static GLWindow create() {
- return create(null, null, false);
+ /** Creates a new GLWindow attaching the given window - not owning the Window. */
+ public static GLWindow create(Window window) {
+ return create(null, window, null, false);
}
- public static GLWindow create(boolean undecorated) {
- return create(null, null, undecorated);
+ /** Creates a new GLWindow attaching a new native child Window of the given <code>parentWindowObject</code>
+ with the given GLCapabilities - owning the Window */
+ public static GLWindow create(Object parentWindowObject, GLCapabilities caps) {
+ return create(parentWindowObject, null, caps, true);
}
- /** Creates a new GLWindow referring to the given window. */
- public static GLWindow create(Window window) {
- return create(window, null, false);
- }
+ /** Creates a new GLWindow attaching a new decorated Window on the local display, screen 0, with a
+ dummy visual ID and given GLCapabilities - owning the window */
public static GLWindow create(GLCapabilities caps) {
- return create(null, caps, false);
+ return create(null, null, caps, false);
}
- /** Creates a new GLWindow on the local display, screen 0, with a
- dummy visual ID, and with the given GLCapabilities. */
+ /** Creates a new GLWindow attaching a new Window on the local display, screen 0, with a
+ dummy visual ID and given GLCapabilities - owning the window */
public static GLWindow create(GLCapabilities caps, boolean undecorated) {
- return create(null, caps, undecorated);
+ return create(null, null, caps, undecorated);
}
/** Either or: window (prio), or caps and undecorated (2nd choice) */
- private static GLWindow create(Window window,
+ private static GLWindow create(Object parentWindowObject, Window window,
GLCapabilities caps,
boolean undecorated) {
- Display display;
boolean ownerOfWinScrDpy=false;
if (window == null) {
if (caps == null) {
caps = new GLCapabilities(null); // default ..
}
ownerOfWinScrDpy = true;
- display = NewtFactory.createDisplay(null); // local display
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- window = NewtFactory.createWindow(screen, caps, undecorated);
+ window = NewtFactory.createWindow(parentWindowObject, caps, undecorated);
}
return new GLWindow(window, ownerOfWinScrDpy);
}
+ public boolean isDestroyed() {
+ return null == window ;
+ }
+
+ public Window getWindow() {
+ return window;
+ }
+
/**
* EXPERIMENTAL<br>
* Enable or disables running the {@link Display#pumpMessages} in the {@link #display()} call.<br>
@@ -150,7 +154,7 @@ public class GLWindow extends Window implements GLAutoDrawable {
runPumpMessages = onoff;
}
- protected void createNative(long parentWindowHandle, Capabilities caps) {
+ protected void createNativeImpl() {
shouldNotCallThis();
}
@@ -204,11 +208,6 @@ public class GLWindow extends Window implements GLAutoDrawable {
/** @param sendDisposeEvent should be false in a [time,reliable] critical shutdown */
public synchronized void destroy(boolean sendDisposeEvent) {
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- Exception e1 = new Exception("GLWindow.destroy "+Thread.currentThread()+", 1: "+this);
- e1.printStackTrace();
- }
-
List newglw = (List) ((ArrayList) glwindows).clone();
newglw.remove(this);
glwindows=newglw;
@@ -224,10 +223,6 @@ public class GLWindow extends Window implements GLAutoDrawable {
drawable = null;
context = null;
window = null;
-
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println("GLWindow.destroy "+Thread.currentThread()+", fin: "+this);
- }
}
public boolean getPerfLogEnabled() { return perfLog; }
@@ -236,13 +231,13 @@ public class GLWindow extends Window implements GLAutoDrawable {
perfLog = v;
}
- public void setVisible(boolean visible) {
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println(Thread.currentThread()+" GLWindow.setVisible("+visible+") START ; isVisible "+this.visible+" ; has context "+(null!=context));
- }
- this.visible=visible;
+ protected void setVisibleImpl() {
+ shouldNotCallThis();
+ }
+
+ public void setVisible(final boolean visible) {
window.setVisible(visible);
- if (visible && context == null) {
+ if (visible && null == context && 0 != window.getWindowHandle()) {
NativeWindow nw;
if (window.getWrappedWindow() != null) {
nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getGraphicsConfiguration());
@@ -256,9 +251,6 @@ public class GLWindow extends Window implements GLAutoDrawable {
context = drawable.createContext(null);
sendReshape = true; // ensure a reshape event is send ..
}
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println(Thread.currentThread()+" GLWindow.setVisible("+visible+") END ; has context "+(null!=context));
- }
}
public Screen getScreen() {
@@ -438,7 +430,14 @@ public class GLWindow extends Window implements GLAutoDrawable {
}
public void display(boolean forceReshape) {
- if(window!=null && drawable!=null && context != null) {
+ if( null == window ) { return; }
+
+ if( null == context && window.isVisible() ) {
+ // retry native window and drawable/context creation
+ setVisible(true);
+ }
+
+ if( null != context ) {
if(runPumpMessages) {
window.getScreen().getDisplay().pumpMessages();
}
@@ -448,7 +447,7 @@ public class GLWindow extends Window implements GLAutoDrawable {
if (sendDestroy) {
destroy();
sendDestroy=false;
- } else {
+ } else if ( window.isVisible() ) {
if(forceReshape) {
sendReshape = true;
}
@@ -553,13 +552,9 @@ public class GLWindow extends Window implements GLAutoDrawable {
private SwapBuffersAction swapBuffersAction = new SwapBuffersAction();
//----------------------------------------------------------------------
- // GLDrawable methods
+ // NativeWindow/Window methods
//
- public NativeWindow getNativeWindow() {
- return null!=drawable ? drawable.getNativeWindow() : null;
- }
-
public synchronized int lockSurface() throws NativeWindowException {
if(null!=drawable) return drawable.getNativeWindow().lockSurface();
return NativeWindow.LOCK_SURFACE_NOT_READY;
@@ -587,12 +582,25 @@ public class GLWindow extends Window implements GLAutoDrawable {
public long getWindowHandle() {
if(null!=drawable) return drawable.getNativeWindow().getWindowHandle();
- return super.getWindowHandle();
+ return window.getWindowHandle();
}
public long getSurfaceHandle() {
if(null!=drawable) return drawable.getNativeWindow().getSurfaceHandle();
- return super.getSurfaceHandle();
+ return window.getSurfaceHandle();
+ }
+
+ public AbstractGraphicsConfiguration getGraphicsConfiguration() {
+ if(null!=drawable) return drawable.getNativeWindow().getGraphicsConfiguration();
+ return window.getGraphicsConfiguration();
+ }
+
+ //----------------------------------------------------------------------
+ // GLDrawable methods
+ //
+
+ public NativeWindow getNativeWindow() {
+ return null!=drawable ? drawable.getNativeWindow() : null;
}
//----------------------------------------------------------------------
diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java
index 2550eef82..e6af747c8 100644
--- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java
+++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java
@@ -123,11 +123,17 @@ public class EDTUtil {
}
public void invokeAndWait(Runnable task) {
+ invoke(false, task);
+ }
+
+ public void invoke(boolean deferred, Runnable task) {
if(task == null) {
return;
}
invokeLater(task);
- waitOnWorker();
+ if(!deferred) {
+ waitOnWorker();
+ }
}
public void waitOnWorker() {
diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m
index 21bc9b2ad..1956b6899 100644
--- a/src/newt/native/MacWindow.m
+++ b/src/newt/native/MacWindow.m
@@ -125,7 +125,7 @@ NS_ENDHANDLER
* Method: initIDs
* Signature: ()Z
*/
-JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_macosx_MacDisplay_initNSApplication
+JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_macosx_MacDisplay_initNSApplication0
(JNIEnv *env, jclass clazz)
{
static int initialized = 0;
@@ -199,7 +199,7 @@ NS_ENDHANDLER
* Method: getWidthImpl
* Signature: (I)I
*/
-JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_macosx_MacScreen_getWidthImpl
+JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_macosx_MacScreen_getWidthImpl0
(JNIEnv *env, jclass clazz, jint screen_idx)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -220,7 +220,7 @@ JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_macosx_MacScreen_getWidthImpl
* Method: getHeightImpl
* Signature: (I)I
*/
-JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_macosx_MacScreen_getHeightImpl
+JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_macosx_MacScreen_getHeightImpl0
(JNIEnv *env, jclass clazz, jint screen_idx)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -241,7 +241,7 @@ JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_macosx_MacScreen_getHeightImpl
* Method: initIDs
* Signature: ()Z
*/
-JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_initIDs
+JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_initIDs0
(JNIEnv *env, jclass clazz)
{
static int initialized = 0;
@@ -338,7 +338,7 @@ NS_ENDHANDLER
* Method: makeKeyAndOrderFront
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_makeKeyAndOrderFront
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_makeKeyAndOrderFront0
(JNIEnv *env, jobject unused, jlong window)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -352,7 +352,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_makeKeyAndOrde
* Method: makeKey
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_makeKey
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_makeKey0
(JNIEnv *env, jobject unused, jlong window)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -366,7 +366,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_makeKey
* Method: orderOut
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_orderOut
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_orderOut0
(JNIEnv *env, jobject unused, jlong window)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -421,7 +421,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_setTitle0
* Method: contentView
* Signature: (J)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_contentView
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_contentView0
(JNIEnv *env, jobject unused, jlong window)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -436,7 +436,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_contentView
* Method: changeContentView
* Signature: (J)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_changeContentView
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_changeContentView0
(JNIEnv *env, jobject jthis, jlong parent, jlong window, jlong jview)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -456,7 +456,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_changeContent
* Method: setContentSize
* Signature: (JII)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_setContentSize
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_setContentSize0
(JNIEnv *env, jobject unused, jlong window, jint w, jint h)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -471,7 +471,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_setContentSize
* Method: setFrameTopLeftPoint
* Signature: (JII)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_setFrameTopLeftPoint
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_macosx_MacWindow_setFrameTopLeftPoint0
(JNIEnv *env, jobject unused, jlong parent, jlong window, jint x, jint y)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 488588f52..fabcab1c7 100755
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -922,7 +922,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
* Method: DispatchMessages
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_DispatchMessages
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_DispatchMessages0
(JNIEnv *env, jclass clazz)
{
int i = 0;
@@ -950,7 +950,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_Dispatch
* Method: LoadLibraryW
* Signature: (Ljava/lang/String;)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_LoadLibraryW
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_LoadLibraryW0
(JNIEnv *env, jclass clazz, jstring dllName)
{
jchar* _dllName = NewtCommon_GetNullTerminatedStringChars(env, dllName);
@@ -964,7 +964,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_LoadLib
* Method: RegisterWindowClass
* Signature: (Ljava/lang/String;J)I
*/
-JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_RegisterWindowClass
+JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_RegisterWindowClass0
(JNIEnv *env, jclass clazz, jstring wndClassName, jlong hInstance)
{
ATOM res;
@@ -1004,7 +1004,7 @@ JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_Register
* Method: CleanupWindowResources
* Signature: (java/lang/String;J)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_UnregisterWindowClass
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_UnregisterWindowClass0
(JNIEnv *env, jclass clazz, jint wndClassAtom, jlong hInstance)
{
UnregisterClass(MAKEINTATOM(wndClassAtom), (HINSTANCE) (intptr_t) hInstance);
@@ -1015,7 +1015,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_Unregist
* Method: getWidthImpl
* Signature: (I)I
*/
-JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsScreen_getWidthImpl
+JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsScreen_getWidthImpl0
(JNIEnv *env, jobject obj, jint scrn_idx)
{
return (jint)GetSystemMetrics(SM_CXSCREEN);
@@ -1026,7 +1026,7 @@ JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsScreen_getWidthI
* Method: getHeightImpl
* Signature: (I)I
*/
-JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsScreen_getHeightImpl
+JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsScreen_getHeightImpl0
(JNIEnv *env, jobject obj, jint scrn_idx)
{
return (jint)GetSystemMetrics(SM_CYSCREEN);
@@ -1037,7 +1037,7 @@ JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsScreen_getHeight
* Method: initIDs
* Signature: ()Z
*/
-JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initIDs
+JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initIDs0
(JNIEnv *env, jclass clazz)
{
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)V");
@@ -1070,7 +1070,7 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI
* Method: CreateWindow
* Signature: (JILjava/lang/String;JJZIIII)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWindow
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWindow0
(JNIEnv *env, jobject obj, jlong parent, jint wndClassAtom, jstring jWndName, jlong hInstance, jlong visualID,
jboolean bIsUndecorated,
jint jx, jint jy, jint defaultWidth, jint defaultHeight)
@@ -1151,7 +1151,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWi
* Method: DestroyWindow
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_DestroyWindow
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_DestroyWindow0
(JNIEnv *env, jobject obj, jlong window)
{
DestroyWindow((HWND) (intptr_t) window);
@@ -1162,7 +1162,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_DestroyWi
* Method: GetDC
* Signature: (J)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_GetDC
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_GetDC0
(JNIEnv *env, jobject obj, jlong window)
{
return (jlong) (intptr_t) GetDC((HWND) (intptr_t) window);
@@ -1173,7 +1173,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_GetDC
* Method: ReleaseDC
* Signature: (JJ)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_ReleaseDC
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_ReleaseDC0
(JNIEnv *env, jobject obj, jlong window, jlong dc)
{
ReleaseDC((HWND) (intptr_t) window, (HDC) (intptr_t) dc);
@@ -1184,7 +1184,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_ReleaseDC
* Method: MonitorFromWindow
* Signature: (J)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_MonitorFromWindow
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_MonitorFromWindow0
(JNIEnv *env, jobject obj, jlong window)
{
#if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410 || WINVER >= 0x0500) && !defined(_WIN32_WCE)
@@ -1337,7 +1337,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setFullsc
* Method: setTitle
* Signature: (JLjava/lang/String;)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setTitle
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setTitle0
(JNIEnv *env, jclass clazz, jlong window, jstring title)
{
HWND hwnd = (HWND) (intptr_t) window;
@@ -1355,7 +1355,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setTitle
* Method: requestFocus
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_requestFocus
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_requestFocus0
(JNIEnv *env, jclass clazz, jlong window)
{
NewtWindows_requestFocus ( (HWND) (intptr_t) window ) ;
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index eb52e45bc..abaa3594f 100755
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -236,17 +236,13 @@ static void displayDispatchErrorHandlerEnable(int onoff, JNIEnv * env) {
/*
* Class: com_jogamp_newt_impl_x11_X11Display
* Method: initIDs
- * Signature: ()Z
+ * Signature: (Z)Z
*/
-JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Display_initIDs
+JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Display_initIDs0
(JNIEnv *env, jclass clazz)
{
jclass c;
- if( 0 == XInitThreads() ) {
- fprintf(stderr, "Warning: NEWT X11Window: XInitThreads() failed\n");
- }
-
displayCompletedID = (*env)->GetMethodID(env, clazz, "displayCompleted", "(JJ)V");
if (displayCompletedID == NULL) {
return JNI_FALSE;
@@ -284,7 +280,7 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Display_initIDs
* Method: CompleteDisplay
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_CompleteDisplay
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_CompleteDisplay0
(JNIEnv *env, jobject obj, jlong display)
{
Display * dpy = (Display *)(intptr_t)display;
@@ -431,7 +427,7 @@ static void NewtWindows_setDecorations (Display *dpy, Window w, Bool val) {
* Method: DispatchMessages
* Signature: (JIJJ)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages0
(JNIEnv *env, jobject obj, jlong display, jlong javaObjectAtom, jlong wmDeleteAtom)
{
Display * dpy = (Display *) (intptr_t) display;
@@ -597,7 +593,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
* Method: GetScreen
* Signature: (JI)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Screen_GetScreen
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Screen_GetScreen0
(JNIEnv *env, jobject obj, jlong display, jint screen_index)
{
Display * dpy = (Display *)(intptr_t)display;
@@ -643,7 +639,7 @@ JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_x11_X11Screen_getHeight0
* Method: initIDs
* Signature: ()Z
*/
-JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs
+JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs0
(JNIEnv *env, jclass clazz)
{
windowChangedID = (*env)->GetMethodID(env, clazz, "windowChanged", "(IIII)V");
@@ -671,7 +667,7 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs
* Method: CreateWindow
* Signature: (JJIJIIII)J
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow0
(JNIEnv *env, jobject obj, jlong parent, jlong display, jint screen_index,
jlong visualID,
jlong javaObjectAtom, jlong windowDeleteAtom,
@@ -800,7 +796,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow
* Method: CloseWindow
* Signature: (JJ)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CloseWindow
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CloseWindow0
(JNIEnv *env, jobject obj, jlong display, jlong window, jlong javaObjectAtom)
{
Display * dpy = (Display *) (intptr_t) display;