diff options
author | Sven Gothel <[email protected]> | 2011-10-15 10:51:54 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-10-15 10:51:54 +0200 |
commit | ec2fc482bf97459c57417a8f856345a5836680f3 (patch) | |
tree | a0414e9596791e5e3954df6586033e84af2f1d8b /src/newt/native/WindowsWindow.c | |
parent | 50dca7ef60f28711397d40d8daeb8a24dff41dc2 (diff) |
NEWT/Mouse: Skip 'move' event w/ same position. Add Enter/Exit events
Skip 'mouse move' event w/ same position
- On Windows, the OS sends us multiple event w/o change in position, suppress them
Add Enter/Exit events incl. synthesize 'enter' event for windows/osx
- X11: using native Enter/Leave events
- Windows: using native Leave event (tracking) and synthesized enter event
- OSX: TODO (required for the confined feature, etc)
Diffstat (limited to 'src/newt/native/WindowsWindow.c')
-rw-r--r-- | src/newt/native/WindowsWindow.c | 33 |
1 files changed, 32 insertions, 1 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); +} + |