summaryrefslogtreecommitdiffstats
path: root/src/newt/native
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-10-10 08:05:26 +0200
committerSven Gothel <[email protected]>2011-10-10 08:05:26 +0200
commit600ebcac40ee2d13947701fffc51ea93887db89c (patch)
tree448cf840e0e7bd11287437129440a4edcc7e0e2d /src/newt/native
parent24e0591b6be036d5389cc1eb986ed5e86043ba65 (diff)
NEWT Pointer Feature: Add Windows impl. ; Fix test (warp action) ; Minor cleanup in X11
Diffstat (limited to 'src/newt/native')
-rw-r--r--src/newt/native/WindowsWindow.c76
-rw-r--r--src/newt/native/X11Window.c9
2 files changed, 79 insertions, 6 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);
+}
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index 2038237cd..c7b271188 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -1847,7 +1847,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_requestFocus0
* Signature: (JJ)J
*/
JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_getParentWindow0
- (JNIEnv *env, jobject obj, jlong display, jlong window)
+ (JNIEnv *env, jclass clazz, jlong display, jlong window)
{
return (jlong) NewtWindows_getParent ((Display *) (intptr_t) display, (Window)window);
}
@@ -1947,7 +1947,6 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_confinePointer0
{
Display * dpy = (Display *) (intptr_t) display;
Window w = (Window)window;
- int res;
DBG_PRINT( "X11: confinePointer0: %d\n", confine);
@@ -1964,18 +1963,16 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_confinePointer0
/*
* Class: Java_jogamp_newt_driver_x11_X11Window
* Method: warpPointer0
- * Signature: (JJII)Z
+ * Signature: (JJII)V
*/
-JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_warpPointer0
+JNIEXPORT void 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;
}