diff options
author | Sven Gothel <[email protected]> | 2012-01-22 23:49:17 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-01-22 23:49:17 +0100 |
commit | c0d20361c059a97d008c561dac4f6f74e3e267cb (patch) | |
tree | 18c036e52311a651af177883f4cbb13ae36bd277 /src/jogl/classes/com/jogamp | |
parent | 8867722e28fce9e8d519fbf4e2a0c1725568706a (diff) | |
parent | 9844190b0a7a3b1504266f81bcba973a9b0ac06c (diff) |
Merge branch 'master' of github.com:sgothel/jogl
Diffstat (limited to 'src/jogl/classes/com/jogamp')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index ef1c3fbeb..c982ce16d 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -57,6 +57,7 @@ import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; @@ -186,6 +187,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { }; /** + * Storage for the client area rectangle so that it may be accessed from outside of the SWT thread. + */ + private volatile Rectangle clientArea; + + /** * Creates a new SWT GLCanvas. * * @param parent @@ -212,6 +218,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { SWTAccessor.setRealized(this, true); + clientArea = GLCanvas.this.getClientArea(); + /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite) */ device = SWTAccessor.getDevice(this); /* Native handle for the control, used to associate with GLContext */ @@ -247,6 +255,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { addControlListener(new ControlAdapter() { @Override public void controlResized(final ControlEvent arg0) { + clientArea = GLCanvas.this.getClientArea(); /* Mark for OpenGL reshape next time the control is painted */ sendReshape = true; } @@ -381,7 +390,9 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } public int getHeight() { - return getClientArea().height; + final Rectangle clientArea = this.clientArea; + if (clientArea == null) return 0; + return clientArea.height; } public NativeSurface getNativeSurface() { @@ -395,7 +406,9 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } public int getWidth() { - return getClientArea().width; + final Rectangle clientArea = this.clientArea; + if (clientArea == null) return 0; + return clientArea.width; } public boolean isRealized() { |