summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-27 14:57:20 +0200
committerSven Gothel <[email protected]>2011-09-27 14:57:20 +0200
commitac49f30cde53f75d74a9e605dbc255df5852bdc2 (patch)
tree8e9b4e285c94c36d7f83e317fc9269241dda78b2 /src
parent563ae7d45cf47e1f8f2dc2d85bb139b3214eee90 (diff)
NEWT/OSX: 'Better' child window positioning, still, after reparenting into parent,
a white window rectangle remains. .. we also need to understand the absolute screen position better, ie. when required and when not (at window creation currently).
Diffstat (limited to 'src')
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java1
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java10
-rw-r--r--src/newt/native/MacWindow.m12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java7
5 files changed, 29 insertions, 9 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 5a924149c..929980d52 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -55,6 +55,7 @@ import jogamp.newt.awt.event.NewtFactoryAWT;
import javax.swing.MenuSelectionManager;
+@SuppressWarnings("serial")
public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProtocol {
public static final boolean DEBUG = Debug.debug("Window");
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
index 8fe32029c..b34f9a26c 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
@@ -200,8 +200,10 @@ public class MacWindow extends WindowImpl {
}
}
{
+ // On MacOSX the absolute position is required to position
+ // a window - even for a child window!
final NativeWindow parent = getParent();
- if(null != parent) {
+ if( null != parent && 0 != parent.getWindowHandle() ) {
final Point p = parent.getLocationOnScreen(null);
_x += p.getX();
_y += p.getY();
@@ -218,7 +220,9 @@ public class MacWindow extends WindowImpl {
if( getWindowHandle() == 0 ) {
if( 0 != ( FLAG_IS_VISIBLE & flags) ) {
- createWindow(false, _x, _y, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags));
+ // FIXME: for some reason we do not need (or can use)
+ // the absolute position at creation time .. need to determine the reason/mechanics.
+ createWindow(false, x, y, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags));
this.x = x;
this.y = y;
visibleChanged(false, true); // no native event ..
@@ -237,6 +241,8 @@ public class MacWindow extends WindowImpl {
} else if( 0 != ( FLAG_CHANGE_DECORATION & flags) ||
0 != ( FLAG_CHANGE_PARENTING & flags) ||
0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) {
+ // FIXME: for some reason we do not need (or can use)
+ // the absolute position at creation time .. need to determine the reason/mechanics.
createWindow(true, x, y, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags));
}
if(x>=0 && y>=0) {
diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m
index a149c74af..335a1fd65 100644
--- a/src/newt/native/MacWindow.m
+++ b/src/newt/native/MacWindow.m
@@ -350,8 +350,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_makeKeyAndOrderF
DBG_PRINT( "makeKeyAndOrderFront0 - window: %p (START)\n", win);
- [win performSelectorOnMainThread:@selector(makeKeyAndOrderFront:) withObject:win waitUntilDone:NO];
- // [win makeKeyAndOrderFront: win];
+ // [win performSelectorOnMainThread:@selector(makeKeyAndOrderFront:) withObject:win waitUntilDone:NO];
+ [win makeKeyAndOrderFront: win];
DBG_PRINT( "makeKeyAndOrderFront0 - window: %p (END)\n", win);
@@ -371,8 +371,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_makeKey0
DBG_PRINT( "makeKey0 - window: %p (START)\n", win);
- [win performSelectorOnMainThread:@selector(makeKeyWindow:) withObject:nil waitUntilDone:NO];
- // [win makeKeyWindow];
+ // [win performSelectorOnMainThread:@selector(makeKeyWindow:) withObject:nil waitUntilDone:NO];
+ [win makeKeyWindow];
DBG_PRINT( "makeKey0 - window: %p (END)\n", win);
@@ -392,8 +392,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderOut0
DBG_PRINT( "orderOut0 - window: %p (START)\n", win);
- [win performSelectorOnMainThread:@selector(orderOut:) withObject:win waitUntilDone:NO];
- // [win orderOut: win];
+ // [win performSelectorOnMainThread:@selector(orderOut:) withObject:win waitUntilDone:NO];
+ [win orderOut: win];
DBG_PRINT( "orderOut0 - window: %p (END)\n", win);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
index 75585291d..46748cb52 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java
@@ -82,6 +82,14 @@ class NewtAWTReparentingKeyAdapter extends KeyAdapter {
glWindow.setPosition(frame.getX()+frame.getWidth()+dx, frame.getY()+dy);
}
glWindow.requestFocus();
+ } else if(e.getKeyChar()=='s') {
+ if(glWindow.getParent()==null) {
+ System.err.println("XXX glWin to 100/100");
+ glWindow.setPosition(100, 100);
+ } else {
+ System.err.println("XXX glWin to 0/0");
+ glWindow.setPosition(0, 0);
+ }
}
}
} \ No newline at end of file
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java
index c7c067015..46a63dc14 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03bAWT.java
@@ -98,23 +98,28 @@ public class TestParenting03bAWT extends UITestCase {
Container cont1 = new Container();
cont1.setLayout(new BorderLayout());
cont1.add(newtCanvasAWT1, BorderLayout.CENTER);
+ System.err.println("******* Cont1 setVisible");
cont1.setVisible(true);
Container cont2 = new Container();
cont2.setLayout(new BorderLayout());
cont2.add(newtCanvasAWT2, BorderLayout.CENTER);
+ System.err.println("******* Cont2 setVisible");
cont2.setVisible(true);
final Container f_cont2 = cont2;
frame1.setLayout(new BorderLayout());
+ frame1.add(new Label("NORTH"), BorderLayout.NORTH);
+ frame1.add(new Label("CENTER"), BorderLayout.CENTER);
+ frame1.add(new Label("SOUTH"), BorderLayout.SOUTH);
frame1.add(cont1, BorderLayout.EAST);
- frame1.add(new Label("center"), BorderLayout.CENTER);
frame1.setLocation(0, 0);
frame1.setSize((int)size.getWidth()*2, (int)size.getHeight()*2);
final Frame f_frame1 = frame1;
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
f_frame1.pack();
+ System.err.println("******* Frame setVisible");
f_frame1.setVisible(true);
}});