diff options
author | Sven Gothel <[email protected]> | 2013-11-06 07:06:58 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-11-06 07:06:58 +0100 |
commit | 24eab4dc2a14eed97897ec61b69f7f845ab84e04 (patch) | |
tree | 11bfb932a45d2b0837b06e4a87ff4f15636cc573 | |
parent | 44117f78f5d4fb3329409a92d758562d013298af (diff) |
NEWT Window: Expose 'setVisible(boolean wait, boolean visible)' allowing applications to not block until window becomes visible.
-rw-r--r-- | src/newt/classes/com/jogamp/newt/Window.java | 21 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 5 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/WindowImpl.java | 23 |
3 files changed, 33 insertions, 16 deletions
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 04eb07a25..869b56331 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -158,10 +158,21 @@ public interface Window extends NativeWindow, WindowClosingProtocol { void setWindowDestroyNotifyAction(Runnable r); /** - * <code>setVisible</code> makes the window and children visible if <code>visible</code> is true, + * Calls {@link #setVisible(boolean, boolean) setVisible(true, visible)}, + * i.e. blocks until the window becomes visible. + * @see #setVisible(boolean, boolean) + */ + void setVisible(boolean visible); + + /** + * <code>setVisible(..)</code> makes the window and children visible if <code>visible</code> is true, * otherwise the window and children becomes invisible. * <p> - * The <code>setVisible(true)</code> is responsible to actual create the native window. + * <code>setVisible(wait, true)</code> is responsible to actual create the native window. + * </p> + * <p> + * If <code>wait</code> is true, method blocks until window is {@link #isVisible() visible} and {@link #isNativeValid() valid}, + * otherwise method returns immediately. * </p> * <p> * Zero size semantics are respected, see {@link #setSize(int,int)}:<br> @@ -178,12 +189,12 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * </pre></p> * <p> * In case this window is a child window and has a {@link javax.media.nativewindow.NativeWindow} parent,<br> - * <code>setVisible(true)</code> has no effect as long the parent's is not valid yet, + * <code>setVisible(wait, true)</code> has no effect as long the parent's is not valid yet, * i.e. {@link javax.media.nativewindow.NativeWindow#getWindowHandle()} returns <code>null</code>.<br> - * <code>setVisible(true)</code> shall be repeated when the parent becomes valid. + * <code>setVisible(wait, true)</code> shall be repeated when the parent becomes valid. * </p> */ - void setVisible(boolean visible); + void setVisible(boolean wait, boolean visible); boolean isVisible(); diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 4f259fe9a..52f19f783 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -426,6 +426,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } @Override + public void setVisible(boolean wait, boolean visible) { + window.setVisible(wait, visible); + } + + @Override public final void setSize(int width, int height) { window.setSize(width, height); } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 5102fd26d..77c19ae05 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -148,7 +148,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private volatile int x = 64, y = 64; // client-area pos w/o insets private volatile Insets insets = new Insets(); // insets of decoration (if top-level && decorated) - private RecursiveLock windowLock = LockFactory.createRecursiveLock(); // Window instance wide lock + private final RecursiveLock windowLock = LockFactory.createRecursiveLock(); // Window instance wide lock private int surfaceLockCount = 0; // surface lock recursion count private ScreenImpl screen; // never null after create - may change reference though (reparent) @@ -177,10 +177,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private FocusRunnable focusAction = null; private KeyListener keyboardFocusHandler = null; - private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); + private final SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); - private Object childWindowsLock = new Object(); - private ArrayList<NativeWindow> childWindows = new ArrayList<NativeWindow>(); + private final Object childWindowsLock = new Object(); + private final ArrayList<NativeWindow> childWindows = new ArrayList<NativeWindow>(); private ArrayList<MouseListener> mouseListeners = new ArrayList<MouseListener>(); @@ -196,7 +196,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer lastButtonPressTime = 0; } } - private PointerState0 pState0 = new PointerState0(); + private final PointerState0 pState0 = new PointerState0(); /** from direct input: {@link WindowImpl#doPointerEvent(boolean, boolean, int[], short, int, int, boolean, short[], int[], int[], float[], float, float[], float)}. */ private static class PointerState1 extends PointerState0 { @@ -227,7 +227,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return null; } } - private PointerState1 pState1 = new PointerState1(); + private final PointerState1 pState1 = new PointerState1(); /** pointer names -> pointer ID (consecutive index, starting w/ 0) */ private final ArrayHashSet<Integer> pName2pID = new ArrayHashSet<Integer>(); @@ -534,7 +534,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer //---------------------------------------------------------------------- // WindowClosingProtocol implementation // - private Object closingListenerLock = new Object(); + private final Object closingListenerLock = new Object(); private WindowClosingMode defaultCloseOperation = WindowClosingMode.DISPOSE_ON_CLOSE; @Override @@ -965,7 +965,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - protected void setVisible(boolean wait, boolean visible) { + @Override + public void setVisible(boolean wait, boolean visible) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window setVisible: START ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow)); } @@ -3007,7 +3008,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private final IntBitfield keyPressedState = new IntBitfield( keyTrackingRange + 1 ); protected final boolean isKeyCodeTracked(final short keyCode) { - return ( 0xFFFF & (int)keyCode ) <= keyTrackingRange; + return ( 0xFFFF & keyCode ) <= keyTrackingRange; } /** @@ -3016,7 +3017,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @return the previus pressed value */ protected final boolean setKeyPressed(short keyCode, boolean pressed) { - final int v = 0xFFFF & (int)keyCode; + final int v = 0xFFFF & keyCode; if( v <= keyTrackingRange ) { return keyPressedState.put(v, pressed); } @@ -3027,7 +3028,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @return true if pressed, otherwise false */ protected final boolean isKeyPressed(short keyCode) { - final int v = 0xFFFF & (int)keyCode; + final int v = 0xFFFF & keyCode; if( v <= keyTrackingRange ) { return keyPressedState.get(v); } |