Windows: Only clip mouse to window borders if the lwjgl window is the foreground window
This commit is contained in:
parent
984c5a4e81
commit
d464876fe0
|
@ -511,7 +511,11 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
|
|
||||||
private static native long getDC(long hwnd);
|
private static native long getDC(long hwnd);
|
||||||
private static native long getDesktopWindow();
|
private static native long getDesktopWindow();
|
||||||
|
private static native long getForegroundWindow();
|
||||||
|
|
||||||
static void centerCursor(long hwnd) {
|
static void centerCursor(long hwnd) {
|
||||||
|
if (getForegroundWindow() != hwnd)
|
||||||
|
return;
|
||||||
getGlobalClientRect(hwnd, rect);
|
getGlobalClientRect(hwnd, rect);
|
||||||
int local_offset_x = rect.left;
|
int local_offset_x = rect.left;
|
||||||
int local_offset_y = rect.top;
|
int local_offset_y = rect.top;
|
||||||
|
@ -721,7 +725,7 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateClipping() {
|
private void updateClipping() {
|
||||||
if ((isFullscreen || (mouse != null && mouse.isGrabbed())) && !isMinimized && isFocused) {
|
if ((isFullscreen || (mouse != null && mouse.isGrabbed())) && !isMinimized && isFocused && getForegroundWindow() == getHwnd()) {
|
||||||
try {
|
try {
|
||||||
setupCursorClipping(getHwnd());
|
setupCursorClipping(getHwnd());
|
||||||
} catch (LWJGLException e) {
|
} catch (LWJGLException e) {
|
||||||
|
|
|
@ -198,6 +198,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clientToScreen(JNIEn
|
||||||
buffer[1] = point.y;
|
buffer[1] = point.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getForegroundWindow(JNIEnv *env, jclass unused) {
|
||||||
|
return (INT_PTR)GetForegroundWindow();
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getDesktopWindow(JNIEnv *env, jclass unused) {
|
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getDesktopWindow(JNIEnv *env, jclass unused) {
|
||||||
return (INT_PTR)GetDesktopWindow();
|
return (INT_PTR)GetDesktopWindow();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue