summaryrefslogtreecommitdiffstats
path: root/src/newt/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-11-25 04:25:04 +0100
committerSven Gothel <[email protected]>2013-11-25 04:25:04 +0100
commitd5c25aa5584e98416208afef57610c85ac6c254c (patch)
tree6f56777890402c2f80218be16a6c6abbc1102890 /src/newt/classes
parent09b5d1ed25f9b5de13d2b0980c95121d0d5d7c0e (diff)
Bug 672 (NewtCanvasSWT): Reuse SWTAccessor.isOS_TYPE ; Impl NW.getLocationOnScreen(..) for X11 and Windows ; Allow unit test to run on all platforms.
- Reuse SWTAccessor.isOS_TYPE (public now) - Impl NW.getLocationOnScreen(..) for X11 and Windows reusing existing native code - Allow unit test to run on all platforms. Note: NewtCanvasSWT unit tests require a 'wait for realized' while SWT dispatching. Otherwise the 'sash unit test' will fail since realiziation happens later, at least on X11. Hence extended AWTRobotUtil.waitForRealized(..) to use a 'waitAction' which is used here w/ special SWT dispatch Runnable. AWTRobotUtil.waitForRealized(..) operates on time-delta instead of iteration-counter, allowing above 'waitAction' Runnable. AWTRobotUtil.waitForRealized(..) removed 2nd 'glad.isRealized()' loop ..
Diffstat (limited to 'src/newt/classes')
-rw-r--r--src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
index 029cee3da..5ed8d9e63 100644
--- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
+++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
@@ -46,6 +46,8 @@ import javax.media.nativewindow.util.Point;
import javax.media.opengl.GLCapabilities;
import jogamp.nativewindow.macosx.OSXUtil;
+import jogamp.nativewindow.windows.GDIUtil;
+import jogamp.nativewindow.x11.X11Lib;
import jogamp.newt.Debug;
import jogamp.newt.swt.SWTEDTUtil;
@@ -70,7 +72,6 @@ import com.jogamp.newt.util.EDTUtil;
*/
public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol {
private static final boolean DEBUG = Debug.debug("Window");
- private static final boolean isOSX = NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false);
private final AbstractGraphicsScreen screen;
@@ -145,7 +146,9 @@ 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);
+ if( SWTAccessor.isOSX ) {
+ newtChild.setPosition(parent.getLocation().x,parent.getLocation().y);
+ }
newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height);
}
}
@@ -398,7 +401,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol {
public SWTNativeWindow(AbstractGraphicsConfiguration config, long nativeWindowHandle) {
this.config = config;
this.nativeWindowHandle = nativeWindowHandle;
- if(isOSX) {
+ if( SWTAccessor.isOSX ) {
this.insets = OSXUtil.GetInsets(nativeWindowHandle);
} else {
this.insets = new Insets(0, 0, 0, 0);
@@ -501,22 +504,25 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol {
@Override
public Point getLocationOnScreen(Point point) {
- if( isOSX ) {
- final Point los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0);
- // top-level position -> client window position
- 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 {
- return los;
- }
+ final Point los; // client window location on screen
+ if( SWTAccessor.isOSX ) {
+ los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0);
+ // top-level position -> client window position: OSX needs to add SWT parent position incl. insets
+ final Rectangle swtCanvasPosition = getSWTCanvasPosition();
+ los.translate(swtCanvasPosition.x + insets.getLeftWidth(), swtCanvasPosition.y + insets.getTopHeight());
+ } else if (SWTAccessor.isX11) {
+ final AbstractGraphicsScreen s = config.getScreen();
+ los = X11Lib.GetRelativeLocation(s.getDevice().getHandle(), s.getIndex(), nativeWindowHandle, 0 /*root win*/, 0, 0);
+ } else if (SWTAccessor.isWindows) {
+ los = GDIUtil.GetRelativeLocation( nativeWindowHandle, 0 /*root win*/, 0, 0);
} else {
- // client position on 'normal' windowing systems is 0/0
- if(null == point) {
- point = new Point(0, 0);
- }
- return point;
+ // fall-back to 0/0
+ los = new Point(0, 0);
+ }
+ if(null!=point) {
+ return point.translate(los);
+ } else {
+ return los;
}
}