diff options
Diffstat (limited to 'src/newt/classes/jogamp')
3 files changed, 90 insertions, 33 deletions
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(..) } |