summaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-02-22 04:09:03 +0100
committerSven Gothel <[email protected]>2013-02-22 04:09:03 +0100
commitaf384debfdf354d98e3d0d0c6e0c5cf5a967904e (patch)
tree8c8d9cdb4ba104888434a65c6a0b628d3a51a1b5 /src/newt
parentcbd8e33f1e19cf0c061c371af6930aba7c36b84f (diff)
NEWT/OSX Fix: Child positioning ; NewtCanvasAWT: Change reparent time and use actual component size while setting min/pref. size at setup
- NEWT/OSX Fix: Child positioning - If !Offscreen and has-parent: Gather screen location by traversing through parent and set native position (was removed w/ commit 7d5c51b635e0795d9b170342bdebe8e7e0bbd01d since still buggy). - NewtCanvasAWT: Change reparent time and use actual component size while setting min/pref. size at setup - Analog to AWT GLCanvas - validates and reparents at reshape(..), paint(..) and update(..) - reshape(..) also trigers jawtWindow.layoutSurfaceLayer() -
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java388
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java62
-rw-r--r--src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java59
4 files changed, 306 insertions, 205 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 524917780..3503dabd5 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -34,6 +34,7 @@ import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.KeyboardFocusManager;
+import java.beans.Beans;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Method;
@@ -84,6 +85,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
private JAWTWindow jawtWindow = null;
private boolean shallUseOffscreenLayer = false;
private Window newtChild = null;
+ private boolean newtChildAttached = false;
private boolean isOnscreen = true;
private WindowClosingMode newtChildCloseOp;
private AWTAdapter awtAdapter = null;
@@ -181,6 +183,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() {
@Override
+ public void windowResized(WindowEvent e) {
+ updateLayoutSize();
+ }
+ @Override
public void windowGainedFocus(WindowEvent arg0) {
if( isParent() && !isFullscreen() ) {
MenuSelectionManager.defaultManager().clearSelectedPath();
@@ -292,16 +298,26 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
final java.awt.Container cont = AWTMisc.getContainer(this);
// remove old one
if(null != newtChild) {
- reparentWindow( false, cont );
+ detachNewtChild( cont );
newtChild = null;
}
// add new one, reparent only if ready
newtChild = newChild;
- if( isDisplayable() && null != newChild) {
- reparentWindow( true, cont );
- }
+
+ updateLayoutSize();
+ // will be done later at paint/display/..: attachNewtChild(cont);
+
return prevChild;
}
+
+ private final void updateLayoutSize() {
+ if( null != newtChild ) {
+ // use NEWT child's size for min/pref size!
+ java.awt.Dimension minSize = new java.awt.Dimension(newtChild.getWidth(), newtChild.getHeight());
+ setMinimumSize(minSize);
+ setPreferredSize(minSize);
+ }
+ }
/** @return the current NEWT child */
public Window getNEWTChild() {
@@ -320,166 +336,54 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
return awtWindowClosingProtocol.setDefaultCloseOperation(op);
}
- /* package */ void configureNewtChild(boolean attach) {
- if(null!=awtAdapter) {
- awtAdapter.removeFrom(this);
- awtAdapter=null;
- }
- if(null!=awtMouseAdapter) {
- awtMouseAdapter.removeFrom(this);
- awtMouseAdapter = null;
- }
- if(null!=awtKeyAdapter) {
- awtKeyAdapter.removeFrom(this);
- awtKeyAdapter = null;
- }
- if(null != keyboardFocusManager) {
- keyboardFocusManager.removePropertyChangeListener("focusOwner", focusPropertyChangeListener);
- keyboardFocusManager = null;
- }
-
- if( null != newtChild ) {
- newtChild.setKeyboardFocusHandler(null);
- if(attach) {
- if(null == jawtWindow.getGraphicsConfiguration()) {
- throw new InternalError("XXX");
- }
- isOnscreen = jawtWindow.getGraphicsConfiguration().getChosenCapabilities().isOnscreen();
- awtAdapter = new AWTParentWindowAdapter(jawtWindow, newtChild).addTo(this);
- newtChild.addWindowListener(clearAWTMenusOnNewtFocus);
- newtChild.setFocusAction(focusAction); // enable AWT focus traversal
- newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE);
- awtWindowClosingProtocol.addClosingListenerOneShot();
- keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
- keyboardFocusManager.addPropertyChangeListener("focusOwner", focusPropertyChangeListener);
- if(isOnscreen) {
- // onscreen newt child needs to fwd AWT focus
- newtChild.setKeyboardFocusHandler(newtFocusTraversalKeyListener);
- } else {
- // offscreen newt child requires AWT to fwd AWT key/mouse event
- awtMouseAdapter = new AWTMouseAdapter(newtChild).addTo(this);
- awtKeyAdapter = new AWTKeyAdapter(newtChild).addTo(this);
- }
- } else {
- newtChild.removeWindowListener(clearAWTMenusOnNewtFocus);
- newtChild.setFocusAction(null);
- newtChild.setDefaultCloseOperation(newtChildCloseOp);
- awtWindowClosingProtocol.removeClosingListener();
- }
- }
- }
-
@Override
public void addNotify() {
-
- // before native peer is valid: X11
- disableBackgroundErase();
-
- // creates the native peer
- super.addNotify();
-
- // after native peer is valid: Windows
- disableBackgroundErase();
-
- java.awt.Container cont = AWTMisc.getContainer(this);
- if(DEBUG) {
- // if ( isShowing() == false ) -> Container was not visible yet.
- // if ( isShowing() == true ) -> Container is already visible.
- System.err.println("NewtCanvasAWT.addNotify: "+newtChild+", "+this+", visible "+isVisible()+", showing "+isShowing()+
- ", displayable "+isDisplayable()+" -> "+cont);
+ if( Beans.isDesignTime() ) {
+ super.addNotify();
+ } else {
+ // before native peer is valid: X11
+ disableBackgroundErase();
+
+ // creates the native peer
+ super.addNotify();
+
+ // after native peer is valid: Windows
+ disableBackgroundErase();
+
+ jawtWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities());
+ jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer);
+
+ if(DEBUG) {
+ // if ( isShowing() == false ) -> Container was not visible yet.
+ // if ( isShowing() == true ) -> Container is already visible.
+ System.err.println("NewtCanvasAWT.addNotify: win "+newtWinHandleToHexString(newtChild)+
+ ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+
+ ", displayable "+isDisplayable()+", cont "+AWTMisc.getContainer(this));
+ }
}
- reparentWindow(true, cont);
}
- @SuppressWarnings("deprecation")
- @Override
- public void reshape(int x, int y, int width, int height) {
- super.reshape(x, y, width, height);
- if(DEBUG) {
- System.err.println("NewtCanvasAWT.reshape: "+x+"/"+y+" "+width+"x"+height);
- }
- if(null != jawtWindow && jawtWindow.isOffscreenLayerSurfaceEnabled() ) {
- jawtWindow.layoutSurfaceLayer();
- }
- }
-
@Override
public void removeNotify() {
- java.awt.Container cont = AWTMisc.getContainer(this);
- if(DEBUG) {
- System.err.println("NewtCanvasAWT.removeNotify: "+newtChild+", from "+cont);
- }
- // Detach OLS early..
- final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true);
- if(null != ols && ols.isSurfaceLayerAttached()) {
- ols.detachSurfaceLayer();
- }
- reparentWindow(false, cont); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached)
-
- if(null != jawtWindow) {
+ if( Beans.isDesignTime() ) {
+ super.removeNotify();
+ } else {
+ java.awt.Container cont = AWTMisc.getContainer(this);
+ if(DEBUG) {
+ System.err.println("NewtCanvasAWT.removeNotify: "+newtChild+", from "+cont);
+ }
+ // Detach OLS early..
+ final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true);
+ if(null != ols && ols.isSurfaceLayerAttached()) {
+ ols.detachSurfaceLayer();
+ }
+ detachNewtChild(cont); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached)
+
NewtFactoryAWT.destroyNativeWindow(jawtWindow);
jawtWindow=null;
+
+ super.removeNotify();
}
-
- super.removeNotify();
- }
-
- void reparentWindow(boolean add, java.awt.Container cont) {
- if(null==newtChild) {
- return; // nop
- }
- if(DEBUG) {
- System.err.println("NewtCanvasAWT.reparentWindow.0: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil());
- }
-
- newtChild.setFocusAction(null); // no AWT focus traversal ..
- if(add) {
- if(DEBUG) {
- System.err.println("NewtCanvasAWT.reparentWindow: newtChild: "+newtChild);
- }
- if(null == jawtWindow) {
- jawtWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities());
- jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer);
- }
- final int w;
- final int h;
- if(isPreferredSizeSet()) {
- // 1st: Component's PreferedSize
- java.awt.Dimension d = getPreferredSize();
- w = d.width;
- h = d.height;
- } else {
- final java.awt.Dimension min1, min2;
- // 2nd: Component's Max( Max( comp.min, newt.size ), cont.size )
- if(this.isMinimumSizeSet()) {
- min1 = getMinimumSize();
- } else {
- min1 = new java.awt.Dimension(0, 0);
- }
- min2 = new java.awt.Dimension( Math.max( min1.width, newtChild.getWidth() ),
- Math.max( min1.height, newtChild.getHeight() ) );
- java.awt.Insets ins = cont.getInsets();
- w = Math.max(min2.width, cont.getWidth() - ins.left - ins.right);
- h = Math.max(min2.height, cont.getHeight() - ins.top - ins.bottom);
- }
- setSize(w, h);
- newtChild.setSize(w, h);
- newtChild.reparentWindow(jawtWindow);
- newtChild.setVisible(true);
- configureNewtChild(true);
- newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener
-
- // force this AWT Canvas to be focus-able,
- // since this it is completely covered by the newtChild (z-order).
- setFocusable(true);
- } else {
- configureNewtChild(false);
- newtChild.setVisible(false);
- newtChild.reparentWindow(null);
- }
- if(DEBUG) {
- System.err.println("NewtCanvasAWT.reparentWindow.X: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil());
- }
}
/**
@@ -489,46 +393,56 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
* <li> Disconnects the NEWT Child from this Canvas NativeWindow, reparent to NULL </li>
* <li> Issues <code>destroy()</code> on the NEWT Child</li>
* <li> Remove reference to the NEWT Child</li>
- * <li> Remove this Canvas from it's parent.</li>
* </ul>
* @see Window#destroy()
*/
public final void destroy() {
- if(null!=newtChild) {
+ if( null !=newtChild ) {
java.awt.Container cont = AWTMisc.getContainer(this);
if(DEBUG) {
System.err.println("NewtCanvasAWT.destroy(): "+newtChild+", from "+cont);
}
- configureNewtChild(false);
- if(null!=jawtWindow) {
- NewtFactoryAWT.destroyNativeWindow(jawtWindow);
- jawtWindow=null;
- }
- newtChild.setVisible(false);
- newtChild.reparentWindow(null);
+ // Detach OLS early..
+ final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true);
+ if(null != ols && ols.isSurfaceLayerAttached()) {
+ ols.detachSurfaceLayer();
+ }
+ detachNewtChild(cont); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached)
newtChild.destroy();
newtChild=null;
- if(null!=cont) {
- cont.remove(this);
- }
}
- }
-
+ }
+
@Override
public void paint(Graphics g) {
- awtWindowClosingProtocol.addClosingListenerOneShot();
- if(null!=newtChild) {
+ if( validateComponent(true, null) ) {
newtChild.windowRepaint(0, 0, getWidth(), getHeight());
}
}
@Override
public void update(Graphics g) {
- awtWindowClosingProtocol.addClosingListenerOneShot();
- if(null!=newtChild) {
+ if( validateComponent(true, null) ) {
newtChild.windowRepaint(0, 0, getWidth(), getHeight());
}
}
+ @SuppressWarnings("deprecation")
+ @Override
+ public void reshape(int x, int y, int width, int height) {
+ synchronized (getTreeLock()) { // super.reshape(..) claims tree lock, so we do extend it's lock over reshape
+ super.reshape(x, y, width, height);
+ if(DEBUG) {
+ System.err.println("NewtCanvasAWT.reshape: "+x+"/"+y+" "+width+"x"+height);
+ }
+ if( validateComponent(true, null) ) {
+ // newtChild.setSize(width, height);
+ if(null != jawtWindow && jawtWindow.isOffscreenLayerSurfaceEnabled() ) {
+ jawtWindow.layoutSurfaceLayer();
+ }
+ }
+ }
+ }
+
private final void requestFocusNEWTChild() {
if(null!=newtChild) {
newtChild.setFocusAction(null);
@@ -573,6 +487,136 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
return res;
}
+ private final boolean validateComponent(boolean attachNewtChild, java.awt.Container cont) {
+ if( Beans.isDesignTime() || !isDisplayable() ) {
+ return false;
+ }
+ if ( null == newtChild || null == jawtWindow ) {
+ return false;
+ }
+ if( null == cont ) {
+ cont = AWTMisc.getContainer(this);
+ }
+ if( 0 >= getWidth() || 0 >= getHeight() ) {
+ return false;
+ }
+
+ awtWindowClosingProtocol.addClosingListenerOneShot();
+
+ if( attachNewtChild && !newtChildAttached && null != newtChild ) {
+ attachNewtChild(cont);
+ }
+
+ return true;
+ }
+
+ private final void configureNewtChild(boolean attach) {
+ if(null!=awtAdapter) {
+ awtAdapter.removeFrom(this);
+ awtAdapter=null;
+ }
+ if(null!=awtMouseAdapter) {
+ awtMouseAdapter.removeFrom(this);
+ awtMouseAdapter = null;
+ }
+ if(null!=awtKeyAdapter) {
+ awtKeyAdapter.removeFrom(this);
+ awtKeyAdapter = null;
+ }
+ if(null != keyboardFocusManager) {
+ keyboardFocusManager.removePropertyChangeListener("focusOwner", focusPropertyChangeListener);
+ keyboardFocusManager = null;
+ }
+
+ if( null != newtChild ) {
+ newtChild.setKeyboardFocusHandler(null);
+ if(attach) {
+ if(null == jawtWindow.getGraphicsConfiguration()) {
+ throw new InternalError("XXX");
+ }
+ isOnscreen = jawtWindow.getGraphicsConfiguration().getChosenCapabilities().isOnscreen();
+ awtAdapter = new AWTParentWindowAdapter(jawtWindow, newtChild).addTo(this);
+ newtChild.addWindowListener(clearAWTMenusOnNewtFocus);
+ newtChild.setFocusAction(focusAction); // enable AWT focus traversal
+ newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE);
+ awtWindowClosingProtocol.addClosingListenerOneShot();
+ keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ keyboardFocusManager.addPropertyChangeListener("focusOwner", focusPropertyChangeListener);
+ if(isOnscreen) {
+ // onscreen newt child needs to fwd AWT focus
+ newtChild.setKeyboardFocusHandler(newtFocusTraversalKeyListener);
+ } else {
+ // offscreen newt child requires AWT to fwd AWT key/mouse event
+ awtMouseAdapter = new AWTMouseAdapter(newtChild).addTo(this);
+ awtKeyAdapter = new AWTKeyAdapter(newtChild).addTo(this);
+ }
+ } else {
+ newtChild.removeWindowListener(clearAWTMenusOnNewtFocus);
+ newtChild.setFocusAction(null);
+ newtChild.setDefaultCloseOperation(newtChildCloseOp);
+ awtWindowClosingProtocol.removeClosingListener();
+ }
+ }
+ }
+
+ private final void attachNewtChild(java.awt.Container cont) {
+ if( null == newtChild || null == jawtWindow || newtChildAttached ) {
+ return; // nop
+ }
+ if(DEBUG) {
+ // if ( isShowing() == false ) -> Container was not visible yet.
+ // if ( isShowing() == true ) -> Container is already visible.
+ System.err.println("NewtCanvasAWT.attachNewtChild.0: win "+newtWinHandleToHexString(newtChild)+
+ ", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+
+ ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+", displayable "+isDisplayable()+
+ ", cont "+cont);
+ }
+
+ newtChildAttached = true;
+ newtChild.setFocusAction(null); // no AWT focus traversal ..
+ if(DEBUG) {
+ System.err.println("NewtCanvasAWT.attachNewtChild.1: newtChild: "+newtChild);
+ }
+ final int w = getWidth();
+ final int h = getHeight();
+ System.err.println("NewtCanvasAWT.attachNewtChild.2: size "+w+"x"+h);
+ newtChild.setSize(w, h);
+ newtChild.reparentWindow(jawtWindow);
+ newtChild.setVisible(true);
+ configureNewtChild(true);
+ newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener
+
+ // force this AWT Canvas to be focus-able,
+ // since this it is completely covered by the newtChild (z-order).
+ setFocusable(true);
+ if(DEBUG) {
+ System.err.println("NewtCanvasAWT.attachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this);
+ }
+ }
+
+ private final void detachNewtChild(java.awt.Container cont) {
+ if( null == newtChild || null == jawtWindow || !newtChildAttached ) {
+ return; // nop
+ }
+ if(DEBUG) {
+ // if ( isShowing() == false ) -> Container was not visible yet.
+ // if ( isShowing() == true ) -> Container is already visible.
+ System.err.println("NewtCanvasAWT.detachNewtChild.0: win "+newtWinHandleToHexString(newtChild)+
+ ", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+
+ ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+", displayable "+isDisplayable()+
+ ", cont "+cont);
+ }
+
+ newtChildAttached = false;
+ newtChild.setFocusAction(null); // no AWT focus traversal ..
+ configureNewtChild(false);
+ newtChild.setVisible(false);
+ newtChild.reparentWindow(null);
+ if(DEBUG) {
+ System.err.println("NewtCanvasAWT.detachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this);
+ }
+ }
+
// Disables the AWT's erasing of this Canvas's background on Windows
// in Java SE 6. This internal API is not available in previous
// releases, but the system property
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 73c0d2754..222a1173c 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -527,9 +527,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
protected void setTitleImpl(String title) {}
/**
- * Return screen coordinates of the given coordinates
- * or null, in which case a NativeWindow traversal shall being used
+ * Translates the given window client-area coordinates with top-left origin
+ * to screen coordinates.
+ * <p>
+ * Since the position reflects the client area, it does not include the insets.
+ * </p>
+ * <p>
+ * May return <code>null</code>, in which case the caller shall traverse through the NativeWindow tree
* as demonstrated in {@link #getLocationOnScreen(javax.media.nativewindow.util.Point)}.
+ * </p>
*
* @return if not null, the screen location of the given coordinates
*/
@@ -644,14 +650,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// public final void destroy() - see below
+ @Override
public final NativeWindow getParent() {
return parentWindow;
}
+ @Override
public final long getWindowHandle() {
return windowHandle;
}
+ @Override
public Point getLocationOnScreen(Point storage) {
if(isNativeValid()) {
Point d;
@@ -688,14 +697,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// Window
//
+ @Override
public final boolean isNativeValid() {
return 0 != windowHandle ;
}
+ @Override
public final Screen getScreen() {
return screen;
}
-
+
protected final void setVisibleImpl(boolean visible, int x, int y, int width, int height) {
reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, visible));
}
@@ -778,7 +789,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
runOnEDTIfAvail(wait, new VisibleAction(visible));
}
-
+
+ @Override
public void setVisible(boolean visible) {
setVisible(true, visible);
}
@@ -830,9 +842,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
+ @Override
public void setSize(int width, int height) {
runOnEDTIfAvail(true, new SetSizeAction(width, height));
}
+ @Override
public void setTopLevelSize(int width, int height) {
setSize(width - getInsets().getTotalWidth(), height - getInsets().getTotalHeight());
}
@@ -932,6 +946,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
private final DestroyAction destroyAction = new DestroyAction();
+ @Override
public void destroy() {
visible = false; // Immediately mark synchronized visibility flag, avoiding possible recreation
runOnEDTIfAvail(true, destroyAction);
@@ -1253,6 +1268,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
private final ReparentActionRecreate reparentActionRecreate = new ReparentActionRecreate();
+ @Override
public final ReparentOperation reparentWindow(NativeWindow newParent) {
return reparentWindow(newParent, false);
}
@@ -1263,16 +1279,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return reparentAction.getOp();
}
+ @Override
public CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser) {
CapabilitiesChooser old = this.capabilitiesChooser;
this.capabilitiesChooser = chooser;
return old;
}
+ @Override
public final CapabilitiesImmutable getChosenCapabilities() {
return getGraphicsConfiguration().getChosenCapabilities();
}
+ @Override
public final CapabilitiesImmutable getRequestedCapabilities() {
return capsRequested;
}
@@ -1312,10 +1331,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
+ @Override
public void setUndecorated(boolean value) {
runOnEDTIfAvail(true, new DecorationAction(value));
}
+ @Override
public final boolean isUndecorated() {
return 0 != parentWindowHandle || undecorated || fullscreen ;
}
@@ -1355,17 +1376,21 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
+ @Override
public final void setAlwaysOnTop(boolean value) {
runOnEDTIfAvail(true, new AlwaysOnTopAction(value));
}
+ @Override
public final boolean isAlwaysOnTop() {
return alwaysOnTop;
}
+ @Override
public String getTitle() {
return title;
}
+ @Override
public void setTitle(String title) {
if (title == null) {
title = "";
@@ -1376,9 +1401,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
+ @Override
public boolean isPointerVisible() {
return pointerVisible;
}
+ @Override
public void setPointerVisible(boolean pointerVisible) {
if(this.pointerVisible != pointerVisible) {
boolean setVal = 0 == getWindowHandle();
@@ -1390,10 +1417,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
}
+ @Override
public boolean isPointerConfined() {
return pointerConfined;
}
+ @Override
public void confinePointer(boolean confine) {
if(this.pointerConfined != confine) {
boolean setVal = 0 == getWindowHandle();
@@ -1417,12 +1446,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
+ @Override
public void warpPointer(int x, int y) {
if(0 != getWindowHandle()) {
warpPointerImpl(x, y);
}
}
+ @Override
public final InsetsImmutable getInsets() {
if(isUndecorated()) {
return Insets.getZero();
@@ -1431,18 +1462,22 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return insets;
}
+ @Override
public final int getWidth() {
return width;
}
+ @Override
public final int getHeight() {
return height;
}
+ @Override
public final int getX() {
return x;
}
+ @Override
public final int getY() {
return y;
}
@@ -1468,10 +1503,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
this.width = width; this.height = height;
}
+ @Override
public final boolean isVisible() {
return visible;
}
+ @Override
public final boolean isFullscreen() {
return fullscreen;
}
@@ -1480,6 +1517,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// Window
//
+ @Override
+ public final Window getDelegatedWindow() {
+ return this;
+ }
+
+ //----------------------------------------------------------------------
+ // WindowImpl
+ //
+
/**
* If the implementation is capable of detecting a device change
* return true and clear the status/reason of the change.
@@ -1504,10 +1550,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return null;
}
- public final Window getDelegatedWindow() {
- return this;
- }
-
/**
* If set to true, the default value, this NEWT Window implementation will
* handle the destruction (ie {@link #destroy()} call) within {@link #windowDestroyNotify(boolean)} implementation.<br>
@@ -1517,10 +1559,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
handleDestroyNotify = b;
}
- //----------------------------------------------------------------------
- // WindowImpl
- //
-
/**
* Returns the non delegated {@link AbstractGraphicsConfiguration},
* see {@link #getGraphicsConfiguration()}. */
diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
index 747e2368e..701d9d60a 100644
--- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
+++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
@@ -98,7 +98,7 @@ public class AWTParentWindowAdapter
public void run() {
int cw = comp.getWidth();
int ch = comp.getHeight();
- if( 0 < cw * ch ) {
+ if( 0 < cw && 0 < ch ) {
if( newtWindow.getWidth() != cw || newtWindow.getHeight() != ch ) {
newtWindow.setSize(cw, ch);
if(comp.isVisible() != newtWindow.isVisible()) {
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
index f47ca327d..6e9335f08 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
@@ -41,7 +41,6 @@ import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.MutableSurface;
import javax.media.nativewindow.VisualIDHolder;
import javax.media.nativewindow.util.Insets;
-import javax.media.nativewindow.util.InsetsImmutable;
import javax.media.nativewindow.util.Point;
import javax.media.nativewindow.util.PointImmutable;
@@ -167,17 +166,36 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
@Override
public void updatePosition() {
- final Point pS = getLocationOnScreenImpl(0, 0);
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("MacWindow: updatePosition() - isOffscreenInstance "+isOffscreenInstance+", new abs pos: pS "+pS);
+ final long handle = getWindowHandle();
+ if( 0 != handle && !isOffscreenInstance ) {
+ final Point pS = getLocationOnScreenImpl(0, 0);
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("MacWindow: updatePosition() -> abs child-client-pos: "+pS);
+ }
+ setWindowClientTopLeftPoint0(handle, pS.getX(), pS.getY());
+ // no native event (fullscreen, some reparenting)
+ positionChanged(true, pS.getX(), pS.getY());
}
- if( !isOffscreenInstance ) {
- setWindowClientTopLeftPoint0(getWindowHandle(), pS.getX(), pS.getY());
- } // else no offscreen position
- // no native event (fullscreen, some reparenting)
- positionChanged(true, pS.getX(), pS.getY());
}
+ @Override
+ protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) {
+ final long handle = getWindowHandle();
+ if( 0 != handle && !isOffscreenInstance ) {
+ final NativeWindow parent = getParent();
+ final boolean useParent = null != parent && 0 != parent.getWindowHandle() ;
+ if( useParent && ( getWidth() != newWidth || getHeight() != newHeight ) ) {
+ final Point p0S = getLocationOnScreenImpl(0, 0);
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("MacWindow: sizeChanged() "+newWidth+"x"+newHeight+" -> abs child-client-pos "+p0S);
+ }
+ setWindowClientTopLeftPoint0(getWindowHandle(), p0S.getX(), p0S.getY());
+ }
+ }
+ super.sizeChanged(defer, newWidth, newHeight, force);
+ }
+
+ @Override
protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {
final boolean _isOffscreenInstance = isOffscreenInstance(this, this.getParent());
isOffscreenInstance = 0 != sscSurfaceHandle || _isOffscreenInstance;
@@ -185,7 +203,13 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
if( isOffscreenInstance ) {
pClientLevelOnSreen = new Point(0, 0);
} else {
- pClientLevelOnSreen = new Point(x, y);
+ final NativeWindow parent = getParent();
+ final boolean useParent = null != parent && 0 != parent.getWindowHandle() ;
+ if( useParent ) {
+ pClientLevelOnSreen = getLocationOnScreenImpl(x, y);
+ } else {
+ pClientLevelOnSreen = new Point(x, y);
+ }
}
if(DEBUG_IMPLEMENTATION) {
@@ -200,6 +224,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
", ioi: "+_isOffscreenInstance+
") -> "+isOffscreenInstance+
"\n\t, "+getReconfigureFlagsAsString(null, flags));
+ Thread.dumpStack();
}
if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) {
@@ -240,11 +265,12 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
setAlwaysOnTop0(getWindowHandle(), 0 != ( FLAG_IS_ALWAYSONTOP & flags));
}
if(DEBUG_IMPLEMENTATION) {
- System.err.println("MacWindow reconfig.X: clientPos "+pClientLevelOnSreen+", "+width+"x"+height+" -> clientPos "+getLocationOnScreenImpl(0, 0)+", topPos "+getTopLevelLocationOnScreen(0, 0)+", insets: "+getInsets());
+ System.err.println("MacWindow reconfig.X: clientPos "+pClientLevelOnSreen+", "+width+"x"+height+" -> clientPos "+getLocationOnScreenImpl(0, 0)+", insets: "+getInsets());
}
return true;
}
+ @Override
protected Point getLocationOnScreenImpl(int x, int y) {
final NativeWindow parent = getParent();
final boolean useParent = null != parent && 0 != parent.getWindowHandle() ;
@@ -262,15 +288,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
}
return p;
}
-
- private Point getTopLevelLocationOnScreen(int x, int y) {
- final InsetsImmutable _insets = getInsets(); // zero if undecorated
- // client position -> top-level window position
- x -= _insets.getLeftWidth() ;
- y -= _insets.getTopHeight() ;
- return getLocationOnScreenImpl(x, y);
- }
-
+
+ @Override
protected void updateInsetsImpl(Insets insets) {
// nop - using event driven insetsChange(..)
}