aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-02-25 17:17:31 +0100
committerSven Gothel <[email protected]>2014-02-25 17:17:31 +0100
commit64bdefac9191334ace292683a6a7c4274bc3f72b (patch)
treed388d1081c114d181004caec12ff424395cae5af /src/newt/classes
parentc3621221b9a563495b4f54fe60e18e8db8cc57fb (diff)
parentc2e6233c57f47c067dbb24f4a6a127fbaedf7a08 (diff)
Merge branch 'master' into 2.2-train
Diffstat (limited to 'src/newt/classes')
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java32
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java3
3 files changed, 26 insertions, 13 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 1ed628435..f0cc68903 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -621,9 +621,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
printActive = false;
return; // not yet available ..
}
- if( !isShowing() ) {
+ if( !isVisible() ) {
if(DEBUG) {
- System.err.println(currentThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable valid, canvas not showing");
+ System.err.println(currentThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, canvas not visible");
}
printActive = false;
return; // not yet available ..
diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
index 43e56c874..6f4be75f5 100644
--- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
+++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
@@ -146,9 +146,6 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol {
newtChild.setSize(clientArea.width, clientArea.height);
postSetSize = false;
}
- if( SWTAccessor.isOSX ) {
- newtChild.setPosition(parent.getLocation().x,parent.getLocation().y);
- }
newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height);
}
}
@@ -166,7 +163,18 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol {
addListener (SWT.Paint, listener);
addListener (SWT.Dispose, listener);
}
-
+ @Override
+ public void setBounds(int x, int y, int w, int h) {
+ // propagate the setBounds method coming from parent elements to this element
+ // and force newtChild to update its position in OSX
+ super.setBounds(x,y,w,h);
+ if(SWTAccessor.isOSX) {
+ newtChild.setPosition(x, y);
+ clientArea.width = w;
+ clientArea.height = h;
+ updateSizeCheck();
+ }
+ }
/** assumes nativeWindow == null ! */
protected final boolean validateNative() {
updateSizeCheck();
@@ -199,6 +207,10 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol {
nativeWindow = new SWTNativeWindow(config, nativeWindowHandle);
reparentWindow( true );
+ if(SWTAccessor.isOSX) {
+ // initial positioning for OSX, called when the window is created
+ newtChild.setPosition(getLocation().x, getLocation().y);
+ }
}
return null != nativeWindow;
@@ -256,8 +268,9 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol {
super.dispose();
}
- private Rectangle getSWTCanvasPosition() {
- return super.getBounds();
+ private Point getParentLocationOnScreen() {
+ org.eclipse.swt.graphics.Point parentLoc = getParent().toDisplay(0,0);
+ return new Point(parentLoc.x,parentLoc.y);
}
/** @return this SWT Canvas NativeWindow representation, may be null in case it has not been realized. */
public NativeWindow getNativeWindow() { return nativeWindow; }
@@ -506,10 +519,9 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol {
public Point getLocationOnScreen(Point point) {
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());
+ // let getLOS provide the point where the child window may be placed
+ // from, as taken from SWT Control.toDisplay();
+ los = getParentLocationOnScreen();
} else if (SWTAccessor.isX11) {
final AbstractGraphicsScreen s = config.getScreen();
los = X11Lib.GetRelativeLocation(s.getDevice().getHandle(), s.getIndex(), nativeWindowHandle, 0 /*root win*/, 0, 0);
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 7f7cb61a9..9593d4faa 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -2107,7 +2107,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window setPosition: "+getX()+"/"+getY()+" -> "+x+"/"+y+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle));
}
- if ( !isFullscreen() && ( getX() != x || getY() != y ) ) {
+ // Let the window be positioned if !fullscreen and position changed or being a child window.
+ if ( !isFullscreen() && ( getX() != x || getY() != y || null != getParent()) ) {
if(isNativeValid()) {
// this.x/this.y will be set by sizeChanged, triggered by windowing event system
reconfigureWindowImpl(x, y, getWidth(), getHeight(), getReconfigureFlags(0, isVisible()));