summaryrefslogtreecommitdiffstats
path: root/src/newt/native
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt/native')
-rw-r--r--src/newt/native/WindowsWindow.c33
-rw-r--r--src/newt/native/X11Window.c30
2 files changed, 60 insertions, 3 deletions
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 3eba0f345..0d969e670 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -617,6 +617,16 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, HWND hwnd, jb
DBG_PRINT("*** WindowsWindow: requestFocus.XX\n");
}
+static void NewtWindows_trackPointerLeave(HWND hwnd) {
+ TRACKMOUSEEVENT tme;
+ memset(&tme, 0, sizeof(TRACKMOUSEEVENT));
+ tme.cbSize = sizeof(TRACKMOUSEEVENT);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hwnd;
+ tme.dwHoverTime = 0; // we don't use TME_HOVER
+ TrackMouseEvent(&tme);
+}
+
#if 0
static RECT* UpdateInsets(JNIEnv *env, jobject window, HWND hwnd)
@@ -925,6 +935,15 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
(jint) 0, (jint) 0);
useDefWindowProc = 1;
break;
+ case WM_MOUSELEAVE:
+ (*env)->CallVoidMethod(env, window, enqueueMouseEventID, JNI_FALSE,
+ (jint) EVENT_MOUSE_EXITED,
+ 0,
+ (jint) -1, (jint) -1, // fake
+ (jint) 0, (jint) 0);
+ useDefWindowProc = 1;
+ break;
+ // Java synthesizes EVENT_MOUSE_ENTERED
case WM_MOUSEWHEEL: {
// need to convert the coordinates to component-relative
@@ -986,7 +1005,6 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
break;
- // FIXME: generate EVENT_MOUSE_ENTERED, EVENT_MOUSE_EXITED
default:
useDefWindowProc = 1;
}
@@ -1651,3 +1669,16 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_warpPointer
SetCursorPos(x, y);
}
+/*
+ * Class: Java_jogamp_newt_driver_windows_WindowsWindow
+ * Method: trackPointerLeave0
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_trackPointerLeave0
+ (JNIEnv *env, jclass clazz, jlong window)
+{
+ HWND hwnd = (HWND) (intptr_t) window;
+ DBG_PRINT( "*** WindowsWindow: trackMouseLeave0\n");
+ NewtWindows_trackPointerLeave(hwnd);
+}
+
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index c7b271188..6b6c1ff6c 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -161,6 +161,8 @@ static jint X11InputState2NewtModifiers(unsigned int xstate) {
return modifiers;
}
+#define X11_MOUSE_EVENT_MASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask)
+
static const char * const ClazzNameNewtWindow = "com/jogamp/newt/Window";
static jclass newtWindowClz=NULL;
@@ -837,6 +839,30 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0
(jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0 /*rotation*/);
#endif
break;
+ case EnterNotify:
+ DBG_PRINT( "X11: event . EnterNotify call %p %d/%d\n", (void*)evt.xcrossing.window, evt.xcrossing.x, evt.xcrossing.y);
+ #ifdef USE_SENDIO_DIRECT
+ (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_ENTERED,
+ modifiers,
+ (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/);
+ #else
+ (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_ENTERED,
+ modifiers,
+ (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/);
+ #endif
+ break;
+ case LeaveNotify:
+ DBG_PRINT( "X11: event . LeaveNotify call %p %d/%d\n", (void*)evt.xcrossing.window, evt.xcrossing.x, evt.xcrossing.y);
+ #ifdef USE_SENDIO_DIRECT
+ (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_EXITED,
+ modifiers,
+ (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/);
+ #else
+ (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_EXITED,
+ modifiers,
+ (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/);
+ #endif
+ break;
case KeyPress:
#ifdef USE_SENDIO_DIRECT
(*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_PRESSED,
@@ -1586,7 +1612,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_CreateWindow0
xswa.backing_store=NotUseful; /* NotUseful, WhenMapped, Always */
xswa.backing_planes=0; /* planes to be preserved if possible */
xswa.backing_pixel=0; /* value to use in restoring planes */
- xswa.event_mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask ;
+ xswa.event_mask = X11_MOUSE_EVENT_MASK;
xswa.event_mask |= KeyPressMask | KeyReleaseMask ;
xswa.event_mask |= FocusChangeMask | SubstructureNotifyMask | StructureNotifyMask | ExposureMask ;
@@ -1952,7 +1978,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_confinePointer0
if(JNI_TRUE == confine) {
return GrabSuccess == XGrabPointer(dpy, w, True,
- ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
+ X11_MOUSE_EVENT_MASK,
GrabModeAsync, GrabModeAsync, w, None, CurrentTime)
? JNI_TRUE : JNI_FALSE ;
}