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:
parent
fffa870418
commit
a4c5be3781
|
@ -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) {
|
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);
|
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];
|
NSRect winRect = [[window_info->view window] frame];
|
||||||
|
|
||||||
// get top corner of window frame, also flip coords so origin is in top left
|
// get top corner of window frame, also flip coords so origin is in top left
|
||||||
|
|
|
@ -70,7 +70,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nSetCursorPositio
|
||||||
p.y = point.y;
|
p.y = point.y;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NSRect screenRect = [[NSScreen mainScreen] frame];
|
NSRect screenRect = [[window_info->window screen] frame];
|
||||||
NSRect viewRect = [window_info->view frame];
|
NSRect viewRect = [window_info->view frame];
|
||||||
NSRect winRect = [window_info->window 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.y = winRect.origin.y + viewPoint.y + (viewRect.size.height - y - 1);
|
||||||
|
|
||||||
p.x = winRect.origin.x + viewPoint.x + x;
|
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;
|
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) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nRegisterMouseListener(JNIEnv *env, jobject _this, jobject window_handle) {
|
||||||
|
|
Loading…
Reference in New Issue