diff options
author | Sven Gothel <[email protected]> | 2015-07-17 04:39:53 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-07-17 04:39:53 +0200 |
commit | 51268bc9874de7cc34dfe7741187238f7d46aafc (patch) | |
tree | ba8ed3877d1456a4f4cf10eef1c54b95db49c3ee /src/newt | |
parent | 1584cae39c6dca9e372000bb64534c881ebc3511 (diff) |
Bug 1176: BCM VC IV: Refine clamping of window position and size at native creation
- Refines commit a566a1b5a2828b38f1a5c4dfb215ab9b03e7acaa
- Issue clamping at 'canCreateNativeImpl()' instead of 'createNativeImpl()',
allowing to define clamped position and size before utilizing these values
at caller 'createNative()'.
Otherwise a clamped position would cause to wait for the original position
after 'createNativeImpl()'.
This also allows to remove the positionChanged(..) / sizeChanged(..) calls in
the native CreateWindow0() implementation.
Diffstat (limited to 'src/newt')
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 42 | ||||
-rw-r--r-- | src/newt/native/bcm_vc_iv.c | 2 |
2 files changed, 29 insertions, 15 deletions
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 9423949e4..93c28d370 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 @@ -69,46 +69,57 @@ public class WindowDriver extends WindowImpl { * * @param screen * @param rect the {@link RectangleImmutable} in pixel units + * @param definePosSize if {@code true} issue {@link #definePosition(int, int)} and {@link #defineSize(int, int)} + * if either has changed. * @return If position or size has been clamped a new {@link RectangleImmutable} instance w/ clamped values * will be returned, otherwise the given {@code rect} is returned. */ - private RectangleImmutable clampRect(final ScreenDriver screen, final RectangleImmutable rect) { + private RectangleImmutable clampRect(final ScreenDriver screen, final RectangleImmutable rect, final boolean definePosSize) { int x = rect.getX(); int y = rect.getY(); int w = rect.getWidth(); int h = rect.getHeight(); final int s_w = screen.getWidth(); final int s_h = screen.getHeight(); - boolean mod = false; + boolean modPos = false; + boolean modSize = false; if( 0 > x ) { x = 0; - mod = true; + modPos = true; } if( 0 > y ) { y = 0; - mod = true; + modPos = true; } if( s_w < x + w ) { if( 0 < x ) { x = 0; - mod = true; + modPos = true; } if( s_w < w ) { w = s_w; - mod = true; + modSize = true; } } if( s_h < y + h ) { if( 0 < y ) { y = 0; - mod = true; + modPos = true; } if( s_h < h ) { h = s_h; - mod = true; + modSize = true; } } - if( mod ) { + if( modPos || modSize ) { + if( definePosSize ) { + if( modPos ) { + definePosition(x, y); + } + if( modSize ) { + defineSize(w, h); + } + } return new Rectangle(x, y, w, h); } else { return rect; @@ -116,6 +127,13 @@ public class WindowDriver extends WindowImpl { } @Override + protected boolean canCreateNativeImpl() { + // clamp if required incl. redefinition of position and size + clampRect((ScreenDriver) getScreen(), new Rectangle(getX(), getY(), getWidth(), getHeight()), true); + return true; // default: always able to be created + } + + @Override protected void createNativeImpl() { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported (yet)"); @@ -162,10 +180,8 @@ public class WindowDriver extends WindowImpl { chosenCaps.setBackgroundOpaque(capsRequested.isBackgroundOpaque()); } setGraphicsConfiguration(cfg); - // CreateWindow0 will issue position/size changed event if clamped and required - final RectangleImmutable rect = clampRect(screen, new Rectangle(getX(), getY(), getWidth(), getHeight())); nativeWindowHandle = CreateWindow0(display.getBCMHandle(), layer, - rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight(), + getX(), getY(), getWidth(), getHeight(), chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits()); if (nativeWindowHandle == 0) { throw new NativeWindowException("Error creating egl window: "+cfg); @@ -210,7 +226,7 @@ public class WindowDriver extends WindowImpl { @Override protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) { - final RectangleImmutable rect = clampRect((ScreenDriver) getScreen(), new Rectangle(x, y, width, height)); + final RectangleImmutable rect = clampRect((ScreenDriver) getScreen(), new Rectangle(x, y, width, height), false); // reconfigure0 will issue position/size changed events if required reconfigure0(nativeWindowHandle, rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight(), flags); return true; diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index 487941e38..611dd5a4a 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -402,8 +402,6 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWin vc_dispmanx_update_submit_sync( dispman_update ); (*env)->CallVoidMethod(env, obj, visibleChangedID, JNI_FALSE, JNI_TRUE); // FIXME: or defer=true ? - (*env)->CallVoidMethod(env, obj, positionChangedID, JNI_FALSE, x, y); // always report pos-change (clamping) - (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, width, height, JNI_FALSE); // always report size-change (clamping) DBG_PRINT( "BCM.Display Window.Create.X %p, element %p\n", (void*)(intptr_t)dispman_display, (void*)(intptr_t)p->handle); |