diff options
author | Sven Gothel <[email protected]> | 2013-02-28 00:39:28 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-02-28 00:39:28 +0100 |
commit | 808a9a27a8c1c9e0a6701a8dd81d51f8daa8129d (patch) | |
tree | 35bf5791a829b59f1abe436abb176df7fffb045f /src/jogl/classes/javax/media/opengl | |
parent | af384debfdf354d98e3d0d0c6e0c5cf5a967904e (diff) |
Fix NEWT/AWT WindowClosing Unit Tests ; Review/Cleanup NEWT WindowClosing mechanism
Due to a NEWT WindowClosing event regression cause by NewtCanvasAWT changes
a review of our WindowClosing event mechanism was required.
Important cleanups are marked w/ '(*)' below.
I would have preferred to change the 'WindowListener.windowDestroyNotify(WindowEvent)'
method to pass a WindowCloseEvent object exposing more information like
toolkit or programmatic destruction and passing whether a 'closing' or 'nop' action
will be performed based on the WindowClosingMode.
For now I postponed this idea .. since it would change the API again,
but may reconsider it after merging the Android 'closing' patch.
- InputEvent.consumedTag -> NEWTEvent.consumedTag
- Window
- (*) Promote setWindowDestroyNotifyAction(Runnable) to public,
former WindowImpl.setHandleDestroyNotify(boolean).
Using a Runnable action for WindowImpl.windowDestroyNotify(boolean)
allows a setting defined alternative for destroy() and gets rid
of [ab]using WindowListener.windowDestroyNotify(WindowEvent) for
lifecycle actions. Used in:
- GLWindow
- GLAutoDrawableDelegate impl.
- WindowImpl
- Respect NEWTEvent.consumedTag for WindowEvents as well
- (*) Impl. setHandleDestroyNotify(boolean) (see above)
- (*) destroy() simply sends out pre- and post- destruction Window events,
where windowDestroyNotify(boolean) sends out the pre-destruction event if NOP.
- (*) windowDestroyNotify(boolean) is public now, allowing other impl. details
to follow proper destruction using handleDestroyNotify Runnable (-> NewtCanvasAWT).
- AWTWindowClosingProtocol:
- addClosingListenerOneShot() -> addClosingListener()
- calling addClosingListener() at addNotify()
- calling removeClosingListener() at removeNotify()
- AWTWindowClosingProtocol ctor taking NOP runnable,
allowing to send WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY at WindowClosingMode.DO_NOTHING_ON_CLOSE
- add/remove listener on AWT-EDT
- AWTWindowAdapter
- Add 'removeWindowClosingFrom(..)',
allowing to remove window closing event fwd.
- Also fwd windowClosed in window closing fwd'ing.
- NewtCanvasAWT
- (*) Utilize AWTWindowClosingProtocol NOP runnable (see above)
to fwd closing-NOP event to NEWT
- (*) Unify remove/destroy code in destroyImpl(..)
- !removeNotify -> destroy NEWT child programatic or as toolkit event
- removeNotify || windowClosing -> destroy jawtWindow
- (*) Remove AWTWindowAdapter/AWTParentWindowAdapter's windowClosingListener,
since we utilize AWTWindowClosingProtocol
- DisplayImpl
- Adding 'final void dispatchMessage(final NEWTEvent event)'
allowing to remove the NEWTEventTask wrapping for no reason
in enqueueEvent(..) if on EDT and waiting.
Diffstat (limited to 'src/jogl/classes/javax/media/opengl')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 6 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 5 |
2 files changed, 5 insertions, 6 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index dc4fe955c..94e123b3e 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -176,7 +176,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void run() { GLCanvas.this.destroyImpl( true ); } - }); + }, null); /** Creates a new GLCanvas component with a default set of OpenGL capabilities, using the default OpenGL capabilities selection @@ -460,7 +460,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if( isVisible() ) { Threading.invoke(true, displayOnEDTAction, getTreeLock()); } - awtWindowClosingProtocol.addClosingListenerOneShot(); } /** @@ -568,7 +567,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // for all launch flavors (applet/javaws/..) // validateGLDrawable(); } - + awtWindowClosingProtocol.addClosingListener(); + if(DEBUG) { System.err.println(getThreadName()+": Info: addNotify - end: peer: "+getPeer()); } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 2b99bb570..6c28c75ab 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -174,7 +174,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing public void run() { GLJPanel.this.destroy(); } - }); + }, null); static { // Force eager initialization of part of the Java2D class since @@ -369,6 +369,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void addNotify() { super.addNotify(); + awtWindowClosingProtocol.addClosingListener(); if (DEBUG) { System.err.println(getThreadName()+": GLJPanel.addNotify()"); } @@ -677,8 +678,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if (!isInitialized) { backend.initialize(); } - - awtWindowClosingProtocol.addClosingListenerOneShot(); } @Override |