aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java6
-rw-r--r--src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java13
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java135
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java3
5 files changed, 88 insertions, 73 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
index 1370f0fca..ab2986fbe 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
@@ -242,9 +242,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable {
if(null != getJAWT()) {
System.err.println("JAWT version: 0x"+Integer.toHexString(getJAWT().getCachedVersion())+
", CA_LAYER: "+ JAWTUtil.isJAWTUsingOffscreenLayer(getJAWT())+
- ", isLayeredSurface "+isOffscreenLayerSurfaceEnabled()+", bounds "+bounds);
+ ", isLayeredSurface "+isOffscreenLayerSurfaceEnabled()+", bounds "+bounds+", insets "+insets);
} else {
- System.err.println("JAWT n/a, bounds "+bounds);
+ System.err.println("JAWT n/a, bounds "+bounds+", insets "+insets);
}
// Thread.dumpStack();
}
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
index ae7474c73..69b0d0482 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
@@ -107,6 +107,9 @@ public class AWTWindowAdapter
public void componentResized(java.awt.event.ComponentEvent e) {
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("AWT: componentResized: "+event);
+ }
if(null!=newtListener) {
((com.jogamp.newt.event.WindowListener)newtListener).windowResized(event);
} else {
@@ -116,6 +119,9 @@ public class AWTWindowAdapter
public void componentMoved(java.awt.event.ComponentEvent e) {
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("AWT: componentMoved: "+event);
+ }
if(null!=newtListener) {
((com.jogamp.newt.event.WindowListener)newtListener).windowMoved(event);
} else {
diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
index 313a5e868..8e9c028d4 100644
--- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
+++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
@@ -30,6 +30,8 @@ package jogamp.newt.awt.event;
import java.awt.KeyboardFocusManager;
+import jogamp.newt.driver.DriverUpdatePosition;
+
import com.jogamp.newt.event.awt.AWTAdapter;
import com.jogamp.newt.event.awt.AWTWindowAdapter;
@@ -99,7 +101,12 @@ public class AWTParentWindowAdapter
}
public void componentMoved(java.awt.event.ComponentEvent e) {
- // no propagation to NEWT child window
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("AWT: componentMoved: "+e);
+ }
+ if(getNewtWindow().getDelegatedWindow() instanceof DriverUpdatePosition) {
+ ((DriverUpdatePosition)getNewtWindow().getDelegatedWindow()).updatePosition();
+ }
}
public void windowActivated(java.awt.event.WindowEvent e) {
@@ -113,11 +120,11 @@ public class AWTParentWindowAdapter
public void hierarchyChanged(java.awt.event.HierarchyEvent e) {
if( null == getNewtEventListener() ) {
long bits = e.getChangeFlags();
- final java.awt.Component changed = e.getChanged();
+ final java.awt.Component changed = e.getChanged();
if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) {
final boolean showing = changed.isShowing();
if(DEBUG_IMPLEMENTATION) {
- System.err.println("AWT: hierarchyChanged SHOWING_CHANGED: showing "+showing+", "+changed);
+ System.err.println("AWT: hierarchyChanged SHOWING_CHANGED: showing "+showing+", "+changed+", source "+e.getComponent());
}
getNewtWindow().runOnEDTIfAvail(false, new Runnable() {
public void run() {
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
index 277f7e6b9..4570abbfa 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java
@@ -46,10 +46,11 @@ import javax.media.nativewindow.util.PointImmutable;
import jogamp.newt.WindowImpl;
import jogamp.newt.driver.DriverClearFocus;
+import jogamp.newt.driver.DriverUpdatePosition;
import com.jogamp.newt.event.KeyEvent;
-public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverClearFocus {
+public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverClearFocus, DriverUpdatePosition {
static {
MacDisplay.initSingleton();
@@ -152,8 +153,21 @@ public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverCl
}
}
+ public void updatePosition() {
+ final Point pS = getLocationOnScreenImpl(getX(), getY());
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("MacWindow: updatePosition() - isOffscreenInstance "+isOffscreenInstance+", new abs pos: pS "+pS);
+ }
+ if( !isOffscreenInstance ) {
+ setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY());
+ } // else no offscreen position
+ // no native event (fullscreen, some reparenting)
+ positionChanged(true, pS);
+ }
+
+
protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {
- final PointImmutable pS = position2TopLevel(new Point(x, y));
+ final Point pS = getLocationOnScreenImpl(x, y);
isOffscreenInstance = 0 != sscSurfaceHandle || isOffscreenInstance(this, this.getParent());
if(DEBUG_IMPLEMENTATION) {
@@ -162,57 +176,65 @@ public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverCl
", "+getReconfigureFlagsAsString(null, flags));
}
- if( getWindowHandle() == 0 ) {
- if( 0 != ( FLAG_IS_VISIBLE & flags) ) {
- createWindow(isOffscreenInstance, false, pS, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags));
- // no native event ..
- visibleChanged(true, true);
- } /* else { ?? } */
- } else {
- if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) {
- if ( !isOffscreenInstance ) {
- orderOut0(getWindowHandle());
- }
- // no native event ..
- visibleChanged(true, false);
- }
- if( 0 != ( FLAG_CHANGE_DECORATION & flags) ||
- 0 != ( FLAG_CHANGE_PARENTING & flags) ||
- 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) {
- createWindow(isOffscreenInstance, true, pS, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags));
- if(isVisible()) { flags |= FLAG_CHANGE_VISIBILITY; }
- }
- if(x>=0 && y>=0) {
- if( !isOffscreenInstance ) {
- setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY());
- } // else no offscreen position
- // no native event (fullscreen, some reparenting)
- positionChanged(true, getLocationOnScreenImpl(0, 0)); // incl. validation
- }
- if(width>0 && height>0) {
- if( !isOffscreenInstance ) {
- setContentSize0(getWindowHandle(), width, height);
- } // else offscreen size is realized via recreation
- // no native event (fullscreen, some reparenting)
- sizeChanged(true, width, height, false); // incl. validation (incl. repositioning)
+ if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) {
+ if ( !isOffscreenInstance ) {
+ orderOut0(getWindowHandle());
}
- if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 != ( FLAG_IS_VISIBLE & flags) ) {
- if( !isOffscreenInstance ) {
- orderFront0(getWindowHandle());
- }
- // no native event ..
- visibleChanged(true, true);
- }
+ // no native event ..
+ visibleChanged(true, false);
+ }
+ if( 0 == getWindowHandle() && 0 != ( FLAG_IS_VISIBLE & flags) ||
+ 0 != ( FLAG_CHANGE_DECORATION & flags) ||
+ 0 != ( FLAG_CHANGE_PARENTING & flags) ||
+ 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) {
+ createWindow(isOffscreenInstance, 0 != getWindowHandle(), pS, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags));
+ if(isVisible()) { flags |= FLAG_CHANGE_VISIBILITY; }
+ }
+ if(x>=0 && y>=0) {
+ if( !isOffscreenInstance ) {
+ setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY());
+ } // else no offscreen position
+ // no native event (fullscreen, some reparenting)
+ positionChanged(true, pS); // incl. validation
+ }
+ if(width>0 && height>0) {
+ if( !isOffscreenInstance ) {
+ setContentSize0(getWindowHandle(), width, height);
+ } // else offscreen size is realized via recreation
+ // no native event (fullscreen, some reparenting)
+ sizeChanged(true, width, height, false); // incl. validation (incl. repositioning)
+ }
+ if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 != ( FLAG_IS_VISIBLE & flags) ) {
if( !isOffscreenInstance ) {
- setAlwaysOnTop0(getWindowHandle(), 0 != ( FLAG_IS_ALWAYSONTOP & flags));
+ orderFront0(getWindowHandle());
}
+ // no native event ..
+ visibleChanged(true, true);
+ }
+ if( !isOffscreenInstance ) {
+ setAlwaysOnTop0(getWindowHandle(), 0 != ( FLAG_IS_ALWAYSONTOP & flags));
}
return true;
}
protected Point getLocationOnScreenImpl(int x, int y) {
- return position2TopLevel(new Point(x, y)); // allows offscreen ..
- // return (Point) getLocationOnScreen0(getWindowHandle(), x, y);
+ Point p = new Point(x, y);
+ if(0<=p.getX() && 0<=p.getY()) {
+ final InsetsImmutable _insets = getInsets(); // zero if undecorated
+ // client position -> top-level window position
+ p.setX(p.getX() - _insets.getLeftWidth()) ;
+ p.setY(p.getY() - _insets.getTopHeight()) ;
+ }
+ // min val is 0
+ p.setX(Math.max(p.getX(), 0));
+ p.setY(Math.max(p.getY(), 0));
+
+ final NativeWindow parent = getParent();
+ if( null != parent && 0 != parent.getWindowHandle() ) {
+ final Point plos = parent.getLocationOnScreen(null);
+ p.translate(plos);
+ }
+ return p;
}
protected void updateInsetsImpl(Insets insets) {
@@ -222,7 +244,7 @@ public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverCl
@Override
protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) {
if(width != newWidth || height != newHeight) {
- final Point p0S = position2TopLevel(new Point(x, y));
+ final Point p0S = getLocationOnScreenImpl(x, y);
setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), p0S.getX(), p0S.getY());
}
super.sizeChanged(defer, newWidth, newHeight, force);
@@ -320,8 +342,6 @@ public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverCl
orderOut0(0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle());
} else {
setTitle0(getWindowHandle(), getTitle());
- // need to revalidate real position
- positionChanged(true, getLocationOnScreenImpl(0, 0)); // incl. validation
}
} catch (Exception ie) {
ie.printStackTrace();
@@ -343,25 +363,6 @@ public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverCl
return absPos;
}
- private Point position2TopLevel(Point clientPos) {
- if(0<=clientPos.getX() && 0<=clientPos.getY()) {
- final InsetsImmutable _insets = getInsets(); // zero if undecorated
- // client position -> top-level window position
- clientPos.setX(clientPos.getX() - _insets.getLeftWidth()) ;
- clientPos.setY(clientPos.getY() - _insets.getTopHeight()) ;
- }
- // min val is 0
- clientPos.setX(Math.max(clientPos.getX(), 0));
- clientPos.setY(Math.max(clientPos.getY(), 0));
- // On MacOSX the absolute position is required to position
- // a window - even a child window!
- final NativeWindow parent = getParent();
- if( null != parent && 0 != parent.getWindowHandle() ) {
- clientPos.translate(parent.getLocationOnScreen(null));
- }
- return clientPos;
- }
-
protected static native boolean initIDs0();
private native long createWindow0(long parentWindowHandle, int x, int y, int w, int h,
boolean opaque, boolean fullscreen, int windowStyle,
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java
index 39759de9f..da689cea6 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java
@@ -118,7 +118,8 @@ public class TestParenting02AWT extends UITestCase {
}
}
- frame.setSize(width, height);
+ // frame.setSize(width, height);
+ frame.setBounds(100, 100, width, height);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {