Mac OS X: Don't hide mouse mouse when already hidden (because the cursor state is counted)
This commit is contained in:
parent
26ce1fecae
commit
f65ae73d47
|
@ -270,9 +270,9 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void grabMouse(boolean grab) {
|
public void grabMouse(boolean grab) {
|
||||||
nGrabMouse(grab);
|
|
||||||
mouse_queue.setGrabbed(grab);
|
mouse_queue.setGrabbed(grab);
|
||||||
warpCursor();
|
warpCursor();
|
||||||
|
nGrabMouse(grab);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void nWarpCursor(int x, int y);
|
private native void nWarpCursor(int x, int y);
|
||||||
|
@ -294,7 +294,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
with another setCursor.
|
with another setCursor.
|
||||||
2. When the cursor is moving in the top pixel row (y = 0 in AWT coordinates) in fullscreen
|
2. When the cursor is moving in the top pixel row (y = 0 in AWT coordinates) in fullscreen
|
||||||
mode, no mouse moved events are reported, even though mouse pressed/released and dragged
|
mode, no mouse moved events are reported, even though mouse pressed/released and dragged
|
||||||
are reported
|
events are reported
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,12 +43,18 @@
|
||||||
#include <ApplicationServices/ApplicationServices.h>
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
#include "common_tools.h"
|
#include "common_tools.h"
|
||||||
|
|
||||||
|
static bool is_grabbed;
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGrabMouse(JNIEnv *env, jobject this, jboolean grab) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGrabMouse(JNIEnv *env, jobject this, jboolean grab) {
|
||||||
CGAssociateMouseAndMouseCursorPosition(grab == JNI_TRUE ? FALSE : TRUE);
|
bool new_grabbed = grab == JNI_TRUE;
|
||||||
if (grab == JNI_TRUE)
|
if (is_grabbed != new_grabbed) {
|
||||||
|
is_grabbed = new_grabbed;
|
||||||
|
CGAssociateMouseAndMouseCursorPosition(is_grabbed ? FALSE : TRUE);
|
||||||
|
if (is_grabbed)
|
||||||
CGDisplayHideCursor(kCGDirectMainDisplay);
|
CGDisplayHideCursor(kCGDirectMainDisplay);
|
||||||
else
|
else
|
||||||
CGDisplayShowCursor(kCGDirectMainDisplay);
|
CGDisplayShowCursor(kCGDirectMainDisplay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nWarpCursor(JNIEnv *env, jobject this, jint x, jint y) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nWarpCursor(JNIEnv *env, jobject this, jint x, jint y) {
|
||||||
|
|
Loading…
Reference in New Issue