aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/Window.java3
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java78
-rw-r--r--src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/event/WindowAdapter.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/event/WindowEvent.java12
-rw-r--r--src/newt/classes/com/jogamp/newt/event/WindowListener.java3
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTNewtEventFactory.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/WindowImpl.java58
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/awt/opengl/VersionApplet.java174
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java1
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/windows/WindowsDisplay.java49
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java34
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/x11/X11Display.java5
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java5
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java62
-rw-r--r--src/newt/native/KDWindow.c5
-rw-r--r--src/newt/native/NewtMacWindow.m5
-rw-r--r--src/newt/native/WindowEvent.h13
-rw-r--r--src/newt/native/WindowsWindow.c134
-rw-r--r--src/newt/native/X11Window.c6
20 files changed, 399 insertions, 256 deletions
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index 99db47168..9fe5089be 100644
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -36,13 +36,14 @@ import javax.media.nativewindow.CapabilitiesChooser;
import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.SurfaceUpdatedListener;
+import javax.media.nativewindow.WindowClosingProtocol;
import javax.media.nativewindow.util.Insets;
/**
* Specifying the public Window functionality for the
* using a Window and for shadowing one like {@link com.jogamp.newt.opengl.GLWindow}.
*/
-public interface Window extends NativeWindow {
+public interface Window extends NativeWindow, WindowClosingProtocol {
public static final boolean DEBUG_MOUSE_EVENT = Debug.debug("Window.MouseEvent");
public static final boolean DEBUG_KEY_EVENT = Debug.debug("Window.KeyEvent");
public static final boolean DEBUG_WINDOW_EVENT = Debug.debug("Window.WindowEvent");
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index bee81624a..18213f94f 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -38,21 +38,36 @@ import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.KeyboardFocusManager;
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.NativeWindow;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.WindowClosingProtocol;
+import javax.media.nativewindow.awt.AWTWindowClosingProtocol;
+import com.jogamp.nativewindow.impl.awt.AWTMisc;
import com.jogamp.newt.event.awt.AWTAdapter;
import com.jogamp.newt.event.awt.AWTParentWindowAdapter;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.Window;
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.event.WindowListener;
import com.jogamp.newt.impl.Debug;
+import javax.swing.MenuSelectionManager;
-public class NewtCanvasAWT extends java.awt.Canvas {
+public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProtocol {
public static final boolean DEBUG = Debug.debug("Window");
NativeWindow nativeWindow = null;
Window newtChild = null;
+ int newtChildCloseOp;
AWTAdapter awtAdapter = null;
+ private AWTWindowClosingProtocol awtWindowClosingProtocol =
+ new AWTWindowClosingProtocol(this, new Runnable() {
+ public void run() {
+ NewtCanvasAWT.this.destroy();
+ }
+ });
+
/**
* Instantiates a NewtCanvas without a NEWT child.<br>
*/
@@ -97,12 +112,18 @@ public class NewtCanvasAWT extends java.awt.Canvas {
}
FocusAction focusAction = new FocusAction();
+ WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() {
+ public void windowGainedFocus(WindowEvent arg0) {
+ MenuSelectionManager.defaultManager().clearSelectedPath();
+ }
+ };
+
/** sets a new NEWT child, provoking reparenting on the NEWT level. */
public NewtCanvasAWT setNEWTChild(Window child) {
if(newtChild!=child) {
newtChild = child;
if(null!=nativeWindow) {
- java.awt.Container cont = getContainer(this);
+ java.awt.Container cont = AWTMisc.getContainer(this);
// reparent right away, addNotify has been called already
reparentWindow( (null!=newtChild) ? true : false, cont );
}
@@ -119,24 +140,37 @@ public class NewtCanvasAWT extends java.awt.Canvas {
* or {@link #addNotify()} hasn't been called yet.*/
public NativeWindow getNativeWindow() { return nativeWindow; }
- void setWindowAdapter(boolean attach) {
+ public int getDefaultCloseOperation() {
+ return awtWindowClosingProtocol.getDefaultCloseOperation();
+ }
+
+ public int setDefaultCloseOperation(int op) {
+ return awtWindowClosingProtocol.setDefaultCloseOperation(op);
+ }
+
+ void configureNewtChild(boolean attach) {
if(null!=awtAdapter) {
awtAdapter.removeFrom(this);
awtAdapter=null;
}
- if(attach && null!=newtChild) {
- awtAdapter = new AWTParentWindowAdapter(newtChild).addTo(this);
- }
- }
-
- static java.awt.Container getContainer(java.awt.Component comp) {
- while( null != comp ) {
- if( comp instanceof java.awt.Container ) {
- return (java.awt.Container) comp;
+ if( null != newtChild ) {
+ if(attach) {
+ awtAdapter = new AWTParentWindowAdapter(newtChild).addTo(this);
+ if(newtChild.isValid()) {
+ newtChild.addWindowListener(clearAWTMenusOnNewtFocus);
+ }
+ newtChild.setFocusAction(focusAction); // enable AWT focus traversal
+ newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingProtocol.DO_NOTHING_ON_CLOSE);
+ awtWindowClosingProtocol.addClosingListenerOneShot();
+ } else {
+ if(newtChild.isValid()) {
+ newtChild.removeWindowListener(clearAWTMenusOnNewtFocus);
+ }
+ newtChild.setFocusAction(null);
+ newtChild.setDefaultCloseOperation(newtChildCloseOp);
+ awtWindowClosingProtocol.removeClosingListener();
}
- comp = comp.getParent();
}
- return null;
}
public void addNotify() {
@@ -150,7 +184,7 @@ public class NewtCanvasAWT extends java.awt.Canvas {
// after native peer is valid: Windows
disableBackgroundErase();
- java.awt.Container cont = getContainer(this);
+ java.awt.Container cont = AWTMisc.getContainer(this);
if(DEBUG) {
// if ( isShowing() == false ) -> Container was not visible yet.
// if ( isShowing() == true ) -> Container is already visible.
@@ -161,7 +195,7 @@ public class NewtCanvasAWT extends java.awt.Canvas {
}
public void removeNotify() {
- java.awt.Container cont = getContainer(this);
+ java.awt.Container cont = AWTMisc.getContainer(this);
if(DEBUG) {
System.err.println("NewtCanvasAWT.removeNotify: "+newtChild+", from "+cont);
}
@@ -187,13 +221,12 @@ public class NewtCanvasAWT extends java.awt.Canvas {
newtChild.setSize(w, h);
newtChild.reparentWindow(nativeWindow);
newtChild.setVisible(true);
- setWindowAdapter(true);
+ configureNewtChild(true);
newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener
newtChild.windowRepaint(0, 0, w, h);
- newtChild.setFocusAction(focusAction); // enable AWT focus traversal
}
} else {
- setWindowAdapter(false);
+ configureNewtChild(false);
nativeWindow = null;
newtChild.setVisible(false);
newtChild.reparentWindow(null);
@@ -213,10 +246,11 @@ public class NewtCanvasAWT extends java.awt.Canvas {
*/
public final void destroy() {
if(null!=newtChild) {
- java.awt.Container cont = getContainer(this);
+ java.awt.Container cont = AWTMisc.getContainer(this);
if(DEBUG) {
System.err.println("NewtCanvasAWT.destroy(): "+newtChild+", from "+cont);
}
+ configureNewtChild(false);
nativeWindow = null;
newtChild.setVisible(false);
newtChild.reparentWindow(null);
@@ -229,11 +263,13 @@ public class NewtCanvasAWT extends java.awt.Canvas {
}
public void paint(Graphics g) {
+ awtWindowClosingProtocol.addClosingListenerOneShot();
if(null!=newtChild) {
newtChild.windowRepaint(0, 0, getWidth(), getHeight());
}
}
public void update(Graphics g) {
+ awtWindowClosingProtocol.addClosingListenerOneShot();
if(null!=newtChild) {
newtChild.windowRepaint(0, 0, getWidth(), getHeight());
}
diff --git a/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java
index 88b165a8d..8542820c4 100644
--- a/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java
@@ -52,6 +52,10 @@ public class TraceWindowAdapter implements WindowListener {
System.err.println(e);
if(null!=downstream) { downstream.windowDestroyNotify(e); }
}
+ public void windowDestroyed(WindowEvent e) {
+ System.err.println(e);
+ if(null!=downstream) { downstream.windowDestroyed(e); }
+ }
public void windowGainedFocus(WindowEvent e) {
System.err.println(e);
if(null!=downstream) { downstream.windowGainedFocus(e); }
diff --git a/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java
index a1ad43a13..b9e487e9b 100644
--- a/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java
@@ -36,6 +36,8 @@ public abstract class WindowAdapter implements WindowListener
}
public void windowDestroyNotify(WindowEvent e) {
}
+ public void windowDestroyed(WindowEvent e) {
+ }
public void windowGainedFocus(WindowEvent e) {
}
public void windowLostFocus(WindowEvent e) {
diff --git a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java
index 2742e0d95..f3d62d8c6 100644
--- a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java
@@ -46,6 +46,7 @@ public class WindowEvent extends NEWTEvent {
public static final int EVENT_WINDOW_GAINED_FOCUS = 103;
public static final int EVENT_WINDOW_LOST_FOCUS = 104;
public static final int EVENT_WINDOW_REPAINT = 105;
+ public static final int EVENT_WINDOW_DESTROYED = 106;
public WindowEvent(int eventType, Object source, long when) {
super(eventType, source, when);
@@ -54,11 +55,12 @@ public class WindowEvent extends NEWTEvent {
public static String getEventTypeString(int type) {
switch(type) {
case EVENT_WINDOW_RESIZED: return "WINDOW_RESIZED";
- case EVENT_WINDOW_MOVED: return "WINDOW_MOVED";
- case EVENT_WINDOW_DESTROY_NOTIFY: return "EVENT_WINDOW_DESTROY_NOTIFY";
- case EVENT_WINDOW_GAINED_FOCUS: return "EVENT_WINDOW_GAINED_FOCUS";
- case EVENT_WINDOW_LOST_FOCUS: return "EVENT_WINDOW_LOST_FOCUS";
- case EVENT_WINDOW_REPAINT: return "EVENT_WINDOW_REPAINT";
+ case EVENT_WINDOW_MOVED: return "WINDOW_MOVED";
+ case EVENT_WINDOW_DESTROY_NOTIFY: return "EVENT_WINDOW_DESTROY_NOTIFY";
+ case EVENT_WINDOW_GAINED_FOCUS: return "EVENT_WINDOW_GAINED_FOCUS";
+ case EVENT_WINDOW_LOST_FOCUS: return "EVENT_WINDOW_LOST_FOCUS";
+ case EVENT_WINDOW_REPAINT: return "EVENT_WINDOW_REPAINT";
+ case EVENT_WINDOW_DESTROYED: return "EVENT_WINDOW_DESTROYED";
default: return "unknown (" + type + ")";
}
}
diff --git a/src/newt/classes/com/jogamp/newt/event/WindowListener.java b/src/newt/classes/com/jogamp/newt/event/WindowListener.java
index 0d201a2a4..e841a06cf 100644
--- a/src/newt/classes/com/jogamp/newt/event/WindowListener.java
+++ b/src/newt/classes/com/jogamp/newt/event/WindowListener.java
@@ -44,6 +44,9 @@ public interface WindowListener extends NEWTEventListener {
/** Window will be destroyed. Release of resources is recommended. */
public void windowDestroyNotify(WindowEvent e);
+ /** Window has been destroyed.*/
+ public void windowDestroyed(WindowEvent e);
+
/** Window gained focus. */
public void windowGainedFocus(WindowEvent e);
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTNewtEventFactory.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTNewtEventFactory.java
index 8e33285bf..20c0d15d1 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTNewtEventFactory.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTNewtEventFactory.java
@@ -39,7 +39,7 @@ class AWTNewtEventFactory {
map.setKeyNotFoundValue(-1);
// n/a map.put(java.awt.event.WindowEvent.WINDOW_OPENED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_OPENED);
map.put(java.awt.event.WindowEvent.WINDOW_CLOSING, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY);
- // n/a map.put(java.awt.event.WindowEvent.WINDOW_CLOSED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_CLOSED);
+ map.put(java.awt.event.WindowEvent.WINDOW_CLOSED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROYED);
// n/a map.put(java.awt.event.WindowEvent.WINDOW_ICONIFIED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_ICONIFIED);
// n/a map.put(java.awt.event.WindowEvent.WINDOW_DEICONIFIED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DEICONIFIED);
map.put(java.awt.event.WindowEvent.WINDOW_ACTIVATED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
diff --git a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
index eb46ef99e..74186f70f 100644
--- a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
+++ b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
@@ -34,6 +34,9 @@
package com.jogamp.newt.impl;
+import java.util.ArrayList;
+import java.lang.reflect.Method;
+
import com.jogamp.common.util.ReflectionUtil;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Display;
@@ -52,8 +55,6 @@ import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.event.WindowListener;
import com.jogamp.newt.event.WindowUpdateEvent;
-import java.util.ArrayList;
-import java.lang.reflect.Method;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.CapabilitiesChooser;
@@ -372,6 +373,26 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
protected void unlockSurfaceImpl() { }
//----------------------------------------------------------------------
+ // WindowClosingProtocol implementation
+ //
+ private Object closingListenerLock = new Object();
+ private int defaultCloseOperation = DISPOSE_ON_CLOSE;
+
+ public int getDefaultCloseOperation() {
+ synchronized (closingListenerLock) {
+ return defaultCloseOperation;
+ }
+ }
+
+ public int setDefaultCloseOperation(int op) {
+ synchronized (closingListenerLock) {
+ int _op = defaultCloseOperation;
+ defaultCloseOperation = op;
+ return _op;
+ }
+ }
+
+ //----------------------------------------------------------------------
// Window: Native implementation
//
@@ -466,11 +487,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
public final void unlockSurface() {
// may throw RuntimeException if not locked
windowLock.validateLocked();
+ AbstractGraphicsDevice adevice = screen.getDisplay().getGraphicsDevice();
try {
unlockSurfaceImpl();
} finally {
- screen.getDisplay().getGraphicsDevice().unlock();
+ adevice.unlock();
}
windowLock.unlock();
}
@@ -586,11 +608,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
public void run() {
windowLock.lock();
try {
- if(DEBUG_IMPLEMENTATION) {
- String msg = new String("Window setVisible: START ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+WindowImpl.this.visible+" -> "+visible+", parentWindowHandle "+toHexString(WindowImpl.this.parentWindowHandle)+", parentWindow "+(null!=WindowImpl.this.parentWindow)/*+", "+this*/);
- System.err.println(msg);
- }
-
if(null!=lifecycleHook) {
lifecycleHook.resetCounter();
}
@@ -651,6 +668,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// fast-path: not realized yet, make visible, but zero size
return;
}
+
+ if(DEBUG_IMPLEMENTATION) {
+ String msg = new String("Window setVisible: START ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow)/*+", "+this*/);
+ System.err.println(msg);
+ Thread.dumpStack();
+ }
VisibleAction visibleAction = new VisibleAction(visible);
runOnEDTIfAvail(true, visibleAction);
}
@@ -737,11 +760,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
if(null!=lifecycleHook) {
+ // send synced destroy notification for proper cleanup, eg GLWindow/OpenGL
lifecycleHook.destroyActionInLock();
}
closeAndInvalidate();
+ // send synced destroyed notification
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROYED);
+
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.destroy() END "+getThreadName()/*+", "+WindowImpl.this*/);
}
@@ -2006,6 +2033,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
case WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY:
l.windowDestroyNotify(e);
break;
+ case WindowEvent.EVENT_WINDOW_DESTROYED:
+ l.windowDestroyed(e);
+ break;
case WindowEvent.EVENT_WINDOW_GAINED_FOCUS:
l.windowGainedFocus(e);
break;
@@ -2097,9 +2127,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
System.err.println("Window.windowDestroyNotify START "+getThreadName());
}
- enqueueWindowEvent(false, WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY);
+ // send synced destroy notifications
+ enqueueWindowEvent(true, WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY);
- if(handleDestroyNotify && isValid()) {
+ if(handleDestroyNotify && DISPOSE_ON_CLOSE == defaultCloseOperation && isValid()) {
destroy();
}
@@ -2108,13 +2139,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
- protected void windowDestroyed() {
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.windowDestroyed "+getThreadName());
- }
- closeAndInvalidate();
- }
-
public void windowRepaint(int x, int y, int width, int height) {
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.windowRepaint "+getThreadName()+" - "+x+"/"+y+" "+width+"x"+height);
diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/opengl/VersionApplet.java b/src/newt/classes/com/jogamp/newt/impl/awt/opengl/VersionApplet.java
new file mode 100644
index 000000000..f31d1bc0f
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/impl/awt/opengl/VersionApplet.java
@@ -0,0 +1,174 @@
+package com.jogamp.newt.impl.awt.opengl;
+
+import java.applet.Applet;
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.Frame;
+import java.awt.GridLayout;
+import java.awt.TextArea;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import java.util.List;
+
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+import javax.media.opengl.GL;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLEventListener;
+
+import com.jogamp.common.GlueGenVersion;
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.VersionUtil;
+import com.jogamp.nativewindow.NativeWindowVersion;
+import com.jogamp.newt.NewtVersion;
+import com.jogamp.opengl.JoglVersion;
+
+public class VersionApplet extends Applet {
+ static {
+ GLProfile.initSingleton(false);
+ }
+ TextArea tareaVersion;
+ TextArea tareaCaps;
+ GLCanvas canvas;
+
+ public static void main(String[] args) {
+ Frame frame = new Frame("JOGL Version Applet");
+ frame.setSize(800, 600);
+ frame.setLayout(new BorderLayout());
+
+ VersionApplet va = new VersionApplet();
+ frame.addWindowListener(new ClosingWindowAdapter(frame, va));
+
+ va.init();
+ frame.add(va, BorderLayout.CENTER);
+ frame.validate();
+
+ frame.setVisible(true);
+ va.start();
+ }
+
+ static class ClosingWindowAdapter extends WindowAdapter {
+ Frame f;
+ VersionApplet va;
+ public ClosingWindowAdapter(Frame f, VersionApplet va) {
+ this.f = f;
+ this.va = va;
+ }
+ public void windowClosing(WindowEvent ev) {
+ f.setVisible(false);
+ va.stop();
+ va.destroy();
+ f.remove(va);
+ f.dispose();
+ System.exit(0);
+ }
+ }
+
+ private synchronized void my_init() {
+ if(null != canvas) { return; }
+
+ GLProfile glp = GLProfile.getDefault();
+ GLCapabilities glcaps = new GLCapabilities(glp);
+
+ setLayout(new BorderLayout());
+ String s;
+
+ tareaVersion = new TextArea(120, 60);
+ s = VersionUtil.getPlatformInfo().toString();
+ System.err.println(s);
+ tareaVersion.append(s);
+
+ s = GlueGenVersion.getInstance().toString();
+ System.err.println(s);
+ tareaVersion.append(s);
+
+ s = NativeWindowVersion.getInstance().toString();
+ System.err.println(s);
+ tareaVersion.append(NativeWindowVersion.getInstance().toString());
+
+ s = JoglVersion.getInstance().toString();
+ System.err.println(s);
+ tareaVersion.append(s);
+
+ s = NewtVersion.getInstance().toString();
+ System.err.println(s);
+ tareaVersion.append(s);
+
+ tareaCaps = new TextArea(120, 20);
+ GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
+ List/*<GLCapabilitiesImmutable>*/ availCaps = factory.getAvailableCapabilities(null);
+ for(int i=0; i<availCaps.size(); i++) {
+ s = ((GLCapabilitiesImmutable) availCaps.get(i)).toString();
+ System.err.println(s);
+ tareaCaps.append(s);
+ tareaCaps.append(Platform.getNewline());
+ }
+
+ Container grid = new Container();
+ grid.setLayout(new GridLayout(2, 1));
+ grid.add(tareaVersion);
+ grid.add(tareaCaps);
+ add(grid, BorderLayout.CENTER);
+
+ canvas = new GLCanvas(glcaps);
+ canvas.addGLEventListener(new GLInfo());
+ canvas.setSize(10, 10);
+ add(canvas, BorderLayout.SOUTH);
+ validate();
+ }
+
+ private synchronized void my_release() {
+ if(null!=canvas) {
+ remove(canvas);
+ canvas.destroy();
+ canvas = null;
+ remove(tareaVersion);
+ tareaVersion=null;
+ }
+ }
+
+ public void init() {
+ System.err.println("VersionApplet: init() - begin");
+ my_init();
+ System.err.println("VersionApplet: init() - end");
+ }
+
+ public void start() {
+ System.err.println("VersionApplet: start() - begin");
+ System.err.println("VersionApplet: start() - end");
+ }
+
+ public void stop() {
+ System.err.println("VersionApplet: stop() - begin");
+ System.err.println("VersionApplet: stop() - end");
+ }
+
+ public void destroy() {
+ System.err.println("VersionApplet: destroy() - start");
+ my_release();
+ System.err.println("VersionApplet: destroy() - end");
+ }
+
+ class GLInfo implements GLEventListener {
+ public void init(GLAutoDrawable drawable) {
+ GL gl = drawable.getGL();
+ String s = JoglVersion.getInstance().getGLInfo(gl, null).toString();
+ System.err.println(s);
+ tareaVersion.append(s);
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ }
+ }
+
+}
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 c01139b78..e789a0dc9 100644
--- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
@@ -166,7 +166,6 @@ public class MacWindow extends WindowImpl {
setWindowHandle(0);
nsViewLock.unlock();
}
- windowDestroyed(); // No OSX hook for DidClose, so do it here
}
public final long getSurfaceHandle() {
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 372859208..af32d1693 100644
--- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsDisplay.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -33,73 +34,61 @@
package com.jogamp.newt.impl.windows;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.windows.*;
-import com.jogamp.newt.*;
-import com.jogamp.newt.impl.*;
+import com.jogamp.nativewindow.impl.windows.RegisteredClass;
+import com.jogamp.nativewindow.impl.windows.RegisteredClassFactory;
+import com.jogamp.newt.impl.DisplayImpl;
+import com.jogamp.newt.impl.NEWTJNILibLoader;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.windows.WindowsGraphicsDevice;
public class WindowsDisplay extends DisplayImpl {
- protected static final String WINDOW_CLASS_NAME = "NewtWindowClass";
- private static int windowClassAtom;
- private static long hInstance;
+ private static final String newtClassBaseName = "_newt_clazz" ;
+ private static RegisteredClassFactory sharedClassFactory;
static {
NEWTJNILibLoader.loadNEWT();
if (!WindowsWindow.initIDs0()) {
throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs");
- }
+ }
+ sharedClassFactory = new RegisteredClassFactory(newtClassBaseName, WindowsWindow.getNewtWndProc0());
}
public static void initSingleton() {
// just exist to ensure static init has been run
}
+ private RegisteredClass sharedClass;
public WindowsDisplay() {
}
protected void createNativeImpl() {
+ sharedClass = sharedClassFactory.getSharedClass();
aDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
}
protected void closeNativeImpl() {
- // Can't do .. only at application shutdown
- // UnregisterWindowClass0(getWindowClassAtom(), getHInstance());
+ sharedClassFactory.releaseSharedClass();
}
protected void dispatchMessagesNative() {
DispatchMessages0();
}
- protected static synchronized int getWindowClassAtom() {
- if(0 == windowClassAtom) {
- windowClassAtom = RegisterWindowClass0(WINDOW_CLASS_NAME, getHInstance());
- if (0 == windowClassAtom) {
- throw new NativeWindowException("Error while registering window class");
- }
- }
- return windowClassAtom;
+ protected long getHInstance() {
+ return sharedClass.getHandle();
}
- protected static synchronized long getHInstance() {
- if(0 == hInstance) {
- hInstance = LoadLibraryW0("newt");
- if (0 == hInstance) {
- throw new NativeWindowException("Error finding HINSTANCE for \"newt\"");
- }
- }
- return hInstance;
+ protected String getWindowClassName() {
+ return sharedClass.getName();
}
//----------------------------------------------------------------------
// Internals only
//
- 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 DispatchMessages0();
}
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 d4f4f77ea..5ab0a5b79 100644
--- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
@@ -35,8 +35,9 @@
package com.jogamp.newt.impl.windows;
import com.jogamp.nativewindow.impl.windows.GDI;
-import javax.media.nativewindow.*;
import com.jogamp.newt.impl.WindowImpl;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.util.Insets;
import javax.media.nativewindow.util.Point;
@@ -56,7 +57,7 @@ public class WindowsWindow extends WindowImpl {
protected int lockSurfaceImpl() {
if( 0 != getWindowHandle() && 0 == hdc ) {
- hdc = GetDC0(getWindowHandle());
+ hdc = GDI.GetDC(getWindowHandle());
hmon = MonitorFromWindow0(getWindowHandle());
}
return ( 0 != hdc ) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY;
@@ -64,7 +65,7 @@ public class WindowsWindow extends WindowImpl {
protected void unlockSurfaceImpl() {
if ( 0 != hdc && 0 != getWindowHandle() && getWindowLockRecursionCount() == 0) {
- ReleaseDC0(getWindowHandle(), hdc);
+ GDI.ReleaseDC(getWindowHandle(), hdc);
hdc=0;
}
}
@@ -97,9 +98,8 @@ public class WindowsWindow extends WindowImpl {
if (config == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
- setWindowHandle(CreateWindow0(getParentWindowHandle(),
- display.getWindowClassAtom(), display.WINDOW_CLASS_NAME, display.getHInstance(),
- 0, undecorated, x, y, width, height));
+ setWindowHandle(CreateWindow0(display.getHInstance(), display.getWindowClassName(), display.getWindowClassName(),
+ getParentWindowHandle(), 0, undecorated, x, y, width, height));
if (getWindowHandle() == 0) {
throw new NativeWindowException("Error creating window");
}
@@ -116,7 +116,7 @@ public class WindowsWindow extends WindowImpl {
if (hdc != 0) {
if(windowHandleClose != 0) {
try {
- ReleaseDC0(windowHandleClose, hdc);
+ GDI.ReleaseDC(windowHandleClose, hdc);
} catch (Throwable t) {
if(DEBUG_IMPLEMENTATION) {
Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t);
@@ -128,7 +128,7 @@ public class WindowsWindow extends WindowImpl {
}
if(windowHandleClose != 0) {
try {
- DestroyWindow0(windowHandleClose);
+ GDI.DestroyWindow(windowHandleClose);
} catch (Throwable t) {
if(DEBUG_IMPLEMENTATION) {
Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t);
@@ -140,11 +140,6 @@ public class WindowsWindow extends WindowImpl {
}
}
- protected void windowDestroyed() {
- windowHandleClose = 0;
- super.windowDestroyed();
- }
-
protected void setVisibleImpl(boolean visible, int x, int y, int width, int height) {
setVisible0(getWindowHandle(), visible, (getParentWindowHandle()==0)?true:false, x, y, width, height);
visibleChanged(visible);
@@ -177,14 +172,11 @@ public class WindowsWindow extends WindowImpl {
// Internals only
//
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 DestroyWindow0(long windowHandle);
- private native long GetDC0(long windowHandle);
- private native void ReleaseDC0(long windowHandle, long hdc);
+ protected static native long getNewtWndProc0();
+
+ private native long CreateWindow0(long hInstance, String wndClassName, String wndName,
+ long parentWindowHandle, long visualID, boolean isUndecorated,
+ int x, int y, int width, int height);
private native long MonitorFromWindow0(long windowHandle);
private native void setVisible0(long windowHandle, boolean visible, boolean top, int x, int y, int width, int height);
private native void reconfigureWindow0(long parentWindowHandle, long windowHandle,
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 1aaffacb5..af05c0356 100644
--- a/src/newt/classes/com/jogamp/newt/impl/x11/X11Display.java
+++ b/src/newt/classes/com/jogamp/newt/impl/x11/X11Display.java
@@ -76,9 +76,8 @@ public class X11Display extends DisplayImpl {
throw e;
}
aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, NativeWindowFactory.getNullToolkitLock());
- // aDevice = new X11GraphicsDevice(handle, NativeWindowFactory.createDefaultToolkitLockNoAWT(NativeWindowFactory.TYPE_X11, handle));
- // aDevice = new X11GraphicsDevice(handle);
-
+ // aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, NativeWindowFactory.createDefaultToolkitLockNoAWT(NativeWindowFactory.TYPE_X11, handle));
+ // aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT);
}
protected void closeNativeImpl() {
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 73c6eb351..b8f1a0c95 100644
--- a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
+++ b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
@@ -87,11 +87,6 @@ public class X11Window extends WindowImpl {
}
}
- protected void windowDestroyed() {
- windowHandleClose = 0;
- super.windowDestroyed();
- }
-
protected void setVisibleImpl(boolean visible, int x, int y, int width, int height) {
setVisible0(getDisplayHandle(), getWindowHandle(), visible, x, y, width, height);
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 358a3d4ce..6886fc71b 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -34,18 +34,22 @@
package com.jogamp.newt.opengl;
+import java.util.List;
+
import com.jogamp.common.GlueGenVersion;
import com.jogamp.common.util.VersionUtil;
import com.jogamp.nativewindow.NativeWindowVersion;
import com.jogamp.newt.*;
import com.jogamp.newt.event.*;
import com.jogamp.newt.impl.WindowImpl;
+
import javax.media.nativewindow.*;
import javax.media.nativewindow.util.Point;
+import javax.media.nativewindow.util.Insets;
import javax.media.opengl.*;
+
import com.jogamp.opengl.impl.GLDrawableHelper;
import com.jogamp.opengl.JoglVersion;
-import javax.media.nativewindow.util.Insets;
/**
* An implementation of {@link javax.media.opengl.GLAutoDrawable} interface,
@@ -85,24 +89,26 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer {
}
public void windowDestroyNotify(WindowEvent e) {
- // Is an animator thread perform rendering?
- if (GLWindow.this.helper.isExternalAnimatorRunning()) {
- // Pause animations before initiating safe destroy.
- GLAnimatorControl ctrl = GLWindow.this.helper.getAnimator();
- boolean isPaused = ctrl.pause();
- destroy();
- if(isPaused) {
- ctrl.resume();
+ if( DISPOSE_ON_CLOSE == GLWindow.this.getDefaultCloseOperation() ) {
+ // Is an animator thread perform rendering?
+ if (GLWindow.this.helper.isExternalAnimatorRunning()) {
+ // Pause animations before initiating safe destroy.
+ GLAnimatorControl ctrl = GLWindow.this.helper.getAnimator();
+ boolean isPaused = ctrl.pause();
+ destroy();
+ if(isPaused) {
+ ctrl.resume();
+ }
+ } else if (GLWindow.this.window.isSurfaceLockedByOtherThread()) {
+ // Surface is locked by another thread
+ // Flag that destroy should be performed on the next
+ // attempt to display.
+ sendDestroy = true;
+ } else {
+ // Without an external thread animating or locking the
+ // surface, we are safe.
+ destroy ();
}
- } else if (GLWindow.this.window.isSurfaceLockedByOtherThread()) {
- // Surface is locked by another thread
- // Flag that destroy should be performed on the next
- // attempt to display.
- sendDestroy = true;
- } else {
- // Without an external thread animating or locking the
- // surface, we are safe.
- destroy ();
}
}
});
@@ -152,6 +158,17 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer {
}
//----------------------------------------------------------------------
+ // WindowClosingProtocol implementation
+ //
+ public int getDefaultCloseOperation() {
+ return window.getDefaultCloseOperation();
+ }
+
+ public int setDefaultCloseOperation(int op) {
+ return window.setDefaultCloseOperation(op);
+ }
+
+ //----------------------------------------------------------------------
// Window Access
//
@@ -882,7 +899,14 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer {
System.err.println(NativeWindowVersion.getInstance());
System.err.println(JoglVersion.getInstance());
System.err.println(NewtVersion.getInstance());
- GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault() );
+
+ GLProfile glp = GLProfile.getDefault();
+ GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
+ List/*<GLCapabilitiesImmutable>*/ availCaps = factory.getAvailableCapabilities(null);
+ for(int i=0; i<availCaps.size(); i++) {
+ System.err.println(availCaps.get(i));
+ }
+ GLCapabilitiesImmutable caps = new GLCapabilities( glp );
GLWindow glWindow = GLWindow.create(caps);
glWindow.setSize(128, 128);
diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c
index 33af4d963..50ad22b5a 100644
--- a/src/newt/native/KDWindow.c
+++ b/src/newt/native/KDWindow.c
@@ -94,7 +94,6 @@ static jmethodID windowCreatedID = NULL;
static jmethodID sizeChangedID = NULL;
static jmethodID visibleChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
-static jmethodID windowDestroyedID = NULL;
static jmethodID sendMouseEventID = NULL;
static jmethodID sendKeyEventID = NULL;
@@ -137,8 +136,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_opengl_kd_KDDisplay_DispatchMes
{
DBG_PRINT( "event window close : src: %p\n", userData);
(*env)->CallVoidMethod(env, javaWindow, windowDestroyNotifyID);
- // Called by Window.java: DestroyWindow(wnd);
- // (*env)->CallVoidMethod(env, javaWindow, windowDestroyedID);
}
break;
case KD_EVENT_WINDOWPROPERTY_CHANGE:
@@ -213,14 +210,12 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_opengl_kd_KDWindow_initIDs
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(IIZ)V");
visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
- windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
if (windowCreatedID == NULL ||
sizeChangedID == NULL ||
visibleChangedID == NULL ||
windowDestroyNotifyID == NULL ||
- windowDestroyedID == NULL ||
sendMouseEventID == NULL ||
sendKeyEventID == NULL) {
DBG_PRINT( "initIDs failed\n" );
diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m
index 2d8a84b4b..cba69498a 100644
--- a/src/newt/native/NewtMacWindow.m
+++ b/src/newt/native/NewtMacWindow.m
@@ -80,7 +80,6 @@ static jmethodID visibleChangedID = NULL;
static jmethodID positionChangedID = NULL;
static jmethodID focusChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
-static jmethodID windowDestroyedID = NULL;
@implementation NewtView
- (void) setJNIEnv: (JNIEnv*) theEnv
@@ -142,9 +141,8 @@ static jmethodID windowDestroyedID = NULL;
positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(II)V");
focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(Z)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
- windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
if (sendMouseEventID && sendKeyEventID && sizeChangedID && visibleChangedID && insetsChangedID &&
- positionChangedID && focusChangedID && windowDestroyedID && windowDestroyNotifyID)
+ positionChangedID && focusChangedID && windowDestroyNotifyID)
{
return YES;
}
@@ -456,7 +454,6 @@ static jint mods2JavaMods(NSUInteger mods)
(*env)->CallVoidMethod(env, javaWindowObject, windowDestroyNotifyID);
// Can't issue call here - locked window state, done from Java method
- // (*env)->CallVoidMethod(env, javaWindowObject, windowDestroyedID); // No OSX hook for DidClose, so do it here
// EOL ..
(*env)->DeleteGlobalRef(env, javaWindowObject);
diff --git a/src/newt/native/WindowEvent.h b/src/newt/native/WindowEvent.h
index 6274f9443..05491b43c 100644
--- a/src/newt/native/WindowEvent.h
+++ b/src/newt/native/WindowEvent.h
@@ -2,11 +2,12 @@
#ifndef _WINDOW_EVENT_H_
#define _WINDOW_EVENT_H_
-#define EVENT_WINDOW_RESIZED = 100;
-#define EVENT_WINDOW_MOVED = 101;
-#define EVENT_WINDOW_DESTROY_NOTIFY = 102;
-#define EVENT_WINDOW_GAINED_FOCUS = 103;
-#define EVENT_WINDOW_LOST_FOCUS = 104;
-#define EVENT_WINDOW_REPAINT = 105; // TODO
+#define EVENT_WINDOW_RESIZED 100
+#define EVENT_WINDOW_MOVED 101
+#define EVENT_WINDOW_DESTROY_NOTIFY 102
+#define EVENT_WINDOW_GAINED_FOCUS 103
+#define EVENT_WINDOW_LOST_FOCUS 104
+#define EVENT_WINDOW_REPAINT 105
+#define EVENT_WINDOW_DESTROYED 106
#endif
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index b282ec9b2..998743e75 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -124,7 +124,6 @@ static jmethodID positionChangedID = NULL;
static jmethodID focusChangedID = NULL;
static jmethodID visibleChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
-static jmethodID windowDestroyedID = NULL;
static jmethodID windowRepaintID = NULL;
static jmethodID enqueueMouseEventID = NULL;
static jmethodID sendMouseEventID = NULL;
@@ -820,8 +819,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
//
// The signal pipeline for destruction is:
// Java::DestroyWindow(wnd) _or_ window-close-button ->
- // WM_CLOSE -> Java::windowDestroyNotify -> W_DESTROY -> Java::windowDestroyed ->
- // Java::CleanupWindowResources()
+ // WM_CLOSE -> Java::windowDestroyNotify -> W_DESTROY
case WM_CLOSE:
(*env)->CallVoidMethod(env, window, windowDestroyNotifyID);
break;
@@ -834,7 +832,6 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
SetWindowLongPtr(wnd, GWLP_USERDATA, (intptr_t) NULL);
#endif
free(wud); wud=NULL;
- (*env)->CallVoidMethod(env, window, windowDestroyedID);
(*env)->DeleteGlobalRef(env, window);
}
break;
@@ -1047,71 +1044,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_Dispatch
}
/*
- * Class: com_jogamp_newt_impl_windows_WindowsDisplay
- * Method: LoadLibraryW
- * Signature: (Ljava/lang/String;)J
- */
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_LoadLibraryW0
- (JNIEnv *env, jclass clazz, jstring dllName)
-{
- jchar* _dllName = NewtCommon_GetNullTerminatedStringChars(env, dllName);
- HMODULE lib = LoadLibraryW(_dllName);
- free(_dllName);
- return (jlong) (intptr_t) lib;
-}
-
-/*
- * Class: com_jogamp_newt_impl_windows_WindowsDisplay
- * Method: RegisterWindowClass
- * Signature: (Ljava/lang/String;J)I
- */
-JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_RegisterWindowClass0
- (JNIEnv *env, jclass clazz, jstring wndClassName, jlong hInstance)
-{
- ATOM res;
- WNDCLASS wc;
-#ifndef UNICODE
- const char* _wndClassName = NULL;
-#endif
-
- /* register class */
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = (WNDPROC)wndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- /* This cast is legal because the HMODULE for a DLL is the same as
- its HINSTANCE -- see MSDN docs for DllMain */
- wc.hInstance = (HINSTANCE) (intptr_t) hInstance;
- wc.hIcon = NULL;
- wc.hCursor = LoadCursor( NULL, IDC_ARROW);
- wc.hbrBackground = GetStockObject(BLACK_BRUSH);
- wc.lpszMenuName = NULL;
-#ifdef UNICODE
- wc.lpszClassName = NewtCommon_GetNullTerminatedStringChars(env, wndClassName);
-#else
- _wndClassName = (*env)->GetStringUTFChars(env, wndClassName, NULL);
- wc.lpszClassName = strdup(_wndClassName);
- (*env)->ReleaseStringUTFChars(env, wndClassName, _wndClassName);
-#endif
- res = RegisterClass(&wc);
-
- free((void *)wc.lpszClassName);
-
- return (jint)res;
-}
-
-/*
- * Class: com_jogamp_newt_impl_windows_WindowsDisplay
- * Method: CleanupWindowResources
- * Signature: (java/lang/String;J)V
- */
-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);
-}
-
-/*
* Class: com_jogamp_newt_impl_windows_WindowsScreen
* Method: getWidthImpl
* Signature: (I)I
@@ -1332,7 +1264,6 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI
focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(Z)V");
visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
- windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(IIII)V");
enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V");
sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
@@ -1347,7 +1278,6 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI
focusChangedID == NULL ||
visibleChangedID == NULL ||
windowDestroyNotifyID == NULL ||
- windowDestroyedID == NULL ||
windowRepaintID == NULL ||
enqueueMouseEventID == NULL ||
sendMouseEventID == NULL ||
@@ -1363,15 +1293,27 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI
/*
* Class: com_jogamp_newt_impl_windows_WindowsWindow
+ * Method: getNewtWndProc0
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_getNewtWndProc0
+ (JNIEnv *env, jclass clazz)
+{
+ return (jlong) (intptr_t) wndProc;
+}
+
+/*
+ * Class: com_jogamp_newt_impl_windows_WindowsWindow
* Method: CreateWindow
- * Signature: (JILjava/lang/String;JJZIIII)J
*/
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)
+ (JNIEnv *env, jobject obj,
+ jlong hInstance, jstring jWndClassName, jstring jWndName,
+ jlong parent, jlong visualID, jboolean bIsUndecorated,
+ jint jx, jint jy, jint defaultWidth, jint defaultHeight)
{
HWND parentWindow = (HWND) (intptr_t) parent;
+ const TCHAR* wndClassName = NULL;
const TCHAR* wndName = NULL;
DWORD windowStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE | WS_TABSTOP;
int x=(int)jx, y=(int)jy;
@@ -1379,8 +1321,10 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWi
HWND window = NULL;
#ifdef UNICODE
+ wndClassName = NewtCommon_GetNullTerminatedStringChars(env, jWndClassName);
wndName = NewtCommon_GetNullTerminatedStringChars(env, jWndName);
#else
+ wndClassName = (*env)->GetStringUTFChars(env, jWndClassName, NULL);
wndName = (*env)->GetStringUTFChars(env, jWndName, NULL);
#endif
@@ -1400,13 +1344,13 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWi
(void) visualID; // FIXME: use the visualID ..
- window = CreateWindow(MAKEINTATOM(wndClassAtom), wndName, windowStyle,
+ window = CreateWindow(wndClassName, wndName, windowStyle,
x, y, width, height,
parentWindow, NULL,
(HINSTANCE) (intptr_t) hInstance,
NULL);
- DBG_PRINT("*** WindowsWindow: CreateWindow thread 0xX, parent %p, window %p, %d/%d %dx%d\n",
+ DBG_PRINT("*** WindowsWindow: CreateWindow thread 0x%X, parent %p, window %p, %d/%d %dx%d\n",
(int)GetCurrentThreadId(), parentWindow, window, x, y, width, height);
if (NULL == window) {
@@ -1427,8 +1371,10 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWi
}
#ifdef UNICODE
+ free((void*) wndClassName);
free((void*) wndName);
#else
+ (*env)->ReleaseStringUTFChars(env, jWndClassName, wndClassName);
(*env)->ReleaseStringUTFChars(env, jWndName, wndName);
#endif
@@ -1437,40 +1383,6 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWi
/*
* Class: com_jogamp_newt_impl_windows_WindowsWindow
- * Method: DestroyWindow
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_DestroyWindow0
- (JNIEnv *env, jobject obj, jlong window)
-{
- DBG_PRINT("*** WindowsWindow: DestroyWindow thread 0x%X, window %p\n", (int)GetCurrentThreadId(), window);
- DestroyWindow((HWND) (intptr_t) window);
-}
-
-/*
- * Class: com_jogamp_newt_impl_windows_WindowsWindow
- * Method: GetDC
- * Signature: (J)J
- */
-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);
-}
-
-/*
- * Class: com_jogamp_newt_impl_windows_WindowsWindow
- * Method: ReleaseDC
- * Signature: (JJ)V
- */
-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);
-}
-
-/*
- * Class: com_jogamp_newt_impl_windows_WindowsWindow
* Method: MonitorFromWindow
* Signature: (J)J
*/
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index 15418269e..d30e5de59 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -147,7 +147,6 @@ static jmethodID positionChangedID = NULL;
static jmethodID focusChangedID = NULL;
static jmethodID visibleChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
-static jmethodID windowDestroyedID = NULL;
static jmethodID windowRepaintID = NULL;
static jmethodID windowReparentedID = NULL;
static jmethodID enqueueMouseEventID = NULL;
@@ -624,7 +623,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
(void*)evt.xdestroywindow.window, (void*)evt.xdestroywindow.event, evt.xdestroywindow.window != evt.xdestroywindow.event);
if ( evt.xdestroywindow.window == evt.xdestroywindow.event ) {
// ignore child destroy notification
- (*env)->CallVoidMethod(env, jwindow, windowDestroyedID);
}
break;
case CreateNotify:
@@ -1191,7 +1189,6 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs0
focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(Z)V");
visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
- windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(IIII)V");
windowReparentedID = (*env)->GetMethodID(env, clazz, "windowReparented", "(J)V");
enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V");
@@ -1206,7 +1203,6 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs0
focusChangedID == NULL ||
visibleChangedID == NULL ||
windowDestroyNotifyID == NULL ||
- windowDestroyedID == NULL ||
windowRepaintID == NULL ||
windowReparentedID == NULL ||
enqueueMouseEventID == NULL ||
@@ -1394,8 +1390,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CloseWindow0
(*env)->DeleteGlobalRef(env, jwindow);
DBG_PRINT( "X11: CloseWindow END\n");
-
- (*env)->CallVoidMethod(env, obj, windowDestroyedID);
}
static void NewtWindows_setPosSize(Display *dpy, Window w, jint x, jint y, jint width, jint height)