From: <ma...@us...> - 2009-05-26 20:39:25
|
Revision: 3215 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3215&view=rev Author: matzon Date: 2009-05-26 20:39:23 +0000 (Tue, 26 May 2009) Log Message: ----------- fix windows issue with mouse down true when released outside window Modified Paths: -------------- trunk/LWJGL/platform_build/windows_ant/build.xml trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/platform_build/windows_ant/build.xml =================================================================== --- trunk/LWJGL/platform_build/windows_ant/build.xml 2009-05-23 09:37:10 UTC (rev 3214) +++ trunk/LWJGL/platform_build/windows_ant/build.xml 2009-05-26 20:39:23 UTC (rev 3215) @@ -52,7 +52,7 @@ <equals arg1="${os.arch}" arg2="x86"/> </condition> <echo message="${sdkhomelib}"/> - <property name="libs" value="Kernel32.lib ole32.lib OpenGL32.Lib Version.lib user32.lib Gdi32.lib Advapi32.lib jawt.lib delayimp.lib winmm.lib"/> + <property name="libs" value="Kernel32.lib ole32.lib OpenGL32.Lib Version.lib user32.lib Gdi32.lib Advapi32.lib jawt.lib delayimp.lib winmm.lib Comctl32.lib"/> <antcall target="compile_dir"/> <antcall target="link"/> </target> Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2009-05-23 09:37:10 UTC (rev 3214) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2009-05-26 20:39:23 UTC (rev 3215) @@ -62,6 +62,7 @@ private final static int WM_MBUTTONUP = 0x0208; private final static int WM_MBUTTONDBLCLK = 0x0209; private final static int WM_MOUSEWHEEL = 0x020A; + private final static int WM_MOUSELEAVE = 0x02A3; private final static int WM_KEYDOWN = 256; private final static int WM_KEYUP = 257; private final static int WM_SYSKEYUP = 261; @@ -149,6 +150,8 @@ private long small_icon; private long large_icon; + private boolean trackingMouse = false; + WindowsDisplay() { current_display = this; } @@ -669,8 +672,18 @@ } private void handleMouseMoved(int x, int y, long millis) { - if (mouse != null) - mouse.handleMouseMoved(x, y, millis, shouldGrab()); + if (mouse != null) { + mouse.handleMouseMoved(x, y, millis, shouldGrab()); + + // if we're not tracking mouse and we get a mouse move event - START TRACKING! + if(!trackingMouse && !Mouse.isGrabbed()) { + LWJGLUtil.log("initial mouse move - need tracking"); + + if (nTrackMouse(hwnd)) { + trackingMouse = true; + } + } + } } private void handleMouseScrolled(int amount, long millis) { @@ -796,6 +809,9 @@ case WM_MBUTTONUP: handleMouseButton(2, 0, millis); return 0; + case WM_MOUSELEAVE: + handleMouseLeave(millis); + return 0; case WM_SYSCHAR: case WM_CHAR: handleChar(wParam, lParam, millis); @@ -886,4 +902,17 @@ return "Rect: top = " + top + " bottom = " + bottom + " left = " + left + " right = " + right; } } + + + + + private static native boolean nTrackMouse(long hwnd); + + private void handleMouseLeave(long millis) { + handleMouseButton(0, 0, millis); + handleMouseButton(1, 0, millis); + handleMouseButton(2, 0, millis); + trackingMouse = false; + } + } Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2009-05-23 09:37:10 UTC (rev 3214) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2009-05-26 20:39:23 UTC (rev 3215) @@ -489,3 +489,14 @@ return GetSystemMetrics(index); } +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nTrackMouse(JNIEnv *env, jclass unused, jlong hwnd_int) { + HWND hwnd = (HWND)(INT_PTR)hwnd_int; + + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = hwnd; + + return _TrackMouseEvent(&tme); +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |