diff options
Diffstat (limited to 'src/newt/classes/com/jogamp')
9 files changed, 26 insertions, 25 deletions
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 e04bd1208..9dace822f 100644 --- a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java +++ b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java @@ -759,11 +759,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*/); } @@ -2028,6 +2032,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; @@ -2119,7 +2126,8 @@ 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 && DISPOSE_ON_CLOSE == defaultCloseOperation && isValid()) { destroy(); @@ -2130,13 +2138,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/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/WindowsWindow.java b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java index 9bc4667c5..5ab0a5b79 100644 --- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java +++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java @@ -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); 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); } |