diff options
Diffstat (limited to 'src/newt')
22 files changed, 405 insertions, 252 deletions
diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java index 299bb1f73..b918d092d 100644 --- a/src/newt/classes/jogamp/newt/OffscreenWindow.java +++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java @@ -57,7 +57,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { static long nextWindowHandle = 0x100; // start here - a marker @Override - protected void createNativeImpl() { + protected void createNativeImpl(boolean[] positionModified) { if(capsRequested.isOnscreen()) { throw new NativeWindowException("Capabilities is onscreen"); } @@ -122,7 +122,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { @Override protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) { - sizeChanged(false, width, height, false); + sizeChanged(false, true /* windowUnits */, width, height, false); if( 0 != ( CHANGE_MASK_VISIBILITY & flags) ) { visibleChanged(0 != ( STATE_MASK_VISIBLE & flags)); } else { diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 67f1e863b..4bdbc3272 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -68,6 +68,7 @@ import jogamp.nativewindow.SurfaceUpdatedHelper; import com.jogamp.common.ExceptionUtils; import com.jogamp.common.util.ArrayHashSet; import com.jogamp.common.util.Bitfield; +import com.jogamp.common.util.InterruptSource; import com.jogamp.common.util.PropertyAccess; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.locks.LockFactory; @@ -88,6 +89,7 @@ import com.jogamp.newt.event.MonitorEvent; import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseEvent.PointerType; +import com.jogamp.opengl.math.FloatUtil; import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.event.NEWTEvent; import com.jogamp.newt.event.NEWTEventConsumer; @@ -156,15 +158,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Volatile: Multithreaded Mutable Access // private volatile long windowHandle = 0; // lifecycle critical - private volatile int pixWidth = 128, pixHeight = 128; // client-area size w/o insets in pixel units, default: may be overwritten by user - private volatile int winWidth = 128, winHeight = 128; // client-area size w/o insets in window units, default: may be overwritten by user protected final float[] minPixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; protected final float[] maxPixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; protected final float[] hasPixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; protected final float[] reqPixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; + private volatile int[] pixelPos = new int[] { 64, 64 }; // client-area pos w/o insets in pixel units + private volatile int[] pixelSize = new int[] { 128, 128 }; // client-area size w/o insets in pixel units, default: may be overwritten by user + private volatile int[] windowPos = new int[] { 64, 64 }; // client-area pos w/o insets in window units + private volatile int[] windowSize = new int[] { 128, 128 }; // client-area size w/o insets in window units, default: may be overwritten by user - private volatile int x = 64, y = 64; // client-area pos w/o insets in window units - private volatile Insets insets = new Insets(); // insets of decoration (if top-level && decorated) + private volatile Insets insets = new Insets(); // insets of decoration in pixel units (if top-level && decorated) private boolean blockInsetsChange = false; // block insets change (from same thread) private final RecursiveLock windowLock = LockFactory.createRecursiveLock(); // Window instance wide lock @@ -750,7 +753,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // child window: position defaults to 0/0, no auto position, no negative position if( hasParent && ( stateMask.get(STATE_BIT_AUTOPOSITION) || 0>getX() || 0>getY() ) ) { - definePosition(0, 0); + defineWindowPosition(0, 0); } boolean postParentlockFocus = false; try { @@ -1010,7 +1013,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * * @see #getSupportedReconfigMaskImpl() * @see #sizeChanged(int,int) - * @see #positionChanged(boolean,int, int) + * @see #positionChanged(boolean,boolean, int, int) */ protected abstract boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags); @@ -1054,6 +1057,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected boolean setPointerVisibleImpl(final boolean pointerVisible) { return false; } protected boolean confinePointerImpl(final boolean confine) { return false; } + + /** + * See {@link #warpPointer(int, int) + * @param x pixel units + * @param y pixel units + */ protected void warpPointerImpl(final int x, final int y) { } protected void setPointerIconImpl(final PointerIconImpl pi) { } @@ -1841,7 +1850,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer parentWindowLocked.unlockSurface(); } } - definePosition(x, y); // position might not get updated by WM events (SWT parent apparently) + defineWindowPosition(x, y); // position might not get updated by WM events (SWT parent apparently) // set visible again if(ok) { @@ -1871,8 +1880,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(!ok || !wasVisible) { // make size and position persistent manual, // since we don't have a WM feedback (invisible or recreation) - definePosition(x, y); - defineSize(width, height); + defineWindowPosition(x, y); + defineWindowSize(width, height); } if(!ok) { @@ -1895,8 +1904,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // ACTION_NATIVE_CREATION_PENDING; // make size and position persistent for proper [re]creation - definePosition(x, y); - defineSize(width, height); + defineWindowPosition(x, y); + defineWindowSize(width, height); } if(DEBUG_IMPLEMENTATION) { @@ -2587,37 +2596,37 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final int getX() { - return x; + return windowPos[0]; } @Override public final int getY() { - return y; + return windowPos[1]; } @Override public final int getWidth() { - return winWidth; + return windowSize[0]; } @Override public final int getHeight() { - return winHeight; + return windowSize[1]; } @Override public final Rectangle getBounds() { - return new Rectangle(x, y, winWidth, winHeight); + return new Rectangle(windowPos[0], windowPos[1], windowSize[0], windowSize[1]); } @Override public final int getSurfaceWidth() { - return pixWidth; + return pixelSize[0]; } @Override public final int getSurfaceHeight() { - return pixHeight; + return pixelSize[1]; } @Override @@ -2699,32 +2708,143 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected final boolean autoPosition() { return stateMask.get(STATE_BIT_AUTOPOSITION); } - /** Sets the position fields {@link #x} and {@link #y} in window units to the given values and {@link #autoPosition} to false. */ - protected final void definePosition(final int x, final int y) { + protected final int[] getWindowPosI() { return windowPos; } + protected final int[] getPixelPosI() { return pixelPos; } + protected final int[] getWindowSizeI() { return windowSize; } + protected final int[] getPixelSizeI() { return pixelSize; } + + /** + * Sets the position in window units to the given values while computing the size in pixel units according to {@link #convertToPixelUnits(int[])}. + * Also sets {@link #autoPosition} to false. + */ + protected final void defineWindowPosition(final int newWinX, final int newWinY) { + final int[] newWindowPos = new int[] { newWinX, newWinY }; + final int[] newPixelPos = SurfaceScaleUtils.scale(new int[2], newWindowPos, hasPixelScale); + if(DEBUG_IMPLEMENTATION) { + System.err.println("defineWinPosition: win["+this.windowPos[0]+"/"+this.windowPos[1]+" -> "+newWindowPos[0]+"/"+newWindowPos[1]+ + "], pixel["+this.pixelSize[0]+"x"+this.pixelSize[1]+" -> "+newPixelPos[0]+"x"+newPixelPos[1]+"]"); + // ExceptionUtils.dumpStackTrace(System.err); + } + stateMask.clear(STATE_BIT_AUTOPOSITION); + this.windowPos = newWindowPos; + this.pixelPos = newPixelPos; + } + + /** + * Sets the position in pixel units to the given values while computing the size in window units according to {@link #convertToWindowUnits(int[])}. + * Also sets {@link #autoPosition} to false. + */ + protected final void definePixelPosition(final int newPixX, final int newPixY) { + final int[] newPixelPos = new int[] { newPixX, newPixY }; + final int[] newWindowPos = SurfaceScaleUtils.scaleInv(new int[2], newPixelPos, hasPixelScale); if(DEBUG_IMPLEMENTATION) { - System.err.println("definePosition: "+this.x+"/"+this.y+" -> "+x+"/"+y); + System.err.println("definePixelPosition: win["+this.windowPos[0]+"/"+this.windowPos[1]+" -> "+newWindowPos[0]+"/"+newWindowPos[1]+ + "], pixel["+this.pixelPos[0]+"x"+this.pixelPos[1]+" -> "+newPixelPos[0]+"x"+newPixelPos[1]+"]"); // ExceptionUtils.dumpStackTrace(System.err); } stateMask.clear(STATE_BIT_AUTOPOSITION); - this.x = x; this.y = y; + this.windowPos = newWindowPos; + this.pixelPos = newPixelPos; } /** - * Sets the size fields {@link #winWidth} and {@link #winHeight} in window units to the given values - * and {@link #pixWidth} and {@link #pixHeight} in pixel units according to {@link #convertToPixelUnits(int[])}. + * Sets the size in window units to the given values while computing the size in pixel units according to {@link #convertToPixelUnits(int[])}. */ - protected final void defineSize(final int winWidth, final int winHeight) { - // FIXME HiDPI: Shortcut, may need to adjust if we change scaling methodology - final int pixWidth = SurfaceScaleUtils.scale(winWidth, getPixelScaleX()); - final int pixHeight = SurfaceScaleUtils.scale(winHeight, getPixelScaleY()); + protected final void defineWindowSize(final int newWinWidth, final int newWinHeight) { + final int[] newWindowSize = new int[] { newWinWidth, newWinHeight }; + final int[] newPixelSize = SurfaceScaleUtils.scale(new int[2], newWindowSize, hasPixelScale); if(DEBUG_IMPLEMENTATION) { - System.err.println("defineSize: win["+this.winWidth+"x"+this.winHeight+" -> "+winWidth+"x"+winHeight+ - "], pixel["+this.pixWidth+"x"+this.pixHeight+" -> "+pixWidth+"x"+pixHeight+"]"); + System.err.println("defineWinSize: win["+this.windowSize[0]+"x"+this.windowSize[1]+" -> "+newWindowSize[0]+"x"+newWindowSize[1]+ + "], pixel["+this.pixelSize[0]+"x"+this.pixelSize[1]+" -> "+newPixelSize[0]+"x"+newPixelSize[1]+"]"); // ExceptionUtils.dumpStackTrace(System.err); } - this.winWidth = winWidth; this.winHeight = winHeight; - this.pixWidth = pixWidth; this.pixHeight = pixHeight; + this.windowSize = newWindowSize; + this.pixelSize = newPixelSize; + } + + /** + * Sets the size in pixel units to the given values while computing the size in window units according to {@link #convertToWindowUnits(int[])}. + */ + protected final void definePixelSize(final int newPixWidth, final int newPixHeight) { + final int[] newPixelSize = new int[] { newPixWidth, newPixHeight }; + final int[] newWindowSize = SurfaceScaleUtils.scaleInv(new int[2], newPixelSize, hasPixelScale); + + if(DEBUG_IMPLEMENTATION) { + System.err.println("definePixelSize: win["+this.windowSize[0]+"x"+this.windowSize[1]+" -> "+newWindowSize[0]+"x"+newWindowSize[1]+ + "], pixel["+this.pixelSize[0]+"x"+this.pixelSize[1]+" -> "+newPixelSize[0]+"x"+newPixelSize[1]+"]"); + // ExceptionUtils.dumpStackTrace(System.err); + } + this.windowSize = newWindowSize; + this.pixelSize = newPixelSize; + } + + /** + * Updates position and size in pixel units according to {@link #convertToPixelUnits(int[])}. + */ + protected void updatePixelPosSize(final boolean sendEvent, final boolean defer) { + final int[] newPixelPos = SurfaceScaleUtils.scale(new int[2], windowPos, hasPixelScale); + final int[] newPixelSize = SurfaceScaleUtils.scale(new int[2], windowSize, hasPixelScale); + final boolean posChanged = pixelPos[0] != newPixelPos[0] || pixelPos[1] != newPixelPos[1]; + final boolean sizeChanged = pixelSize[0] != newPixelSize[0] || pixelSize[1] != newPixelSize[1]; + if( posChanged || sizeChanged ) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("updatePixelPosSize: ("+getThreadName()+"): (event: "+sendEvent+", defer: "+defer+"), state "+getStateMaskString()+ + " - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); + System.err.println("updatePixelPos: win["+this.windowPos[0]+"/"+this.windowPos[1]+ + "], pixel["+this.pixelSize[0]+"x"+this.pixelSize[1]+" -> "+newPixelPos[0]+"x"+newPixelPos[1]+"]"); + System.err.println("updatePixelSize: win["+this.windowSize[0]+"x"+this.windowSize[1]+ + "], pixel["+this.pixelSize[0]+"x"+this.pixelSize[1]+" -> "+newPixelSize[0]+"x"+newPixelSize[1]+"]"); + } + if( posChanged ) { + pixelPos = newPixelPos; + } + if( sizeChanged ) { + pixelSize = newPixelSize; + if( sendEvent && isNativeValid() ) { + if(!defer) { + sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); + } else { + enqueueWindowEvent(false, WindowEvent.EVENT_WINDOW_RESIZED); + } + } + } + } + } + + /** + * Updates position and size in window units according to {@link #convertToWindowUnits(int[])}. + */ + protected void updateWindowPosSize(final boolean sendEvent, final boolean defer) { + final int[] newWindowPos = SurfaceScaleUtils.scaleInv(new int[2], pixelPos, hasPixelScale); + final int[] newWindowSize = SurfaceScaleUtils.scaleInv(new int[2], pixelSize, hasPixelScale); + final boolean posChanged = windowPos[0] != newWindowPos[0] || windowPos[1] != newWindowPos[1]; + final boolean sizeChanged = windowSize[0] != newWindowSize[0] || windowSize[1] != newWindowSize[1]; + if( posChanged || sizeChanged ) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("updateWindowPosSize: ("+getThreadName()+"): (event: "+sendEvent+", defer: "+defer+"), state "+getStateMaskString()+ + " - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); + System.err.println("updateWindowPos: win["+this.windowPos[0]+"/"+this.windowPos[1]+" -> "+newWindowPos[0]+"/"+newWindowPos[1]+ + "], pixel["+this.pixelSize[0]+"x"+this.pixelSize[1]+"]"); + System.err.println("updateWindowSize: win["+this.windowSize[0]+"x"+this.windowSize[1]+" -> "+newWindowSize[0]+"x"+newWindowSize[1]+ + "], pixel["+this.pixelSize[0]+"x"+this.pixelSize[1]+"]"); + } + if( posChanged ) { + windowPos = newWindowPos; + } + if( sizeChanged ) { + windowSize = newWindowSize; + if( sendEvent && isNativeValid() ) { + if(!defer) { + sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); + } else { + enqueueWindowEvent(false, WindowEvent.EVENT_WINDOW_RESIZED); + } + } + } + } + } + } @Override @@ -2955,10 +3075,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class SetPositionAction implements Runnable { int x, y; + boolean waitForPos; + boolean force; - private SetPositionAction(final int x, final int y) { + private SetPositionAction(final int x, final int y, final boolean waitForPos, final boolean force) { this.x = x; this.y = y; + this.waitForPos = waitForPos; + this.force = force; } @Override @@ -2971,18 +3095,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } // Let the window be positioned if !fullscreen and position changed or being a child window. if ( ( isReconfigureMaskSupported(STATE_MASK_REPOSITIONABLE) || !isNativeValid() ) && - !isFullscreen() && ( getX() != x || getY() != y ) + !isFullscreen() && ( force || getX() != x || getY() != y ) ) { if(isNativeValid()) { // this.x/this.y will be set by sizeChanged, triggered by windowing event system reconfigureWindowImpl(x, y, getWidth(), getHeight(), getReconfigureMask(0, isVisible())); - if( null == parentWindow ) { + if( null == parentWindow && waitForPos ) { // Wait until custom position is reached within tolerances waitForPosition(true, x, y, Window.TIMEOUT_NATIVEWINDOW); } } else { - definePosition(x, y); // set pos for createNative(..) + defineWindowPosition(x, y); // set pos for createNative(..) } } } finally { @@ -2990,11 +3114,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } + protected void setPositionImpl(final int x, final int y, final boolean waitForPos, final boolean force) { + stateMask.clear(STATE_BIT_AUTOPOSITION); + runOnEDTIfAvail(true, new SetPositionAction(x, y, waitForPos, force)); + } @Override public void setPosition(final int x, final int y) { - stateMask.clear(STATE_BIT_AUTOPOSITION); - runOnEDTIfAvail(true, new SetPositionAction(x, y)); + setPositionImpl(x, y, true /* waitForPos */, false /* force */); } @Override @@ -3332,8 +3459,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println("Window.monitorModeChanged.1: Non-FS - Fit window "+rect+" into screen viewport "+viewport+ ", due to minimal intersection "+isect); } - definePosition(viewport.getX(), viewport.getY()); // set pos for setVisible(..) or createNative(..) - reduce EDT roundtrip - setSize(viewport.getWidth(), viewport.getHeight(), true /* force */); + defineWindowPosition(viewport.getX(), viewport.getY()); // set pos for setVisible(..) or createNative(..) - reduce EDT roundtrip + setSizeImpl(viewport.getWidth(), viewport.getHeight(), true /* waitForSz */, true /* force */); } } } else if( fullscreenPaused ) { @@ -3354,8 +3481,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final RectangleImmutable winBounds = WindowImpl.this.getBounds(); System.err.println("Window.monitorModeChanged.3: FS Monitor Match: Fit window "+winBounds+" into new viewport union "+viewportInWindowUnits+" [window], provoked by "+md); } - definePosition(viewportInWindowUnits.getX(), viewportInWindowUnits.getY()); // set pos for setVisible(..) or createNative(..) - reduce EDT roundtrip - setSize(viewportInWindowUnits.getWidth(), viewportInWindowUnits.getHeight(), true /* force */); + defineWindowPosition(viewportInWindowUnits.getX(), viewportInWindowUnits.getY()); // set pos for setVisible(..) or createNative(..) - reduce EDT roundtrip + setSizeImpl(viewportInWindowUnits.getWidth(), viewportInWindowUnits.getHeight(), true /* waitForSz */, true /* force */); } } if( hidden ) { @@ -4400,6 +4527,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // // WindowListener/Event Support // + @Override public final void sendWindowEvent(final int eventType) { consumeWindowEvent( new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); @@ -4530,20 +4658,31 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - /** Triggered by implementation's WM events to update the client-area size in window units w/o insets/decorations. */ - protected void sizeChanged(final boolean defer, final int newWidth, final int newHeight, final boolean force) { - if(force || getWidth() != newWidth || getHeight() != newHeight) { + protected boolean sizeChanged(final boolean defer, final boolean windowUnits, final int newWidth, final int newHeight, final boolean force) { + if ( force || + ( windowUnits && ( windowSize[0] != newWidth || windowSize[1] != newHeight ) ) || + ( !windowUnits && ( pixelSize[0] != newWidth || pixelSize[1] != newHeight ) ) ) + { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.sizeChanged: ("+getThreadName()+"): (defer: "+defer+") force "+force+", "+ - getWidth()+"x"+getHeight()+" -> "+newWidth+"x"+newHeight+ + final String change; + if( windowUnits ) { + change = "win["+this.windowSize[0]+"x"+this.windowSize[1]+" -> "+newWidth+"x"+newHeight+"]"; + } else { + change = "pixel["+this.pixelSize[0]+"x"+this.pixelSize[1]+" -> "+newWidth+"x"+newHeight+"]"; + } + System.err.println("Window.sizeChanged: ("+getThreadName()+"): (defer: "+defer+") force "+force+", "+change+ ", state "+getStateMaskString()+ " - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); } if(0>newWidth || 0>newHeight) { throw new NativeWindowException("Illegal width or height "+newWidth+"x"+newHeight+" (must be >= 0)"); } - defineSize(newWidth, newHeight); + if( windowUnits ) { + defineWindowSize(newWidth, newHeight); + } else { + definePixelSize(newWidth, newHeight); + } if(isNativeValid()) { if(!defer) { sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); @@ -4551,57 +4690,106 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer enqueueWindowEvent(false, WindowEvent.EVENT_WINDOW_RESIZED); } } + return true; + } else { + return false; } } /** Triggered by implementation's WM events to update the position. */ - protected final void positionChanged(final boolean defer, final int newX, final int newY) { - if ( getX() != newX || getY() != newY ) { - if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.positionChanged: ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); + protected boolean positionChanged(final boolean defer, final boolean windowUnits, final int newX, final int newY) { + if ( ( windowUnits && ( windowPos[0] != newX || windowPos[1] != newY ) ) || + ( !windowUnits && ( pixelPos[0] != newX || pixelPos[1] != newY ) ) ) + { + if(false && DEBUG_IMPLEMENTATION) { + final String change; + if( windowUnits ) { + change = "win["+this.windowPos[0]+"x"+this.windowPos[1]+" -> "+newX+"x"+newY+"]"; + } else { + change = "pixel["+this.pixelPos[0]+"x"+this.pixelPos[1]+" -> "+newX+"x"+newY+"]"; + } + System.err.println("Window.positionChanged: ("+getThreadName()+"): (defer: "+defer+") "+change+ + " - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); + } + if( windowUnits ) { + defineWindowPosition(newX, newY); + } else { + definePixelPosition(newX, newY); } - definePosition(newX, newY); if(!defer) { sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED); } else { enqueueWindowEvent(false, WindowEvent.EVENT_WINDOW_MOVED); } + return true; } else { stateMask.clear(STATE_BIT_AUTOPOSITION); // ensure it's off even w/ same position + return false; } } /** * Triggered by implementation's WM events to update the insets. + * @param windowUnits if true, values are given in window units, otherwise in pixel units. * @param left insets, -1 ignored * @param right insets, -1 ignored * @param top insets, -1 ignored * @param bottom insets, -1 ignored - * * @see #getInsets() * @see #updateInsetsImpl(Insets) */ - protected final void insetsChanged(final int left, final int right, final int top, final int bottom) { - if ( left >= 0 && right >= 0 && top >= 0 && bottom >= 0 ) { - final boolean changed = left != insets.getLeftWidth() || right != insets.getRightWidth() || - top != insets.getTopHeight() || bottom != insets.getBottomHeight(); + protected final void insetsChanged(final boolean windowUnits, final int leftU, final int rightU, final int topU, final int bottomU) { + if ( leftU >= 0 && rightU >= 0 && topU >= 0 && bottomU >= 0 ) { + final int[] tl_win; + final int[] br_win; + if( windowUnits ) { + tl_win = new int[] { leftU, topU }; + br_win = new int[] { rightU, bottomU }; + } else { + tl_win = SurfaceScaleUtils.scaleInv(new int[2], leftU, topU, hasPixelScale); + br_win = SurfaceScaleUtils.scaleInv(new int[2], rightU, bottomU, hasPixelScale); + } + final boolean changed = tl_win[0] != insets.getLeftWidth() || br_win[0] != insets.getRightWidth() || + tl_win[1] != insets.getTopHeight() || br_win[1] != insets.getBottomHeight(); if( blockInsetsChange || isUndecorated() ) { if(DEBUG_IMPLEMENTATION) { if( changed ) { - System.err.println("Window.insetsChanged: Skip insets change "+insets+" -> "+new Insets(left, right, top, bottom)+" (blocked "+blockInsetsChange+", undecoration "+isUndecorated()+")"); + System.err.println("Window.insetsChanged: Skip insets change "+insets+" -> "+new Insets(tl_win[0], br_win[0], tl_win[1], br_win[1])+" (blocked "+blockInsetsChange+", undecoration "+isUndecorated()+")"); } } } else if ( changed ) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.insetsChanged: Changed "+insets+" -> "+new Insets(left, right, top, bottom)); + System.err.println("Window.insetsChanged: Changed "+insets+" -> "+new Insets(tl_win[0], br_win[0], tl_win[1], br_win[1])); } - insets.set(left, right, top, bottom); + insets.set(tl_win[0], br_win[0], tl_win[1], br_win[1]); } } } /** + * Triggered by implementation's WM events to update the content + * @param defer if true sent event later, otherwise wait until processed. + * @param x dirty-region y-pos in pixel units + * @param y dirty-region x-pos in pixel units + * @param width dirty-region width in pixel units + * @param height dirty-region height in pixel units + */ + protected final void windowRepaint(final boolean defer, final int x, final int y, int width, int height) { + width = ( 0 >= width ) ? getSurfaceWidth() : width; + height = ( 0 >= height ) ? getSurfaceHeight() : height; + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.windowRepaint "+getThreadName()+" (defer: "+defer+") "+x+"/"+y+" "+width+"x"+height); + } + + if(isNativeValid()) { + final NEWTEvent e = new WindowUpdateEvent(WindowEvent.EVENT_WINDOW_REPAINT, this, System.currentTimeMillis(), + new Rectangle(x, y, width, height)); + doEvent(defer, false, e); + } + } + + /** * Triggered by implementation's WM events or programmatic while respecting {@link #getDefaultCloseOperation()}. * * @param force if true, overrides {@link #setDefaultCloseOperation(WindowClosingMode)} with {@link WindowClosingProtocol#DISPOSE_ON_CLOSE} @@ -4678,6 +4866,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } + /** * Triggered by implementation's WM events to update the content * @param defer if true sent event later, otherwise wait until processed. @@ -4694,6 +4883,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } windowRepaint(defer, x, y, width, height); } + /** * Triggered by implementation's WM events to update the focus and visibility state * @@ -4711,25 +4901,29 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer visibleChanged(0 < visibleChange); } } + /** - * Triggered by implementation's WM events to update the client-area position, size, insets and maximized flags. + * Triggered by implementation's WM events to update the client-area position and size in window units, as well as maximized flags. + * @param windowUnits if true, values are given in window units, otherwise in pixel units. * @param left insets, -1 ignored * @param right insets, -1 ignored * @param top insets, -1 ignored * @param bottom insets, -1 ignored * @param visibleChange -1 ignored, 0 invisible, > 0 visible */ - protected final void insetsVisibleChanged(final int left, - final int right, final int top, final int bottom, final int visibleChange) { - insetsChanged(left, right, top, bottom); + protected final void insetsVisibleChanged(final boolean windowUnits, + final int left, final int right, final int top, final int bottom, final int visibleChange) { + insetsChanged(windowUnits, left, right, top, bottom); if( 0 <= visibleChange ) { // ignore visible < 0 visibleChanged(0 < visibleChange); } } + /** * Triggered by implementation's WM events to update the client-area position, size, insets and maximized flags. * * @param defer + * @param windowUnits if true, values are given in window units, otherwise in pixel units. * @param newX * @param newY * @param newWidth @@ -4743,15 +4937,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param force */ protected final void sizePosInsetsFocusVisibleChanged(final boolean defer, - final int newX, final int newY, - final int newWidth, final int newHeight, + final boolean windowUnits, + final int newX, final int newY, final int newWidth, final int newHeight, final int left, final int right, final int top, final int bottom, final int focusChange, - final int visibleChange, - final boolean force) { - sizeChanged(defer, newWidth, newHeight, force); - positionChanged(defer, newX, newY); - insetsChanged(left, right, top, bottom); + final int visibleChange, final boolean force) { + sizeChanged(defer, windowUnits, newWidth, newHeight, force); + positionChanged(defer, windowUnits, newX, newY); + insetsChanged(windowUnits, left, right, top, bottom); if( 0 <= focusChange ) { // ignore focus < 0 focusChanged(defer, 0 < focusChange); } @@ -4759,10 +4952,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer visibleChanged(0 < visibleChange); } } + /** * Triggered by implementation's WM events to update the client-area position, size, insets and maximized flags. * * @param defer + * @param windowUnits if true, values are given in window units, otherwise in pixel units. * @param newX * @param newY * @param newWidth @@ -4775,47 +4970,24 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param bottom insets, -1 ignored * @param visibleChange -1 ignored, 0 invisible, > 0 visible * @param force + * @param windowUnits if true, values are given in window units, otherwise in pixel units. */ - protected final void sizePosMaxInsetsVisibleChanged(final boolean defer, - final int newX, final int newY, - final int newWidth, final int newHeight, + protected final void sizePosMaxInsetsVisibleChanged(final boolean defer, final boolean windowUnits, + final int newX, final int newY, final int newWidth, final int newHeight, final int maxHorzChange, final int maxVertChange, final int left, final int right, final int top, final int bottom, - final int visibleChange, - final boolean force) { - sizeChanged(defer, newWidth, newHeight, force); - positionChanged(defer, newX, newY); + final int visibleChange, final boolean force) { + sizeChanged(defer, windowUnits, newWidth, newHeight, force); + positionChanged(defer, windowUnits, newX, newY); if( 0 <= maxHorzChange && 0 <= maxVertChange ) { maximizedChanged(0 < maxHorzChange, 0 < maxVertChange); } - insetsChanged(left, right, top, bottom); + insetsChanged(false, left, right, top, bottom); if( 0 <= visibleChange ) { // ignore visible < 0 visibleChanged(0 < visibleChange); } } - /** - * Triggered by implementation's WM events to update the content - * @param defer if true sent event later, otherwise wait until processed. - * @param x dirty-region y-pos in pixel units - * @param y dirty-region x-pos in pixel units - * @param width dirty-region width in pixel units - * @param height dirty-region height in pixel units - */ - protected final void windowRepaint(final boolean defer, final int x, final int y, int width, int height) { - width = ( 0 >= width ) ? getSurfaceWidth() : width; - height = ( 0 >= height ) ? getSurfaceHeight() : height; - if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.windowRepaint "+getThreadName()+" (defer: "+defer+") "+x+"/"+y+" "+width+"x"+height); - } - - if(isNativeValid()) { - final NEWTEvent e = new WindowUpdateEvent(WindowEvent.EVENT_WINDOW_REPAINT, this, System.currentTimeMillis(), - new Rectangle(x, y, width, height)); - doEvent(defer, false, e); - } - } - // // Implementation enforced constraints // @@ -4869,15 +5041,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - protected void sizeChangedOffThread(final boolean defer, final int newWidth, final int newHeight, final boolean force) { + protected void sizeChangedOffThread(final boolean defer, final boolean windowUnits, final int newWidth, final int newHeight, final boolean force) { if( defer ) { new InterruptSource.Thread() { @Override public void run() { - WindowImpl.this.sizeChanged(false /* defer */, newWidth, newHeight, force); + WindowImpl.this.sizeChanged(false /* defer */, windowUnits, newWidth, newHeight, force); } }.start(); } else { - WindowImpl.this.sizeChanged(false /* defer */, newWidth, newHeight, force); + WindowImpl.this.sizeChanged(false /* defer */, windowUnits, newWidth, newHeight, force); } } diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index f2c102206..a34e5d5ab 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -225,8 +225,8 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { surface = null; surfaceHandle = 0; eglSurface = 0; - definePosition(0, 0); // default to 0/0 - defineSize(0, 0); // default size -> TBD ! + defineWindowPosition(0, 0); // default to 0/0 + defineWindowSize(0, 0); // default size -> TBD ! setBrokenFocusChange(true); } @@ -287,8 +287,8 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { if( isFullscreen() ) { final MonitorDevice mainMonitor = getMainMonitor(); final RectangleImmutable winRect = mainMonitor.getViewportInWindowUnits(); - definePosition(winRect.getX(), winRect.getY()); - defineSize(winRect.getWidth(), winRect.getHeight()); + defineWindowPosition(winRect.getX(), winRect.getY()); + defineWindowSize(winRect.getWidth(), winRect.getHeight()); } final boolean b; @@ -472,7 +472,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { Log.d(MD.TAG, "reconfigureWindowImpl.setSize n/a"); res = false; } else { - defineSize(width, height); + defineWindowSize(width, height); } } if(getX() != x || getY() != y) { @@ -480,7 +480,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { Log.d(MD.TAG, "reconfigureWindowImpl.setPos n/a"); res = false; } else { - definePosition(x, y); + defineWindowPosition(x, y); } } if( 0 != ( CHANGE_MASK_VISIBILITY & flags) ) { @@ -574,7 +574,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } if(0>getX() || 0>getY()) { - positionChanged(false, 0, 0); + positionChanged(false, true, 0, 0); } if(0 == surfaceHandle) { @@ -590,7 +590,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { final int[] newSurfSize = { getWidth0(surfaceHandle), getHeight0(surfaceHandle) }; final int[] newWinSize = convertToWindowUnits(new int[]{ newSurfSize[0], newSurfSize[1] }); // HiDPI: Not necessary yet .. capsByFormat = (GLCapabilitiesImmutable) fixCaps(true /* matchFormatPrecise */, nativeFormat, getRequestedCapabilities()); - sizeChanged(false, newWinSize[0], newWinSize[1], false); + sizeChanged(false, false, newWinSize[0], newWinSize[1], false); Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+ ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ @@ -601,7 +601,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { setVisible(false, true); } } - sizeChanged(false, aWidth, aHeight, false); + sizeChanged(false, false, aWidth, aHeight, false); windowRepaint(0, 0, aWidth, aHeight); Log.d(MD.TAG, "surfaceChanged: X"); } diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java index 8cd2a1f32..a20777ef2 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -122,7 +122,7 @@ public class WindowDriver extends WindowImpl { protected void createNativeImpl() { if( withinLocalDispose ) { setupHandleAndGC(); - definePosition(getX(), getY()); // clear AUTOPOS + defineWindowPosition(getX(), getY()); // clear AUTOPOS visibleChanged(true); withinLocalDispose = false; } else { @@ -136,8 +136,8 @@ public class WindowDriver extends WindowImpl { owningFrame=true; } else { owningFrame=false; - defineSize(awtContainer.getWidth(), awtContainer.getHeight()); - definePosition(awtContainer.getX(), awtContainer.getY()); + defineWindowSize(awtContainer.getWidth(), awtContainer.getHeight()); + defineWindowPosition(awtContainer.getX(), awtContainer.getY()); } if(null!=awtFrame) { awtFrame.setTitle(getTitle()); @@ -292,7 +292,7 @@ public class WindowDriver extends WindowImpl { setCanvasSizeImpl(width, height); awtContainer.setVisible( true ); final Insets contInsets = awtContainer.getInsets(); - insetsChanged(contInsets.left, contInsets.right, contInsets.top, contInsets.bottom); + insetsChanged(false, contInsets.left, contInsets.right, contInsets.top, contInsets.bottom); } else { awtContainer.setVisible( false ); } @@ -303,12 +303,12 @@ public class WindowDriver extends WindowImpl { setCanvasSizeImpl(width, height); } } - defineSize(width, height); // we are on AWT-EDT .. change values immediately + defineWindowSize(width, height); // we are on AWT-EDT .. change values immediately if( awtContainer.getX() != x || awtContainer.getY() != y ) { awtContainer.setLocation(x, y); } - definePosition(x, y); + defineWindowPosition(x, y); if( 0 != ( CHANGE_MASK_VISIBILITY & flags) ) { if( 0 != ( STATE_MASK_VISIBLE & flags ) ) { @@ -346,7 +346,7 @@ public class WindowDriver extends WindowImpl { @Override public void windowMoved(final com.jogamp.newt.event.WindowEvent e) { if(null!=awtContainer) { - WindowDriver.this.positionChanged(false, awtContainer.getX(), awtContainer.getY()); + WindowDriver.this.positionChanged(false, true, awtContainer.getX(), awtContainer.getY()); } } @Override @@ -355,7 +355,7 @@ public class WindowDriver extends WindowImpl { if(DEBUG_IMPLEMENTATION) { System.err.println("Window Resized: "+awtCanvas); } - WindowDriver.this.sizeChanged(false, awtCanvas.getWidth(), awtCanvas.getHeight(), true); + WindowDriver.this.sizeChanged(false, false, awtCanvas.getWidth(), awtCanvas.getHeight(), true); WindowDriver.this.windowRepaint(false, 0, 0, getSurfaceWidth(), getSurfaceHeight()); } } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java index df6c2336a..d71054fcf 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java @@ -88,7 +88,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { // n/a in BroadcomEGL System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); } else { - defineSize(width, height); + defineWindowSize(width, height); } } @@ -113,7 +113,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { // n/a in BroadcomEGL System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); } else { - defineSize((width>0)?width:getWidth(), (height>0)?height:getHeight()); + defineWindowSize((width>0)?width:getWidth(), (height>0)?height:getHeight()); } } if(x>=0 || y>=0) { @@ -160,7 +160,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { } private void windowCreated(final int cfgID, final int width, final int height) { - defineSize(width, height); + defineWindowSize(width, height); final GLCapabilitiesImmutable capsReq = (GLCapabilitiesImmutable) getGraphicsConfiguration().getRequestedCapabilities(); final AbstractGraphicsConfiguration cfg = EGLGraphicsConfiguration.create(capsReq, getScreen().getGraphicsScreen(), cfgID); if (null == cfg) { diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index 783ee8a36..6a50f0f07 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -132,10 +132,10 @@ public class WindowDriver extends WindowImpl { if( modPos || modSize ) { if( definePosSize ) { if( modPos ) { - definePosition(x, y); + defineWindowPosition(x, y); } if( modSize ) { - defineSize(w, h); + defineWindowSize(w, h); } } return new Rectangle(x, y, w, h); @@ -152,7 +152,7 @@ public class WindowDriver extends WindowImpl { } @Override - protected void createNativeImpl() { + protected void createNativeImpl(boolean[] positionModified) { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported (yet)"); } diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java index a3af050c5..7e1d9423e 100644 --- a/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java @@ -79,7 +79,7 @@ public class WindowDriver extends WindowImpl { modPos = true; } if( modPos ) { - definePosition(x, y); + defineWindowPosition(x, y); } } private void adjustSize(final ScreenDriver screen, int w, int h) { @@ -95,7 +95,7 @@ public class WindowDriver extends WindowImpl { modSize = true; } if( modSize ) { - defineSize(w, h); + defineWindowSize(w, h); } } diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java index a8a3a2007..34b5d80d8 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java @@ -146,8 +146,8 @@ public class WindowDriver extends jogamp.newt.WindowImpl { private native void SetBounds0(long surfaceHandle, int scrn_width, int scrn_height, int x, int y, int width, int height); private void updateBounds(final int x, final int y, final int width, final int height) { - definePosition(x, y); - defineSize(width, height); + defineWindowPosition(x, y); + defineWindowSize(width, height); } private long surfaceHandle; diff --git a/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java index 825e22fd2..7d928cf32 100644 --- a/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java @@ -76,14 +76,14 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // We keep minPixelScale at [1f, 1f]! if( SurfaceScaleUtils.setNewPixelScale(hasPixelScale, hasPixelScale, newPixelScale, minPixelScale, maxPixelScale, DEBUG_IMPLEMENTATION ? getClass().getName() : null) ) { - if( sendEvent ) { - if( defer && deferOffThread ) { - superSizeChangedOffThread(defer, getWidth(), getHeight(), true); - } else { - super.sizeChanged(defer, getWidth(), getHeight(), true); - } + if( sendEvent && defer && deferOffThread ) { + new InterruptSource.Thread() { + @Override + public void run() { + updatePixelPosSize(true, true); + } }.start(); } else { - defineSize(getWidth(), getHeight()); + updatePixelPosSize(sendEvent, defer); } return true; } else { @@ -356,7 +356,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl setWindowClientTopLeftPoint0(getWindowHandle(), p0S.getX(), p0S.getY(), isVisible()); } } ); // no native event (fullscreen, some reparenting) - positionChanged(true, x, y); + positionChanged(true, true, x, y); } } @@ -448,8 +448,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // no native event (fullscreen, some reparenting) updateMaxScreenPixelScaleByWindowHandle(false /* sendEvent */); if( isOffscreenInstance) { - super.sizeChanged(false, width, height, true); - positionChanged(false, x, y); + super.sizeChanged(false, true /* windowUnits */, width, height, true); + positionChanged(false, true, x, y); } else { OSXUtil.RunOnMainThread(false, false, new Runnable() { @Override @@ -478,8 +478,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } ); } else { // else offscreen size is realized via recreation // no native event (fullscreen, some reparenting) - super.sizeChanged(false, width, height, false); - positionChanged(false, x, y); + super.sizeChanged(false, true /* windowUnits */, width, height, false); + positionChanged(false, true, x, y); } } if( 0 != ( CHANGE_MASK_VISIBILITY & flags) && @@ -534,9 +534,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.positionChanged.0 (Screen Pos - TOP): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY); } - positionChanged(defer, newX, newY); + positionChanged(defer, true, newX, newY); } else { final Runnable action = new Runnable() { + @Override public void run() { // screen position -> rel child window position final Point absPos = new Point(newX, newY); @@ -546,7 +547,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.positionChanged.1 (Screen Pos - CHILD): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> absPos "+newX+"/"+newY+", parentOnScreen "+parentOnScreen+" -> "+absPos); } - positionChanged(false, absPos.getX(), absPos.getY()); + positionChanged(false, true, absPos.getX(), absPos.getY()); } }; if( defer ) { new InterruptSource.Thread(null, action).start(); @@ -561,8 +562,13 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } @Override - protected void sizeChanged(final boolean defer, final int newWidth, final int newHeight, final boolean force) { - if(force || getWidth() != newWidth || getHeight() != newHeight) { + protected boolean sizeChanged(final boolean defer, final boolean windowUnits, final int newWidth, final int newHeight, final boolean force) { + final int[] windowSizeI = this.getWindowSizeI(); + final int[] pixelSizeI = this.getPixelSizeI(); + if ( force || + ( windowUnits && ( windowSizeI[0] != newWidth || windowSizeI[1] != newHeight ) ) || + ( !windowUnits && ( pixelSizeI[0] != newWidth || pixelSizeI[1] != newHeight ) ) ) + { if( isNativeValid() && !isOffscreenInstance ) { final NativeWindow parent = getParent(); final boolean useParent = useParent(parent); @@ -579,17 +585,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } ); } } - superSizeChangedOffThread(defer, newWidth, newHeight, force); - } - } - private void superSizeChangedOffThread(final boolean defer, final int newWidth, final int newHeight, final boolean force) { - if( defer ) { - new InterruptSource.Thread() { - public void run() { - WindowDriver.super.sizeChanged(false /* defer */, newWidth, newHeight, force); - } }.start(); + super.sizeChangedOffThread(defer, windowUnits, newWidth, newHeight, force); + return true; } else { - WindowDriver.super.sizeChanged(false /* defer */, newWidth, newHeight, force); + return false; } } @@ -608,9 +607,9 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( withinLiveResize && !resizeAnimatorPaused && null!=lh ) { resizeAnimatorPaused = lh.pauseRenderingAction(); } - sizeChanged(defer, newWidth, newHeight, force); + sizeChanged(defer, false, newWidth, newHeight, force); screenPositionChanged(defer, newX, newY); - insetsChanged(left, right, top, bottom); + insetsChanged(false, left, right, top, bottom); if( !withinLiveResize && resizeAnimatorPaused ) { resizeAnimatorPaused = false; if( null!=lh ) { diff --git a/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java index ee2925b1c..ae578fec0 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java @@ -155,11 +155,11 @@ public class WindowDriver extends WindowImpl { } @Override - protected void sizeChanged(final boolean defer, final int newWidth, final int newHeight, final boolean force) { + protected boolean sizeChanged(final boolean defer, final boolean windowUnits, final int newWidth, final int newHeight, final boolean force) { if(isFullscreen()) { ((ScreenDriver)getScreen()).sizeChanged(getWidth(), getHeight()); } - super.sizeChanged(defer, newWidth, newHeight, force); + return super.sizeChanged(defer, windowUnits, newWidth, newHeight, force); } private long eglWindowHandle; diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index c855e9a48..e07064959 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -55,7 +55,6 @@ import jogamp.newt.WindowImpl; import jogamp.newt.driver.DriverClearFocus; import jogamp.newt.driver.DriverUpdatePosition; -import com.jogamp.newt.Screen; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MonitorEvent; @@ -84,14 +83,14 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // We keep minPixelScale at [1f, 1f]! if( SurfaceScaleUtils.setNewPixelScale(hasPixelScale, hasPixelScale, newPixelScale, minPixelScale, maxPixelScale, DEBUG_IMPLEMENTATION ? getClass().getName() : null) ) { - if( sendEvent ) { - if( defer && deferOffThread ) { - superSizeChangedOffThread(defer, getWidth(), getHeight(), true); - } else { - super.sizeChanged(defer, getWidth(), getHeight(), true); - } + if( sendEvent && defer && deferOffThread ) { + new InterruptSource.Thread() { + @Override + public void run() { + updatePixelPosSize(true, true); + } }.start(); } else { - defineSize(getWidth(), getHeight()); + updatePixelPosSize(sendEvent, defer); } return true; } else { @@ -113,7 +112,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl /** * Essentially updates {@code hasPixelScale} and {@code maxPixelScale} .. */ - private boolean updateMaxScreenPixelScaleByWindowHandle(final boolean sendEvent) { + private boolean updatePixelScaleByWindowHandle(final boolean sendEvent) { final long handle = getWindowHandle(); if( 0 != handle ) { final float maxPixelScaleRaw = OSXUtil.GetScreenPixelScale(handle); @@ -148,7 +147,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected void monitorModeChanged(final MonitorEvent me, final boolean success) { - updateMaxScreenPixelScaleByWindowHandle(false /* sendEvent*/); // send reshape event itself + updatePixelScaleByWindowHandle(false /* sendEvent*/); // send reshape event itself } @Override @@ -376,7 +375,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl setWindowClientTopLeftPoint0(getWindowHandle(), p0S.getX(), p0S.getY(), isVisible()); } } ); // no native event (fullscreen, some reparenting) - positionChanged(true, x, y); + positionChanged(true, true, x, y); } } @@ -466,10 +465,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl createWindow(false, 0 != oldWindowHandle, pClientLevelOnSreen, width, height, flags); } // no native event (fullscreen, some reparenting) - updateMaxScreenPixelScaleByWindowHandle(false /* sendEvent */); + updatePixelScaleByWindowHandle(false /* sendEvent */); if( isOffscreenInstance ) { - super.sizeChanged(false, width, height, true); - positionChanged(false, x, y); + super.sizeChanged(false, true /* windowUnits */, width, height, true); + positionChanged(false, true, x, y); } else { OSXUtil.RunOnMainThread(true, false, new Runnable() { @Override @@ -504,8 +503,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } ); } else { // else offscreen size is realized via recreation // no native event (fullscreen, some reparenting) - super.sizeChanged(false, width, height, false); - positionChanged(false, x, y); + super.sizeChanged(false, true /* windowUnits */, width, height, false); + positionChanged(false, true, x, y); } } if( 0 != ( CHANGE_MASK_VISIBILITY & flags) && @@ -566,7 +565,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.positionChanged.0 (Screen Pos - TOP): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY); } - positionChanged(defer, newX, newY); + positionChanged(defer, true, newX, newY); } else if( useParentLoc && !isVisible() ) { // Fake invisible child window: drop fake position update for fake invisibility if(DEBUG_IMPLEMENTATION) { @@ -575,6 +574,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } else { // visible childWindow or offscreen instance final Runnable action = new Runnable() { + @Override public void run() { // screen position -> rel child window position final Point absPos = new Point(newX, newY); @@ -590,7 +590,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.positionChanged.1 (Screen Pos - CHILD): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> absPos "+newX+"/"+newY+", parentOnScreen "+parentOnScreen+" -> "+absPos); } - positionChanged(false, absPos.getX(), absPos.getY()); + positionChanged(false, true, absPos.getX(), absPos.getY()); } }; if( defer ) { new InterruptSource.Thread(null, action).start(); @@ -605,8 +605,13 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } @Override - protected void sizeChanged(final boolean defer, final int newWidth, final int newHeight, final boolean force) { - if(force || getWidth() != newWidth || getHeight() != newHeight) { + protected boolean sizeChanged(final boolean defer, final boolean windowUnits, final int newWidth, final int newHeight, final boolean force) { + final int[] windowSizeI = this.getWindowSizeI(); + final int[] pixelSizeI = this.getPixelSizeI(); + if ( force || + ( windowUnits && ( windowSizeI[0] != newWidth || windowSizeI[1] != newHeight ) ) || + ( !windowUnits && ( pixelSizeI[0] != newWidth || pixelSizeI[1] != newHeight ) ) ) + { if( isNativeValid() && isVisible() && !isOffscreenInstance ) { final NativeWindow parent = getParent(); final boolean useParentLoc = useParentLocation(parent); @@ -625,17 +630,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } ); } } - superSizeChangedOffThread(defer, newWidth, newHeight, force); - } - } - private void superSizeChangedOffThread(final boolean defer, final int newWidth, final int newHeight, final boolean force) { - if( defer ) { - new InterruptSource.Thread() { - public void run() { - WindowDriver.super.sizeChanged(false /* defer */, newWidth, newHeight, force); - } }.start(); + super.sizeChangedOffThread(defer, windowUnits, newWidth, newHeight, force); + return true; } else { - WindowDriver.super.sizeChanged(false /* defer */, newWidth, newHeight, force); + return false; } } @@ -654,9 +652,9 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( withinLiveResize && !resizeAnimatorPaused && null!=lh ) { resizeAnimatorPaused = lh.pauseRenderingAction(); } - sizeChanged(defer, newWidth, newHeight, force); + sizeChanged(defer, false, newWidth, newHeight, force); screenPositionChanged(defer, newX, newY); - insetsChanged(left, right, top, bottom); + insetsChanged(false, left, right, top, bottom); if( !withinLiveResize && resizeAnimatorPaused ) { resizeAnimatorPaused = false; if( null!=lh ) { diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index b3a68eaf3..6c5f97cdd 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -409,7 +409,6 @@ public class WindowDriver extends WindowImpl { private native long CreateWindow0(long hInstance, String wndClassName, String wndName, int winMajor, int winMinor, long parentWindowHandle, int x, int y, int width, int height, int flags); private native void InitWindow0(long windowHandle, int flags); - private native long MonitorFromWindow0(long windowHandle); private native void reconfigureWindow0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height, int flags); private static native void setTitle0(long windowHandle, String title); diff --git a/src/newt/native/IOSNewtUIWindow.m b/src/newt/native/IOSNewtUIWindow.m index 1900882d7..6e3e362a7 100644 --- a/src/newt/native/IOSNewtUIWindow.m +++ b/src/newt/native/IOSNewtUIWindow.m @@ -219,7 +219,7 @@ static jmethodID windowRepaintID = NULL; CGRect viewFrame = [self frame]; - (*env)->CallVoidMethod(env, javaWindowObject, windowRepaintID, JNI_TRUE, // defer .. + (*env)->CallVoidMethod(env, javaWindowObject, windowRepaintID, JNI_TRUE /* defer */, (int)dirtyRect.origin.x, (int)viewFrame.size.height - (int)dirtyRect.origin.y, (int)dirtyRect.size.width, (int)dirtyRect.size.height); @@ -441,10 +441,10 @@ static jmethodID windowRepaintID = NULL; + (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz { sendTouchScreenEventID = (*env)->GetMethodID(env, clazz, "sendTouchScreenEvent", "(SI[I[S[I[I[I[FF)V"); - sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); + sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZZIIZ)Z"); updatePixelScaleID = (*env)->GetMethodID(env, clazz, "updatePixelScale", "(ZFFFZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V"); - insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(IIII)V"); + insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V"); sizeScreenPosInsetsChangedID = (*env)->GetMethodID(env, clazz, "sizeScreenPosInsetsChanged", "(ZIIIIIIIIZZ)V"); screenPositionChangedID = (*env)->GetMethodID(env, clazz, "screenPositionChanged", "(ZII)V"); focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(ZZ)V"); @@ -691,7 +691,7 @@ static jmethodID windowRepaintID = NULL; DBG_PRINT( "updateInsets: [ l %d, r %d, t %d, b %d ]\n", cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3]); if( NULL != env && NULL != javaWin ) { - (*env)->CallVoidMethod(env, javaWin, insetsChangedID, cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3]); + (*env)->CallVoidMethod(env, javaWin, insetsChangedID, JNI_FALSE, cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3]); } } diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c index b3e9e1f69..972267088 100644 --- a/src/newt/native/KDWindow.c +++ b/src/newt/native/KDWindow.c @@ -131,7 +131,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_DisplayDriver_DispatchMessages KDint32 v[2]; if(!kdGetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_SIZE, v)) { DBG_PRINT( "event window size change : src: %p %dx%d\n", userData, v[0], v[1]); - (*env)->CallVoidMethod(env, javaWindow, sizeChangedID, JNI_FALSE, (jint) v[0], (jint) v[1], JNI_FALSE); + (*env)->CallBooleanMethod(env, javaWindow, sizeChangedID, JNI_FALSE, JNI_FALSE, (jint) v[0], (jint) v[1], JNI_FALSE); } else { DBG_PRINT( "event window size change error: src: %p %dx%d\n", userData, v[0], v[1]); } @@ -191,7 +191,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_WindowDriver_initIDs #endif #endif windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(J)V"); - sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); + sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZZIIZ)Z"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(SIIISF)V"); @@ -307,6 +307,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_WindowDriver_setSize0 DBG_PRINT( "[setSize] v=%dx%d, res=%d\n", width, height, res); (void)res; - (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); + (*env)->CallBooleanMethod(env, obj, sizeChangedID, JNI_FALSE, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); } diff --git a/src/newt/native/MacNewtNSWindow.m b/src/newt/native/MacNewtNSWindow.m index 6ae36af9c..e543f96e1 100644 --- a/src/newt/native/MacNewtNSWindow.m +++ b/src/newt/native/MacNewtNSWindow.m @@ -377,7 +377,7 @@ static jmethodID windowRepaintID = NULL; NSRect viewFrame = [self frame]; - (*env)->CallVoidMethod(env, javaWindowObject, windowRepaintID, JNI_TRUE, // defer .. + (*env)->CallVoidMethod(env, javaWindowObject, windowRepaintID, JNI_TRUE /* defer */, (int)dirtyRect.origin.x, (int)viewFrame.size.height - (int)dirtyRect.origin.y, (int)dirtyRect.size.width, (int)dirtyRect.size.height); @@ -877,10 +877,10 @@ NS_ENDHANDLER { enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZSIIISF)V"); enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZSISCC)V"); - sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); + sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZZIIZ)Z"); updatePixelScaleID = (*env)->GetMethodID(env, clazz, "updatePixelScale", "(ZFFFZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V"); - insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(IIII)V"); + insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V"); sizeScreenPosInsetsChangedID = (*env)->GetMethodID(env, clazz, "sizeScreenPosInsetsChanged", "(ZIIIIIIIIZZ)V"); screenPositionChangedID = (*env)->GetMethodID(env, clazz, "screenPositionChanged", "(ZII)V"); focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(ZZ)V"); @@ -1015,7 +1015,7 @@ NS_ENDHANDLER DBG_PRINT( "updateInsets: [ l %d, r %d, t %d, b %d ]\n", cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3]); if( NULL != env && NULL != javaWin ) { - (*env)->CallVoidMethod(env, javaWin, insetsChangedID, cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3]); + (*env)->CallVoidMethod(env, javaWin, insetsChangedID, JNI_FALSE, cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3]); } } diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 2423275da..4ce5567e1 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -761,7 +761,7 @@ static void UpdateInsets(JNIEnv *env, WindowUserData *wud, HWND hwnd) { (int) ( wud->insets.left + wud->insets.right ), (int) (wud->insets.top + wud->insets.bottom), wud->isInCreation); if( !wud->isInCreation ) { (*env)->CallVoidMethod(env, window, insetsChangedID, - (int)wud->insets.left, (int)wud->insets.right, (int)wud->insets.top, (int)wud->insets.bottom); + JNI_FALSE, (int)wud->insets.left, (int)wud->insets.right, (int)wud->insets.top, (int)wud->insets.bottom); } } @@ -809,7 +809,7 @@ static void WmSize(JNIEnv *env, WindowUserData * wud, HWND wnd, UINT type) jboolean v = wud->isMaximized ? JNI_TRUE : JNI_FALSE; (*env)->CallVoidMethod(env, window, maximizedChangedID, v, v); } - (*env)->CallVoidMethod(env, window, sizeChangedID, JNI_FALSE, wud->width, wud->height, JNI_FALSE); + (*env)->CallBooleanMethod(env, window, sizeChangedID, JNI_FALSE, JNI_FALSE, wud->width, wud->height, JNI_FALSE); } } @@ -1071,7 +1071,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP wud->ypos = (int)GET_Y_LPARAM(lParam); DBG_PRINT("*** WindowsWindow: WM_MOVE window %p, %d/%d, at-init %d\n", wnd, wud->xpos, wud->ypos, wud->isInCreation); if( !wud->isInCreation ) { - (*env)->CallVoidMethod(env, window, positionChangedID, JNI_FALSE, (jint)wud->xpos, (jint)wud->ypos); + (*env)->CallBooleanMethod(env, window, positionChangedID, JNI_FALSE, JNI_FALSE, (jint)wud->xpos, (jint)wud->ypos); } useDefWindowProc = 1; break; @@ -1798,11 +1798,11 @@ static LPCTSTR NewtScreen_getMonitorName1(HMONITOR hmon, MONITORINFOEXA * info) } memset(info, 0, sizeof(MONITORINFOEXA)); info->cbSize = sizeof(MONITORINFOEXA); - if( FALSE == GetMonitorInfo(hmon, info) ) { + if( FALSE == GetMonitorInfo(hmon, (LPMONITORINFO)info) ) { DBG_PRINT("*** WindowsWindow: getMonitorName1.GetMonitorInfo(hmon %p) -> FALSE\n", (void*)hmon); return NULL; } - if( NULL == info->DszDeviceeviceName || 0 == _tcslen(device->DeviceName) ) { + if( 0 == _tcslen(info->szDevice) ) { return NULL; } @@ -1916,7 +1916,7 @@ JNIEXPORT jstring JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getMonito * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getMonitorName1 - (JNIEnv *env, jobject obj, long jhmon) + (JNIEnv *env, jobject obj, jlong jhmon) { HMONITOR hmon = (HMONITOR) (intptr_t) jhmon; MONITORINFOEXA info; @@ -2162,13 +2162,13 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 { NewtCommon_init(env); - insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(IIII)V"); - sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); + insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V"); + sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZZIIZ)Z"); maximizedChangedID = (*env)->GetMethodID(env, clazz, "maximizedChanged", "(ZZ)V"); - positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(ZII)V"); + positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(ZZII)Z"); focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(ZZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V"); - sizePosInsetsFocusVisibleChangedID = (*env)->GetMethodID(env, clazz, "sizePosInsetsFocusVisibleChanged", "(ZIIIIIIIIIIZ)V"); + sizePosInsetsFocusVisibleChangedID = (*env)->GetMethodID(env, clazz, "sizePosInsetsFocusVisibleChanged", "(ZZIIIIIIIIIIZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V"); sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(SIIISF)V"); @@ -2450,7 +2450,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_InitWindow0 if( wud->isMaximized ) { (*env)->CallVoidMethod(env, wud->jinstance, maximizedChangedID, JNI_TRUE, JNI_TRUE); } - (*env)->CallVoidMethod(env, wud->jinstance, sizePosInsetsFocusVisibleChangedID, JNI_FALSE, + (*env)->CallVoidMethod(env, wud->jinstance, sizePosInsetsFocusVisibleChangedID, JNI_FALSE, JNI_FALSE, (jint)wud->xpos, (jint)wud->ypos, (jint)wud->width, (jint)wud->height, (jint)wud->insets.left, (jint)wud->insets.right, (jint)wud->insets.top, (jint)wud->insets.bottom, @@ -2466,21 +2466,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_InitWindow0 /* * Class: jogamp_newt_driver_windows_WindowDriver - * Method: MonitorFromWindow - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_MonitorFromWindow0 - (JNIEnv *env, jobject obj, jlong window) -{ - #if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410 || WINVER >= 0x0500) && !defined(_WIN32_WCE) - return (jlong) (intptr_t) MonitorFromWindow((HWND) (intptr_t) window, MONITOR_DEFAULTTOPRIMARY); - #else - return 0; - #endif -} - -/* - * Class: jogamp_newt_driver_windows_WindowDriver * Method: reconfigureWindow0 * Signature: (JJIIIII)V */ diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index f3359b49e..0e662828d 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -253,13 +253,13 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0 sendRRScreenChangeNotifyID = (*env)->GetMethodID(env, clazz, "sendRRScreenChangeNotify", "(J)V"); getCurrentThreadNameID = (*env)->GetStaticMethodID(env, X11NewtWindowClazz, "getCurrentThreadName", "()Ljava/lang/String;"); dumpStackID = (*env)->GetStaticMethodID(env, X11NewtWindowClazz, "dumpStack", "()V"); - insetsChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "insetsChanged", "(IIII)V"); - sizeChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sizeChanged", "(ZIIZ)V"); - positionChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "positionChanged", "(ZII)V"); + insetsChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "insetsChanged", "(ZIIII)V"); + sizeChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sizeChanged", "(ZZIIZ)Z"); + positionChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "positionChanged", "(ZZII)Z"); focusVisibleChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "focusVisibleChanged", "(ZII)V"); visibleChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "visibleChanged", "(Z)V"); - insetsVisibleChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "insetsVisibleChanged", "(IIIII)V"); - sizePosMaxInsetsVisibleChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sizePosMaxInsetsVisibleChanged", "(ZIIIIIIIIIIIZ)V"); + insetsVisibleChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "insetsVisibleChanged", "(ZIIIII)V"); + sizePosMaxInsetsVisibleChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sizePosMaxInsetsVisibleChanged", "(ZZIIIIIIIIIIIZ)V"); reparentNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "reparentNotify", "(J)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowDestroyNotify", "(Z)Z"); windowRepaintID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowRepaint", "(ZIIII)V"); @@ -763,7 +763,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage int visibleChange = NewtWindows_updateVisibility(env, dpy, jw, netWMState, "ConfigureNotify"); NewtWindows_updateInsets(dpy, jw, False /* wait */, &left, &right, &top, &bottom); Bool maxChanged = NewtWindows_updateMaximized(dpy, jw, netWMState); - (*env)->CallVoidMethod(env, jw->jwindow, sizePosMaxInsetsVisibleChangedID, JNI_FALSE, + (*env)->CallVoidMethod(env, jw->jwindow, sizePosMaxInsetsVisibleChangedID, JNI_FALSE, JNI_FALSE, (jint) evt.xconfigure.x, (jint) evt.xconfigure.y, (jint) evt.xconfigure.width, (jint) evt.xconfigure.height, (jint)(maxChanged ? ( jw->maxHorz ? 1 : 0 ) : -1), @@ -850,7 +850,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage // insets: negative values are ignored int left=-1, right=-1, top=-1, bottom=-1; if( NewtWindows_updateInsets(dpy, jw, False /* wait */, &left, &right, &top, &bottom) ) { - (*env)->CallVoidMethod(env, jw->jwindow, insetsVisibleChangedID, left, right, top, bottom, 1); + (*env)->CallVoidMethod(env, jw->jwindow, insetsVisibleChangedID, JNI_FALSE, left, right, top, bottom, 1); NewtCommon_ExceptionCheck1_throwNewRuntimeException(env, "X11Display.DispatchMessages0: MapNotify: Exception occured at insetsVisibleChanged(..)"); } else { (*env)->CallVoidMethod(env, jw->jwindow, visibleChangedID, JNI_TRUE); diff --git a/src/newt/native/X11Event.c b/src/newt/native/X11Event.c index aca9da675..09b591f0c 100644 --- a/src/newt/native/X11Event.c +++ b/src/newt/native/X11Event.c @@ -199,9 +199,9 @@ void X11EventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, int left, right, top, bottom; NewtWindows_updateInsets(env, w->jwindow, dpy, evt.xany.window, &left, &right, &top, &bottom); } - (*env)->CallVoidMethod(env, w->jwindow, sizeChangedID, JNI_FALSE, + (*env)->CallBooleanMethod(env, w->jwindow, sizeChangedID, JNI_FALSE, JNI_FALSE, (jint) evt.xconfigure.width, (jint) evt.xconfigure.height, JNI_FALSE); - (*env)->CallVoidMethod(env, w->jwindow, positionChangedID, JNI_FALSE, + (*env)->CallBooleanMethod(env, w->jwindow, positionChangedID, JNI_FALSE, JNI_FALSE, (jint) evt.xconfigure.x, (jint) evt.xconfigure.y); } break; diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 9f635fce7..b93bbe24f 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -954,7 +954,7 @@ JNIEXPORT jlongArray JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWind // send insets before visibility, allowing java code a proper sync point! XSync(dpy, False); if( NewtWindows_updateInsets(dpy, javaWindow, True /* wait */, &left, &right, &top, &bottom) ) { - (*env)->CallVoidMethod(env, javaWindow->jwindow, insetsVisibleChangedID, left, right, top, bottom, 1); + (*env)->CallVoidMethod(env, javaWindow->jwindow, insetsVisibleChangedID, JNI_FALSE, left, right, top, bottom, 1); NewtCommon_ExceptionCheck1_throwNewRuntimeException(env, "X11Window.CreateWindow: Exception occured at insetsVisibleChanged(..)"); } else { (*env)->CallVoidMethod(env, javaWindow->jwindow, visibleChangedID, JNI_TRUE); diff --git a/src/newt/native/XCBEvent.c b/src/newt/native/XCBEvent.c index f27d30b28..8add6b6e0 100644 --- a/src/newt/native/XCBEvent.c +++ b/src/newt/native/XCBEvent.c @@ -201,9 +201,9 @@ void XCBEventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, evt.xconfigure.override_redirect, evt.xconfigure.window != evt.xconfigure.event); if ( evt.xconfigure.window == evt.xconfigure.event ) { // ignore child window change notification - (*env)->CallVoidMethod(env, w->jwindow, sizeChangedID, + (*env)->CallBooleanMethod(env, w->jwindow, sizeChangedID, (jint) evt.xconfigure.width, (jint) evt.xconfigure.height, JNI_FALSE); - (*env)->CallVoidMethod(env, w->jwindow, positionChangedID, + (*env)->CallBooleanMethod(env, w->jwindow, positionChangedID, (jint) evt.xconfigure.x, (jint) evt.xconfigure.y); } break; diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index 9e6a41a1d..03a52c787 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -330,8 +330,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_ScreenDriver_initNative JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initIDs (JNIEnv *env, jclass clazz) { - sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); - positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(ZII)V"); + sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZZIIZ)Z"); + positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(ZZII)Z"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); if (sizeChangedID == NULL || @@ -450,10 +450,10 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_reconfigur bcm_moveTo( p->handle, p->layer, p->x, p->y, p->width, p->height); if( posChanged ) { - (*env)->CallVoidMethod(env, obj, positionChangedID, JNI_FALSE, x, y); + (*env)->CallBooleanMethod(env, obj, positionChangedID, JNI_FALSE, JNI_FALSE, x, y); } if( sizeChanged ) { - (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, width, height, JNI_FALSE); + (*env)->CallBooleanMethod(env, obj, sizeChangedID, JNI_FALSE, JNI_FALSE, width, height, JNI_FALSE); } } diff --git a/src/newt/native/drm_gbm.c b/src/newt/native/drm_gbm.c index a6c9a3f9a..7f2b7de88 100644 --- a/src/newt/native/drm_gbm.c +++ b/src/newt/native/drm_gbm.c @@ -221,8 +221,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_egl_gbm_ScreenDriver_initIDs JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_initIDs (JNIEnv *env, jclass clazz) { - sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); - positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(ZII)V"); + sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZZIIZ)Z"); + positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(ZZII)Z"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); if (sizeChangedID == NULL || |