diff options
Diffstat (limited to 'src/newt/classes')
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 42 |
1 files changed, 29 insertions, 13 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; |