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
This commit is contained in:
kappaOne 2012-12-25 14:00:09 +00:00
parent fffa870418
commit a4c5be3781
2 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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) {