diff options
Diffstat (limited to 'src')
3 files changed, 57 insertions, 11 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSizePos.java b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSizePos.java new file mode 100644 index 000000000..e6fcc049c --- /dev/null +++ b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSizePos.java @@ -0,0 +1,36 @@ +package com.jogamp.nativewindow; + +public class UpstreamSurfaceHookMutableSizePos extends UpstreamSurfaceHookMutableSize { + int x, y; + + /** + * @param width initial width + * @param height initial height + */ + public UpstreamSurfaceHookMutableSizePos(int x, int y, int width, int height) { + super(width, height); + this.x= x; + this.y= y; + } + + // @Override + public final void setPos(int x, int y) { + this.x= x; + this.y= y; + } + + public final int getX() { + return x; + } + + public final int getY() { + return y; + } + + @Override + public String toString() { + return getClass().getSimpleName()+"[ "+ x + "/" + y + " " + width + "x" + height + "]"; + } + +} + diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 7c491a9ee..15a43cff8 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -57,7 +57,7 @@ import jogamp.nativewindow.x11.X11Lib; import com.jogamp.common.os.Platform; import com.jogamp.common.util.ReflectionUtil; -import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSizePos; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; @@ -662,7 +662,7 @@ public abstract class NativeWindowFactory { /** * Creates a wrapped {@link NativeWindow} with given native handles and {@link AbstractGraphicsScreen}. * <p> - * The given {@link UpstreamSurfaceHookMutableSize} maybe used to reflect resizes of the native window. + * The given {@link UpstreamSurfaceHookMutableSizePos} maybe used to reflect resizes and repositioning of the native window. * </p> * <p> * The {@link AbstractGraphicsScreen} may be created via {@link #createScreen(AbstractGraphicsDevice, int)}. @@ -673,7 +673,7 @@ public abstract class NativeWindowFactory { * </p> */ public static NativeWindow createWrappedWindow(AbstractGraphicsScreen aScreen, long surfaceHandle, long windowHandle, - UpstreamSurfaceHookMutableSize hook) { + UpstreamSurfaceHookMutableSizePos hook) { final CapabilitiesImmutable caps = new Capabilities(); final AbstractGraphicsConfiguration config = new DefaultGraphicsConfiguration(aScreen, caps, caps); return new WrappedWindow(config, surfaceHandle, hook, true, windowHandle); diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java index d5a977240..edb65eb06 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedWindow.java @@ -9,25 +9,28 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSizePos; + public class WrappedWindow extends WrappedSurface implements NativeWindow { - private final long windowHandle; private final InsetsImmutable insets = new Insets(0, 0, 0, 0); + private long windowHandle; /** - * Utilizes a {@link UpstreamSurfaceHook.MutableSize} to hold the size information, + * Utilizes a {@link UpstreamSurfaceHookMutableSizePos} to hold the size and postion information, * which is being passed to the {@link ProxySurface} instance. * * @param cfg the {@link AbstractGraphicsConfiguration} to be used * @param surfaceHandle the wrapped pre-existing native surface handle, maybe 0 if not yet determined + * @param initialX + * @param initialY * @param initialWidth * @param initialHeight * @param ownsDevice <code>true</code> if this {@link ProxySurface} instance * owns the {@link AbstractGraphicsConfiguration}'s {@link AbstractGraphicsDevice}, * otherwise <code>false</code>. Owning the device implies closing it at {@link #destroyNotify()}. */ - public WrappedWindow(AbstractGraphicsConfiguration cfg, long surfaceHandle, int initialWidth, int initialHeight, boolean ownsDevice, long windowHandle) { - super(cfg, surfaceHandle, initialWidth, initialHeight, ownsDevice); - this.windowHandle = windowHandle; + public WrappedWindow(AbstractGraphicsConfiguration cfg, long surfaceHandle, int initialX, int initialY, int initialWidth, int initialHeight, boolean ownsDevice, long windowHandle) { + this(cfg, surfaceHandle, new UpstreamSurfaceHookMutableSizePos(initialX, initialY, initialWidth, initialHeight), ownsDevice, windowHandle); } /** @@ -38,13 +41,20 @@ public class WrappedWindow extends WrappedSurface implements NativeWindow { * owns the {@link AbstractGraphicsConfiguration}'s {@link AbstractGraphicsDevice}, * otherwise <code>false</code>. */ - public WrappedWindow(AbstractGraphicsConfiguration cfg, long surfaceHandle, UpstreamSurfaceHook upstream, boolean ownsDevice, long windowHandle) { + public WrappedWindow(AbstractGraphicsConfiguration cfg, long surfaceHandle, UpstreamSurfaceHookMutableSizePos upstream, boolean ownsDevice, long windowHandle) { super(cfg, surfaceHandle, upstream, ownsDevice); this.windowHandle = windowHandle; } @Override + protected void invalidateImpl() { + super.invalidateImpl(); + windowHandle = 0; + } + + @Override public void destroy() { + destroyNotify(); } @Override @@ -64,12 +74,12 @@ public class WrappedWindow extends WrappedSurface implements NativeWindow { @Override public int getX() { - return 0; + return ((UpstreamSurfaceHookMutableSizePos)getUpstreamSurfaceHook()).getX(); } @Override public int getY() { - return 0; + return ((UpstreamSurfaceHookMutableSizePos)getUpstreamSurfaceHook()).getY(); } @Override |