From a4c5be3781d4665bf7f097b7a13de7abace22af2 Mon Sep 17 00:00:00 2001 From: kappaOne Date: Tue, 25 Dec 2012 14:00:09 +0000 Subject: [PATCH] fix OS X Mouse.setCursorPosition to use CGDisplayMoveCursorToPoint instead of CGWarpMouseCursorPosition to allow working on multiple monitor setups, also obtain correct window screen instead of screen with keyboard focus --- src/native/macosx/org_lwjgl_opengl_Display.m | 2 +- src/native/macosx/org_lwjgl_opengl_MacOSXNativeMouse.m | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/native/macosx/org_lwjgl_opengl_Display.m b/src/native/macosx/org_lwjgl_opengl_Display.m index 20eae51a..7890acc4 100644 --- a/src/native/macosx/org_lwjgl_opengl_Display.m +++ b/src/native/macosx/org_lwjgl_opengl_Display.m @@ -395,7 +395,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetX(JNIEnv *env, jo JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetY(JNIEnv *env, jobject this, jobject window_handle) { MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle); - NSRect screenRect = [[[window_info->view window] screen] frame]; + NSRect screenRect = [[window_info->window screen] frame]; NSRect winRect = [[window_info->view window] frame]; // get top corner of window frame, also flip coords so origin is in top left diff --git a/src/native/macosx/org_lwjgl_opengl_MacOSXNativeMouse.m b/src/native/macosx/org_lwjgl_opengl_MacOSXNativeMouse.m index e35c34a5..37947810 100644 --- a/src/native/macosx/org_lwjgl_opengl_MacOSXNativeMouse.m +++ b/src/native/macosx/org_lwjgl_opengl_MacOSXNativeMouse.m @@ -70,7 +70,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nSetCursorPositio p.y = point.y; } else { - NSRect screenRect = [[NSScreen mainScreen] frame]; + NSRect screenRect = [[window_info->window screen] frame]; NSRect viewRect = [window_info->view frame]; NSRect winRect = [window_info->window frame]; @@ -81,11 +81,11 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nSetCursorPositio p.y = winRect.origin.y + viewPoint.y + (viewRect.size.height - y - 1); p.x = winRect.origin.x + viewPoint.x + x; - // flip y coordinates (origin top left) to allow use with CGWarpMouseCursorPosition + // flip y coordinates (origin top left) to allow use with CGDisplayMoveCursorToPoint p.y = screenRect.size.height - p.y - 1; } - CGWarpMouseCursorPosition(p); + CGDisplayMoveCursorToPoint(CGMainDisplayID(), p); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nRegisterMouseListener(JNIEnv *env, jobject _this, jobject window_handle) {