Fix 1.13+ mouse not working when pressing too soon

This commit is contained in:
SerpentSpirale 2022-03-14 22:29:30 +01:00 committed by Boulay Mathias
parent e42251a836
commit 2ad0a2ff42
2 changed files with 17 additions and 4 deletions

View File

@ -36,6 +36,7 @@ public class CallbackBridge {
public static void sendCursorPos(float x, float y) {
if (!threadAttached) {
nativeSetUseInputStackQueue(BaseMainActivity.isInputStackCall);
threadAttached = CallbackBridge.nativeAttachThreadToOther(true, BaseMainActivity.isInputStackCall);
}
@ -198,6 +199,7 @@ public class CallbackBridge {
}
}
public static native void nativeSetUseInputStackQueue(boolean useInputStackQueue);
public static native boolean nativeAttachThreadToOther(boolean isAndroid, boolean isUsePushPoll);
private static native boolean nativeSendChar(char codepoint);

View File

@ -159,14 +159,20 @@ void closeGLFWWindow() {
exit(-1);
}
JNIEXPORT void JNICALL
Java_org_lwjgl_glfw_CallbackBridge_nativeSetUseInputStackQueue(JNIEnv *env, jclass clazz,
jboolean use_input_stack_queue) {
isUseStackQueueCall = (int) use_input_stack_queue;
}
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeAttachThreadToOther(JNIEnv* env, jclass clazz, jboolean isAndroid, jboolean isUseStackQueueBool) {
#ifdef DEBUG
LOGD("Debug: JNI attaching thread, isUseStackQueue=%d\n", isUseStackQueue);
LOGD("Debug: JNI attaching thread, isUseStackQueue=%d\n", isUseStackQueueBool);
#endif
jboolean result;
isUseStackQueueCall = (int) isUseStackQueueBool;
//isUseStackQueueCall = (int) isUseStackQueueBool;
if (isAndroid) {
result = attachThread(true, &runtimeJNIEnvPtr_ANDROID);
} else {
@ -256,7 +262,13 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendCursorEnter(
}
*/
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendCursorPos(JNIEnv* env, jclass clazz, jfloat x, jfloat y) {
#ifdef DEBUG
LOGD("Sending cursor position \n");
#endif
if (GLFW_invoke_CursorPos && isInputReady) {
#ifdef DEBUG
LOGD("GLFW_invoke_CursorPos && isInputReady \n");
#endif
if (!isCursorEntered) {
if (GLFW_invoke_CursorEnter) {
isCursorEntered = true;
@ -380,4 +392,3 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSetWindowAttrib(
(jlong) showingWindow, attrib, value
);
}