Native cursor fix in win32
This commit is contained in:
parent
764c2da971
commit
533fb6882f
|
@ -249,18 +249,18 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor
|
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor
|
||||||
(JNIEnv *env, jclass clazz, jlong cursor_handle)
|
(JNIEnv *env, jclass clazz, jlong cursor_handle)
|
||||||
{
|
{
|
||||||
|
if (mDIDevice == NULL)
|
||||||
|
throwException(env, "null device!");
|
||||||
if (cursor_handle != 0) {
|
if (cursor_handle != 0) {
|
||||||
if (mDIDevice == NULL)
|
|
||||||
throwException(env, "null device!");
|
|
||||||
mDIDevice->Unacquire();
|
|
||||||
if(mDIDevice->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND) != DI_OK) {
|
|
||||||
throwException(env, "Could not set the CooperativeLevel.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
HCURSOR cursor = (HCURSOR)cursor_handle;
|
HCURSOR cursor = (HCURSOR)cursor_handle;
|
||||||
SetClassLong(hwnd, GCL_HCURSOR, (LONG)cursor);
|
SetClassLong(hwnd, GCL_HCURSOR, (LONG)cursor);
|
||||||
SetCursor(cursor);
|
SetCursor(cursor);
|
||||||
if (!usingNativeCursor) {
|
if (!usingNativeCursor) {
|
||||||
|
mDIDevice->Unacquire();
|
||||||
|
if(mDIDevice->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND) != DI_OK) {
|
||||||
|
throwException(env, "Could not set the CooperativeLevel.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
/* Reset cursor position to middle of the window */
|
/* Reset cursor position to middle of the window */
|
||||||
RECT clientRect;
|
RECT clientRect;
|
||||||
GetWindowRect(hwnd, &windowRect);
|
GetWindowRect(hwnd, &windowRect);
|
||||||
|
@ -282,6 +282,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor
|
||||||
}
|
}
|
||||||
ShowCursor(FALSE);
|
ShowCursor(FALSE);
|
||||||
usingNativeCursor = false;
|
usingNativeCursor = false;
|
||||||
|
mDIDevice->Acquire();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue