diff options
author | Sven Gothel <[email protected]> | 2023-01-31 05:00:57 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-01-31 05:00:57 +0100 |
commit | ab6d84721e2a15550289e14b751e06701bd68726 (patch) | |
tree | d38e7d5ada77e80df2e044e29ca9cf2bf1883b9a /src/newt/classes/jogamp | |
parent | 1d4c077b29a69fd13526dfd25d00ee87c0d5b3fe (diff) |
NEWT Soft-PixelScale (p4): WindowImpl: Change SetSizeAction to optionally set a custom position additionally to size
This added functionality is desired when adjusting the window position and size when changing the soft-pixel-scale
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r-- | src/newt/classes/jogamp/newt/WindowImpl.java | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index dc6a45d48..f3e91bf5e 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1386,12 +1386,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } private class SetSizeAction implements Runnable { + int x, y; + boolean set_pos; int width, height; + boolean waitForSz; boolean force; - private SetSizeAction(final int w, final int h, final boolean disregardFS) { + private SetSizeAction(final int x, final int y, final boolean set_pos, final int w, final int h, final boolean waitForSz, final boolean disregardFS) { + this.x = x; + this.y = y; + this.set_pos = set_pos; this.width = w; this.height = h; + this.waitForSz = waitForSz; this.force = disregardFS; } @@ -1410,23 +1417,38 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window setSize: START force "+force+", "+getWidth()+"x"+getHeight()+" -> "+width+"x"+height+", windowHandle "+toHexString(windowHandle)+", state "+getStateMaskString()); } - final boolean _visible = stateMask.get(STATE_BIT_VISIBLE); + final boolean _visible = isVisible(); int visibleAction; // 0 nop, 1 invisible, 2 visible (create) if ( _visible && isNativeValid() && ( 0 >= width || 0 >= height ) ) { visibleAction=1; // invisible - defineSize(0, 0); + if( set_pos ) { + defineWindowPosition(x, y); + } + defineWindowSize(0, 0); } else if ( _visible && !isNativeValid() && 0 < width && 0 < height ) { visibleAction = 2; // visible (create) - defineSize(width, height); + if( set_pos ) { + defineWindowPosition(x, y); + } + defineWindowSize(width, height); } else if ( _visible && isNativeValid() ) { visibleAction = 0; // this width/height will be set by windowChanged, called by the native implementation - reconfigureWindowImpl(getX(), getY(), width, height, getReconfigureMask(0, isVisible())); - WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW); + if( set_pos ) { + reconfigureWindowImpl(x, y, width, height, getReconfigureMask(0, _visible)); + } else { + reconfigureWindowImpl(getX(), getY(), width, height, getReconfigureMask(0, _visible)); + } + if( waitForSz ) { + WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW); + } } else { // invisible or invalid w/ 0 size visibleAction = 0; - defineSize(width, height); + if( set_pos ) { + defineWindowPosition(x, y); + } + defineWindowSize(width, height); } if(DEBUG_IMPLEMENTATION) { System.err.println("Window setSize: END "+getWidth()+"x"+getHeight()+", visibleAction "+visibleAction); @@ -1442,12 +1464,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - private void setSize(final int width, final int height, final boolean force) { - runOnEDTIfAvail(true, new SetSizeAction(width, height, force)); + protected void setPosSizeImpl(final int x, final int y, final int width, final int height, final boolean waitForSz, final boolean force) { + runOnEDTIfAvail(true, new SetSizeAction(x, y, true, width, height, waitForSz, force)); + } + protected void setSizeImpl(final int width, final int height, final boolean waitForSz, final boolean force) { + runOnEDTIfAvail(true, new SetSizeAction(0, 0, false, width, height, waitForSz, force)); } @Override public final void setSize(final int width, final int height) { - runOnEDTIfAvail(true, new SetSizeAction(width, height, false)); + setSizeImpl(width, height, true /* waitForSz */, false /* force */); } @Override public final void setSurfaceSize(final int pixelWidth, final int pixelHeight) { |