fix windows issue with mouse down true when released outside window
This commit is contained in:
parent
31522ef459
commit
a6ae9f33b5
|
@ -52,7 +52,7 @@
|
||||||
<equals arg1="${os.arch}" arg2="x86"/>
|
<equals arg1="${os.arch}" arg2="x86"/>
|
||||||
</condition>
|
</condition>
|
||||||
<echo message="${sdkhomelib}"/>
|
<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="compile_dir"/>
|
||||||
<antcall target="link"/>
|
<antcall target="link"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
|
@ -62,6 +62,7 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
private final static int WM_MBUTTONUP = 0x0208;
|
private final static int WM_MBUTTONUP = 0x0208;
|
||||||
private final static int WM_MBUTTONDBLCLK = 0x0209;
|
private final static int WM_MBUTTONDBLCLK = 0x0209;
|
||||||
private final static int WM_MOUSEWHEEL = 0x020A;
|
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_KEYDOWN = 256;
|
||||||
private final static int WM_KEYUP = 257;
|
private final static int WM_KEYUP = 257;
|
||||||
private final static int WM_SYSKEYUP = 261;
|
private final static int WM_SYSKEYUP = 261;
|
||||||
|
@ -149,6 +150,8 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
private long small_icon;
|
private long small_icon;
|
||||||
private long large_icon;
|
private long large_icon;
|
||||||
|
|
||||||
|
private boolean trackingMouse = false;
|
||||||
|
|
||||||
WindowsDisplay() {
|
WindowsDisplay() {
|
||||||
current_display = this;
|
current_display = this;
|
||||||
}
|
}
|
||||||
|
@ -669,8 +672,18 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleMouseMoved(int x, int y, long millis) {
|
private void handleMouseMoved(int x, int y, long millis) {
|
||||||
if (mouse != null)
|
if (mouse != null) {
|
||||||
mouse.handleMouseMoved(x, y, millis, shouldGrab());
|
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) {
|
private void handleMouseScrolled(int amount, long millis) {
|
||||||
|
@ -796,6 +809,9 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
handleMouseButton(2, 0, millis);
|
handleMouseButton(2, 0, millis);
|
||||||
return 0;
|
return 0;
|
||||||
|
case WM_MOUSELEAVE:
|
||||||
|
handleMouseLeave(millis);
|
||||||
|
return 0;
|
||||||
case WM_SYSCHAR:
|
case WM_SYSCHAR:
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
handleChar(wParam, lParam, millis);
|
handleChar(wParam, lParam, millis);
|
||||||
|
@ -886,4 +902,17 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
return "Rect: top = " + top + " bottom = " + bottom + " left = " + left + " right = " + right;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -489,3 +489,14 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getSystemMetrics(JNI
|
||||||
return GetSystemMetrics(index);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue