From 5db2c65cd030311b5cfcb8174ada6e870db10258 Mon Sep 17 00:00:00 2001 From: Petros Koutsolampros Date: Sun, 24 Nov 2013 22:46:58 +0000 Subject: Bug 672 (NewtCanvasSWT ignore windowing offset on OSX'). The NewtCanvasSWT is now brought into place by the parent SWT Composite and the super SWT Canvas it extends. Also added two test cases. One with a simple SashForm and the NewtCanvasSWT in the second cell, and another with the NewtCanvasSWT in a Composite, that Composite now in the second cell of the SashForm. The second test is necessary because the NewtCanvasSWT does not receive SWT.Resize events in this configuration, but only SWT.Paint ones (a behaviour inherited from the super SWT Canvas) --- src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/newt/classes/com') diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index e63a53524..029cee3da 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -145,6 +145,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { newtChild.setSize(clientArea.width, clientArea.height); postSetSize = false; } + if( isOSX ) newtChild.setPosition(parent.getLocation().x,parent.getLocation().y); newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height); } } @@ -252,6 +253,9 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { super.dispose(); } + private Rectangle getSWTCanvasPosition() { + return super.getBounds(); + } /** @return this SWT Canvas NativeWindow representation, may be null in case it has not been realized. */ public NativeWindow getNativeWindow() { return nativeWindow; } @@ -500,7 +504,8 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { if( isOSX ) { final Point los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0); // top-level position -> client window position - los.set(los.getX() + insets.getLeftWidth(), los.getY() + insets.getTopHeight()); + final Rectangle swtCanvasPosition = getSWTCanvasPosition(); + los.set(swtCanvasPosition.x + los.getX() + insets.getLeftWidth(), swtCanvasPosition.y + los.getY() + insets.getTopHeight()); if(null!=point) { return point.translate(los); } else { -- cgit v1.2.3