diff --git a/src/java/org/lwjgl/opengl/Display.java b/src/java/org/lwjgl/opengl/Display.java index 12328dc3..73794124 100644 --- a/src/java/org/lwjgl/opengl/Display.java +++ b/src/java/org/lwjgl/opengl/Display.java @@ -627,6 +627,7 @@ public final class Display { display_impl.update(); } + pollDevices(); } /** @@ -666,8 +667,9 @@ public final class Display { throw new RuntimeException(e); } } + if ( swap_interval != 0 ) // Handle events again when vsync is enabled, to reduced input lag. + processMessages(); - pollDevices(); if ( parent_resized ) { reshape(); parent_resized = false; diff --git a/src/java/org/lwjgl/opengl/WindowsDisplay.java b/src/java/org/lwjgl/opengl/WindowsDisplay.java index d781f0ba..f52170bf 100644 --- a/src/java/org/lwjgl/opengl/WindowsDisplay.java +++ b/src/java/org/lwjgl/opengl/WindowsDisplay.java @@ -542,6 +542,7 @@ final class WindowsDisplay implements DisplayImplementation { if (getForegroundWindow() != hwnd && !hasParent) return; getGlobalClientRect(hwnd, rect); + /* -- This is wrong on multi-monitor setups int local_offset_x = rect.left; int local_offset_y = rect.top; getGlobalClientRect(getDesktopWindow(), rect2); @@ -551,6 +552,9 @@ final class WindowsDisplay implements DisplayImplementation { nSetCursorPosition(center_x, center_y); int local_x = center_x - local_offset_x; int local_y = center_y - local_offset_y; + */ + int local_x = (rect.right - rect.left) / 2; + int local_y = (rect.bottom - rect.top) / 2; if (current_display != null) current_display.setMousePosition(local_x, transformY(hwnd, local_y)); } diff --git a/src/native/windows/org_lwjgl_opengl_Display.c b/src/native/windows/org_lwjgl_opengl_Display.c index 885f5d01..1d0e0237 100644 --- a/src/native/windows/org_lwjgl_opengl_Display.c +++ b/src/native/windows/org_lwjgl_opengl_Display.c @@ -121,8 +121,10 @@ static void handleMessages(JNIEnv *env) { PM_REMOVE // removal options )) { - DispatchMessage(&msg); + if (msg.message == WM_QUIT) + break; TranslateMessage(&msg); + DispatchMessage(&msg); } }