diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/Window.java | 34 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 19 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/DisplayImpl.java | 8 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/WindowImpl.java | 72 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/x11/X11Screen.java | 28 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/x11/X11Window.java | 36 | ||||
-rw-r--r-- | src/newt/native/X11Window.c | 76 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java | 62 |
8 files changed, 284 insertions, 51 deletions
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 24555bf39..a69b8dbb3 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -225,6 +225,40 @@ public interface Window extends NativeWindow, WindowClosingProtocol { String getTitle(); + boolean isPointerVisible(); + + /** + * Makes the pointer visible or invisible. + * + * @param pointerVisible defaults to <code>true</code> for platforms w/ visible pointer, + * otherwise defaults to <code>true</code>, eg. Android. + * @see #confinePointer(boolean) + */ + void setPointerVisible(boolean pointerVisible); + + boolean isPointerConfined(); + + /** + * Confine the pointer to this window, ie. pointer jail. + * <p> + * In combination w/ {@link #warpPointer(int, int)} + * and maybe {@link #setPointerVisible(boolean)} a simple mouse + * navigation can be realized.</p> + * + * @param confine defaults to <code>false</code>. + */ + void confinePointer(boolean confine); + + /** + * Moves the pointer to x/y relative to this window's origin. + * + * @param x relative pointer x position within this window + * @param y relative pointer y position within this window + * + * @see #confinePointer(boolean) + */ + void warpPointer(int x, int y); + /** Defining ids for the reparenting strategy */ public interface ReparentAction { /** No native reparenting valid */ diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 3a49c06f0..5001e55e5 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -215,10 +215,29 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC return window.getTitle(); } + public final boolean isPointerVisible() { + return window.isPointerVisible(); + } + + public final void setPointerVisible(boolean mouseVisible) { + window.setPointerVisible(mouseVisible); + } + + public final boolean isPointerConfined() { + return window.isPointerConfined(); + } + + public final void confinePointer(boolean grab) { + window.confinePointer(grab); + } + public final void setUndecorated(boolean value) { window.setUndecorated(value); } + public final void warpPointer(int x, int y) { + window.warpPointer(x, y); + } public final boolean isUndecorated() { return window.isUndecorated(); } diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 2d251614b..908a44ea2 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -438,15 +438,15 @@ public abstract class DisplayImpl extends Display { } } - public interface DisplayRunnable { - Object run(long dpy); + public interface DisplayRunnable<T> { + T run(long dpy); } - public final Object runWithLockedDisplayHandle(DisplayRunnable action) { + public final <T> T runWithLockedDisplayHandle(DisplayRunnable<T> action) { final AbstractGraphicsDevice aDevice = getGraphicsDevice(); if(null == aDevice) { throw new RuntimeException("null device - not initialized: "+this); } - Object res; + T res; aDevice.lock(); try { res = action.run(aDevice.getHandle()); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 00911443a..7bef0b564 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -96,6 +96,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected String title = "Newt Window"; protected boolean undecorated = false; protected boolean alwaysOnTop = false; + private boolean pointerVisible = true; + private boolean pointerConfined = false; private LifecycleHook lifecycleHook = null; private DestroyAction destroyAction = new DestroyAction(); @@ -280,6 +282,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer createNativeImpl(); screen.addScreenModeListener(screenModeListenerImpl); setTitleImpl(title); + setPointerVisibleImpl(pointerVisible); + confinePointerImpl(pointerConfined); if(waitForVisible(true, false)) { if(isFullscreen()) { fullscreen = false; @@ -522,6 +526,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer */ protected abstract void updateInsetsImpl(Insets insets); + protected boolean setPointerVisibleImpl(boolean pointerVisible) { return false; } + protected boolean confinePointerImpl(boolean confine) { return false; } + protected void warpPointerImpl(int x, int y) { } + //---------------------------------------------------------------------- // NativeSurface // @@ -1216,20 +1224,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return capsRequested; } - public String getTitle() { - return title; - } - - public void setTitle(String title) { - if (title == null) { - title = ""; - } - this.title = title; - if(0 != getWindowHandle()) { - setTitleImpl(title); - } - } - private class DecorationActionImpl implements Runnable { boolean undecorated; @@ -1328,6 +1322,55 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return alwaysOnTop || fullscreen ; } + public String getTitle() { + return title; + } + public void setTitle(String title) { + if (title == null) { + title = ""; + } + this.title = title; + if(0 != getWindowHandle()) { + setTitleImpl(title); + } + } + + public boolean isPointerVisible() { + return pointerVisible; + } + public void setPointerVisible(boolean pointerVisible) { + if(this.pointerVisible != pointerVisible) { + boolean setVal = 0 == getWindowHandle(); + if(!setVal) { + setVal = setPointerVisibleImpl(pointerVisible); + } + if(setVal) { + this.pointerVisible = pointerVisible; + } + } + } + public boolean isPointerConfined() { + return pointerConfined; + } + + public void confinePointer(boolean confine) { + if(this.pointerConfined != confine) { + boolean setVal = 0 == getWindowHandle(); + if(!setVal) { + setVal = confinePointerImpl(confine); + } + if(setVal) { + this.pointerConfined = confine; + } + } + } + + public void warpPointer(int x, int y) { + if(0 != getWindowHandle()) { + warpPointerImpl(x, y); + } + } + public void requestFocus() { enqueueRequestFocus(true); } @@ -1368,7 +1411,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return fullscreen; } - //---------------------------------------------------------------------- // Window // diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java index a67352138..af96dc460 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java +++ b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java @@ -53,8 +53,8 @@ public class X11Screen extends ScreenImpl { protected void createNativeImpl() { // validate screen index - Long handle = (Long) display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Object run(long dpy) { + Long handle = display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Long>() { + public Long run(long dpy) { long handle = GetScreen0(dpy, screen_idx); if(0 != handle) { setScreenSize(getWidth0(dpy, screen_idx), getHeight0(dpy, screen_idx)); @@ -79,8 +79,8 @@ public class X11Screen extends ScreenImpl { private int nmode_number; protected int[] getScreenModeFirstImpl() { - return (int[]) runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Object run(long dpy) { + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<int[]>() { + public int[] run(long dpy) { // initialize iterators and static data nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); if(null==nrotations || 0==nrotations.length) { @@ -108,8 +108,8 @@ public class X11Screen extends ScreenImpl { protected int[] getScreenModeNextImpl() { // assemble: w x h x bpp x f x r - return (int[]) runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Object run(long dpy) { + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<int[]>() { + public int[] run(long dpy) { /** System.err.println("******** mode: "+nmode_number); System.err.println("rot "+nrotation_index); @@ -172,8 +172,8 @@ public class X11Screen extends ScreenImpl { } protected ScreenMode getCurrentScreenModeImpl() { - return (ScreenMode) runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Object run(long dpy) { + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<ScreenMode>() { + public ScreenMode run(long dpy) { int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); if(0==resNumber) { return null; @@ -222,8 +222,8 @@ public class X11Screen extends ScreenImpl { throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); } final long t0 = System.currentTimeMillis(); - Boolean done = (Boolean) runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Object run(long dpy) { + boolean done = runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Boolean>() { + public Boolean run(long dpy) { boolean done = false; int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); @@ -243,19 +243,19 @@ public class X11Screen extends ScreenImpl { } return Boolean.valueOf(done); } - }); + }).booleanValue(); - if(!done.booleanValue()) { + if(done) { System.err.println("X11Screen.setCurrentScreenModeImpl: TO ("+SCREEN_MODE_CHANGE_TIMEOUT+") reached: "+ (System.currentTimeMillis()-t0)+"ms"); } - return done.booleanValue(); + return done; } //---------------------------------------------------------------------- // Internals only // - private final Object runWithLockedDisplayHandle(DisplayRunnable action) { + private final <T> T runWithLockedDisplayHandle(DisplayRunnable<T> action) { return display.runWithLockedDisplayHandle(action); // return runWithTempDisplayHandle(action); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java index dfb84f6f8..c435f993c 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java +++ b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java @@ -129,14 +129,41 @@ public class X11Window extends WindowImpl { @Override protected void setTitleImpl(final String title) { - runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Object>() { public Object run(long dpy) { setTitle0(dpy, getWindowHandle(), title); return null; } }); } + + @Override + protected boolean setPointerVisibleImpl(final boolean pointerVisible) { + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Boolean>() { + public Boolean run(long dpy) { + return Boolean.valueOf(setPointerVisible0(getDisplayEDTHandle(), getWindowHandle(), pointerVisible)); + } + }).booleanValue(); + } + @Override + protected boolean confinePointerImpl(final boolean confine) { + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Boolean>() { + public Boolean run(long dpy) { + return Boolean.valueOf(confinePointer0(getDisplayEDTHandle(), getWindowHandle(), confine)); + } + }).booleanValue(); + } + + @Override + protected void warpPointerImpl(final int x, final int y) { + runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Boolean>() { + public Boolean run(long dpy) { + return Boolean.valueOf(warpPointer0(getDisplayEDTHandle(), getWindowHandle(), x, y)); + } + }); + } + protected Point getLocationOnScreenImpl(final int x, final int y) { // X11Util.GetRelativeLocation: locks display already ! return X11Util.GetRelativeLocation( getScreen().getDisplay().getHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); @@ -153,7 +180,7 @@ public class X11Window extends WindowImpl { private final long getDisplayEDTHandle() { return ((X11Display) getScreen().getDisplay()).getEDTHandle(); } - private final Object runWithLockedDisplayHandle(DisplayRunnable action) { + private final <T> T runWithLockedDisplayHandle(DisplayRunnable<T> action) { return ((DisplayImpl) getScreen().getDisplay()).runWithLockedDisplayHandle(action); // return runWithTempDisplayHandle(action); } @@ -168,6 +195,9 @@ public class X11Window extends WindowImpl { private native void setTitle0(long display, long windowHandle, String title); private native void requestFocus0(long display, long windowHandle, boolean force); private native long getParentWindow0(long display, long windowHandle); - + private native boolean setPointerVisible0(long display, long windowHandle, boolean visible); + private native boolean confinePointer0(long display, long windowHandle, boolean grab); + private native boolean warpPointer0(long display, long windowHandle, int x, int y); + private long windowHandleClose; } diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index f2af91970..2038237cd 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -1903,3 +1903,79 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_setTitle0 #endif } +/* + * Class: Java_jogamp_newt_driver_x11_X11Window + * Method: setPointerVisible0 + * Signature: (JJZ)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_setPointerVisible0 + (JNIEnv *env, jclass clazz, jlong display, jlong window, jboolean mouseVisible) +{ + static char noData[] = { 0,0,0,0,0,0,0,0 }; + static XColor black = { 0 }; + + Display * dpy = (Display *) (intptr_t) display; + Window w = (Window)window; + + DBG_PRINT( "X11: setPointerVisible0: %d\n", mouseVisible); + + if(JNI_TRUE == mouseVisible) { + XUndefineCursor(dpy, w); + } else { + Pixmap bitmapNoData; + Cursor invisibleCursor; + + bitmapNoData = XCreateBitmapFromData(dpy, w, noData, 8, 8); + if(None == bitmapNoData) { + return JNI_FALSE; + } + invisibleCursor = XCreatePixmapCursor(dpy, bitmapNoData, bitmapNoData, &black, &black, 0, 0); + XDefineCursor(dpy, w, invisibleCursor); + XFreeCursor(dpy, invisibleCursor); + XFreePixmap(dpy, bitmapNoData); + } + return JNI_TRUE; +} + +/* + * Class: Java_jogamp_newt_driver_x11_X11Window + * Method: confinePointer0 + * Signature: (JJZ)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_confinePointer0 + (JNIEnv *env, jclass clazz, jlong display, jlong window, jboolean confine) +{ + Display * dpy = (Display *) (intptr_t) display; + Window w = (Window)window; + int res; + + DBG_PRINT( "X11: confinePointer0: %d\n", confine); + + if(JNI_TRUE == confine) { + return GrabSuccess == XGrabPointer(dpy, w, True, + ButtonPressMask | ButtonReleaseMask | PointerMotionMask, + GrabModeAsync, GrabModeAsync, w, None, CurrentTime) + ? JNI_TRUE : JNI_FALSE ; + } + XUngrabPointer(dpy, CurrentTime); + return JNI_TRUE; +} + +/* + * Class: Java_jogamp_newt_driver_x11_X11Window + * Method: warpPointer0 + * Signature: (JJII)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_warpPointer0 + (JNIEnv *env, jclass clazz, jlong display, jlong window, jint x, jint y) +{ + Display * dpy = (Display *) (intptr_t) display; + Window w = (Window)window; + int res; + + DBG_PRINT( "X11: warpPointer0: %d/%d\n", x, y); + + XWarpPointer(dpy, None, w, 0, 0, 0, 0, x, y); + return JNI_TRUE; +} + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 04897eda5..7be31fdb7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -78,13 +78,16 @@ public class TestGearsES2NEWT extends UITestCase { protected void runTestGL(GLCapabilities caps, boolean undecorated) throws InterruptedException { System.err.println("requested: "+caps); - GLWindow glWindow = GLWindow.create(caps); + final GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+")"); glWindow.setSize(width, height); glWindow.setUndecorated(undecorated); glWindow.setAlwaysOnTop(alwaysOnTop); glWindow.setFullscreen(fullscreen); + glWindow.setPointerVisible(mouseVisible); + glWindow.confinePointer(mouseConfined); + GearsES2 demo = new GearsES2(vsync ? 1 : 0); demo.setPMVUseBackingArray(pmvUseBackingArray); glWindow.addGLEventListener(demo); @@ -117,36 +120,57 @@ public class TestGearsES2NEWT extends UITestCase { glWindow.addKeyListener(quitAdapter); glWindow.addWindowListener(quitAdapter); - final GLWindow f_glWindow = glWindow; glWindow.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { if(e.getKeyChar()=='f') { new Thread() { public void run() { - System.err.println("[set fullscreen pre]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", f "+f_glWindow.isFullscreen()+", "+f_glWindow.getInsets()); - f_glWindow.setFullscreen(!f_glWindow.isFullscreen()); - System.err.println("[set fullscreen post]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", f "+f_glWindow.isFullscreen()+", "+f_glWindow.getInsets()); + System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", "+glWindow.getInsets()); + glWindow.setFullscreen(!glWindow.isFullscreen()); + System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", "+glWindow.getInsets()); } }.start(); } else if(e.getKeyChar()=='a') { new Thread() { public void run() { - System.err.println("[set alwaysontop pre]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", a "+f_glWindow.isAlwaysOnTop()+", "+f_glWindow.getInsets()); - f_glWindow.setAlwaysOnTop(!f_glWindow.isAlwaysOnTop()); - System.err.println("[set alwaysontop post]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", a "+f_glWindow.isAlwaysOnTop()+", "+f_glWindow.getInsets()); + System.err.println("[set alwaysontop pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); + glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop()); + System.err.println("[set alwaysontop post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); } }.start(); } else if(e.getKeyChar()=='d') { new Thread() { public void run() { - System.err.println("[set undecorated pre]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", d "+f_glWindow.isUndecorated()+", "+f_glWindow.getInsets()); - f_glWindow.setUndecorated(!f_glWindow.isUndecorated()); - System.err.println("[set undecorated post]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", d "+f_glWindow.isUndecorated()+", "+f_glWindow.getInsets()); + System.err.println("[set undecorated pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", d "+glWindow.isUndecorated()+", "+glWindow.getInsets()); + glWindow.setUndecorated(!glWindow.isUndecorated()); + System.err.println("[set undecorated post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", d "+glWindow.isUndecorated()+", "+glWindow.getInsets()); } }.start(); } else if(e.getKeyChar()=='s') { new Thread() { public void run() { - System.err.println("[set position pre]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", "+f_glWindow.getInsets()); - f_glWindow.setPosition(100, 100); - System.err.println("[set position post]: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", "+f_glWindow.getInsets()); + System.err.println("[set position pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + glWindow.setPosition(100, 100); + System.err.println("[set position post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + } }.start(); + } else if(e.getKeyChar()=='i') { + new Thread() { + public void run() { + System.err.println("[set mouse visible pre]: "+glWindow.isPointerVisible()); + glWindow.setPointerVisible(!glWindow.isPointerVisible()); + System.err.println("[set mouse visible post]: "+glWindow.isPointerVisible()); + } }.start(); + } else if(e.getKeyChar()=='j') { + new Thread() { + public void run() { + System.err.println("[set mouse confined pre]: "+glWindow.isPointerConfined()); + glWindow.confinePointer(!glWindow.isPointerConfined()); + System.err.println("[set mouse confined post]: "+glWindow.isPointerConfined()); + } }.start(); + } else if(e.getKeyChar()=='w') { + new Thread() { + public void run() { + System.err.println("[set mouse pos pre]"); + glWindow.warpPointer(glWindow.getWidth()/2, glWindow.getHeight()/2); + glWindow.confinePointer(!glWindow.isPointerConfined()); + System.err.println("[set mouse pos post]"); } }.start(); } } @@ -158,7 +182,7 @@ public class TestGearsES2NEWT extends UITestCase { glWindow.setVisible(true); - System.err.println("size/pos: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", "+f_glWindow.getInsets()); + System.err.println("size/pos: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); System.err.println("chosen: "+glWindow.getChosenCapabilities()); while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) { @@ -184,6 +208,8 @@ public class TestGearsES2NEWT extends UITestCase { static boolean pmvUseBackingArray = true; static boolean vsync = false; static boolean waitForKey = false; + static boolean mouseVisible = true; + static boolean mouseConfined = false; public static void main(String args[]) throws IOException { @@ -207,6 +233,10 @@ public class TestGearsES2NEWT extends UITestCase { vsync = true; } else if(args[i].equals("-wait")) { waitForKey = true; + } else if(args[i].equals("-mouseInvisible")) { + mouseVisible = false; + } else if(args[i].equals("-mouseConfine")) { + mouseConfined = true; } } System.err.println("translucent "+(!opaque)); @@ -215,6 +245,8 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("fullscreen "+fullscreen); System.err.println("pmvDirect "+(!pmvUseBackingArray)); System.err.println("vsync "+vsync); + System.err.println("mouseVisible "+mouseVisible); + System.err.println("mouseConfined "+mouseConfined); if(waitForKey) { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); |