diff options
author | Sven Gothel <[email protected]> | 2011-10-10 08:05:26 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-10-10 08:05:26 +0200 |
commit | 600ebcac40ee2d13947701fffc51ea93887db89c (patch) | |
tree | 448cf840e0e7bd11287437129440a4edcc7e0e2d /src/newt/native/WindowsWindow.c | |
parent | 24e0591b6be036d5389cc1eb986ed5e86043ba65 (diff) |
NEWT Pointer Feature: Add Windows impl. ; Fix test (warp action) ; Minor cleanup in X11
Diffstat (limited to 'src/newt/native/WindowsWindow.c')
-rw-r--r-- | src/newt/native/WindowsWindow.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 307938ac1..3eba0f345 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -1574,4 +1574,80 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_requestFocu NewtWindows_requestFocus ( env, obj, (HWND) (intptr_t) window, force) ; } +/* + * Class: Java_jogamp_newt_driver_windows_WindowsWindow + * Method: setPointerVisible0 + * Signature: (JJZ)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_setPointerVisible0 + (JNIEnv *env, jclass clazz, jlong window, jboolean mouseVisible) +{ + HWND hwnd = (HWND) (intptr_t) window; + int res, resOld, i; + jboolean b; + + if(JNI_TRUE == mouseVisible) { + res = ShowCursor(TRUE); + if(res < 0) { + i=0; + do { + resOld = res; + res = ShowCursor(TRUE); + } while(res!=resOld && res<0 && ++i<10); + } + b = res>=0 ? JNI_TRUE : JNI_FALSE; + } else { + res = ShowCursor(FALSE); + if(res >= 0) { + i=0; + do { + resOld = res; + res = ShowCursor(FALSE); + } while(res!=resOld && res>=0 && ++i<10); + } + b = res<0 ? JNI_TRUE : JNI_FALSE; + } + + DBG_PRINT( "*** WindowsWindow: setPointerVisible0: %d, res %d/%d\n", mouseVisible, res, b); + + return b; +} + +/* + * Class: Java_jogamp_newt_driver_windows_WindowsWindow + * Method: confinePointer0 + * Signature: (JJZIIII)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_confinePointer0 + (JNIEnv *env, jclass clazz, jlong window, jboolean confine, jint l, jint t, jint r, jint b) +{ + HWND hwnd = (HWND) (intptr_t) window; + jboolean res; + + if(JNI_TRUE == confine) { + // SetCapture(hwnd); + // res = ( GetCapture() == hwnd ) ? JNI_TRUE : JNI_FALSE; + RECT rect = { l, t, r, b }; + res = ClipCursor(&rect) ? JNI_TRUE : JNI_FALSE; + } else { + // res = ReleaseCapture() ? JNI_TRUE : JNI_FALSE; + res = ClipCursor(NULL) ? JNI_TRUE : JNI_FALSE; + } + DBG_PRINT( "*** WindowsWindow: confinePointer0: %d, [ l %d t %d r %d b %d ], res %d\n", + confine, l, t, r, b, res); + + return res; +} + +/* + * Class: Java_jogamp_newt_driver_windows_WindowsWindow + * Method: warpPointer0 + * Signature: (JJII)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_warpPointer0 + (JNIEnv *env, jclass clazz, jlong window, jint x, jint y) +{ + DBG_PRINT( "*** WindowsWindow: warpPointer0: %d/%d\n", x, y); + SetCursorPos(x, y); +} |