From e9e9bf7b911da715a3a87b03b4af46f19d2ad81f Mon Sep 17 00:00:00 2001 From: kappa1 Date: Thu, 12 Nov 2009 22:12:49 +0000 Subject: [PATCH] FIX: Mouse Grab should now work on Windows when using Display.setParent() --- src/java/org/lwjgl/opengl/WindowsDisplay.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/java/org/lwjgl/opengl/WindowsDisplay.java b/src/java/org/lwjgl/opengl/WindowsDisplay.java index e3eba681..c59c49be 100644 --- a/src/java/org/lwjgl/opengl/WindowsDisplay.java +++ b/src/java/org/lwjgl/opengl/WindowsDisplay.java @@ -131,6 +131,7 @@ final class WindowsDisplay implements DisplayImplementation { private WindowsDisplayPeerInfo peer_info; private Object current_cursor; private Canvas parent; + private static boolean hasParent = false; private WindowsKeyboard keyboard; private WindowsMouse mouse; @@ -169,6 +170,7 @@ final class WindowsDisplay implements DisplayImplementation { isFocused = false; did_maximize = false; this.parent = parent; + hasParent = parent != null; long parent_hwnd = parent != null ? getHwnd(parent) : 0; this.hwnd = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), Display.isFullscreen() || isUndecorated(), parent != null, parent_hwnd); if (hwnd == 0) { @@ -519,7 +521,7 @@ final class WindowsDisplay implements DisplayImplementation { private static native long getForegroundWindow(); static void centerCursor(long hwnd) { - if (getForegroundWindow() != hwnd) + if (getForegroundWindow() != hwnd && !hasParent) return; getGlobalClientRect(hwnd, rect); int local_offset_x = rect.left; @@ -764,7 +766,7 @@ final class WindowsDisplay implements DisplayImplementation { } private void updateClipping() { - if ((Display.isFullscreen() || (mouse != null && mouse.isGrabbed())) && !isMinimized && isFocused && getForegroundWindow() == getHwnd()) { + if ((Display.isFullscreen() || (mouse != null && mouse.isGrabbed())) && !isMinimized && isFocused && (getForegroundWindow() == getHwnd() || hasParent)) { try { setupCursorClipping(getHwnd()); } catch (LWJGLException e) {