diff options
author | Sven Gothel <[email protected]> | 2012-11-29 00:26:11 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-11-29 00:26:11 +0100 |
commit | 03d74338497130f8100272803cae475043d8ceee (patch) | |
tree | bc657b1abb7be5eb5ecdaf34671970b6583d31d0 /src | |
parent | 601d6c46df61853fb61df087327a055550316b1d (diff) |
NewtCanvasSWT: Add DisposeListener
Diffstat (limited to 'src')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 525225804..b56958303 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -49,8 +49,10 @@ import jogamp.nativewindow.macosx.OSXUtil; import jogamp.newt.Debug; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Rectangle; @@ -142,12 +144,23 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } }); - addControlListener(new ControlAdapter() { + addControlListener(new ControlListener() { + @Override + public void controlMoved(ControlEvent e) { + } @Override public void controlResized(final ControlEvent arg0) { updateSizeCheck(); } }); + + addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + NewtCanvasSWT.this.dispose(); + } + }); + } /** assumes nativeWindow == null ! */ @@ -160,7 +173,8 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { if(0 >= nClientArea.width || 0 >= nClientArea.height) { return false; } - + screen.getDevice().open(); + /* Native handle for the control, used to associate with GLContext */ final long nativeWindowHandle = SWTAccessor.getWindowHandle(this); final int visualID = SWTAccessor.getNativeVisualID(screen.getDevice(), nativeWindowHandle); @@ -230,6 +244,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { newtChild.destroy(); newtChild = null; } + screen.getDevice().close(); nativeWindow = null; super.dispose(); } |