From f9ca95df8ef9f9802cd5c3fe82006a9e016340e7 Mon Sep 17 00:00:00 2001 From: khanhduytran0 Date: Sun, 1 Oct 2023 21:00:14 +0700 Subject: [PATCH] Fix a regression in 32d2d78 Cleanup in the said commit accidentally removed pause on idle --- Natives/SceneDelegate.m | 1 + Natives/input_bridge_v3.m | 16 ++-------------- Natives/utils.h | 2 +- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/Natives/SceneDelegate.m b/Natives/SceneDelegate.m index 2837c265..ff67d775 100644 --- a/Natives/SceneDelegate.m +++ b/Natives/SceneDelegate.m @@ -48,6 +48,7 @@ // Called as the scene transitions from the foreground to the background. // Use this method to save data, release shared resources, and store enough scene-specific state information // to restore the scene back to its current state. + CallbackBridge_pauseGameIfNeed(); } @end diff --git a/Natives/input_bridge_v3.m b/Natives/input_bridge_v3.m index 861190a2..9830f7bf 100644 --- a/Natives/input_bridge_v3.m +++ b/Natives/input_bridge_v3.m @@ -592,21 +592,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_GLFW_nglfwSetShowingWindow(JNIEnv* en showingWindow = (long) window; } -void CallbackBridge_setWindowAttrib(int attrib, int value) { - if (attrib == GLFW_VISIBLE && value == 0 && isGrabbing) { +void CallbackBridge_pauseGameIfNeed() { + if (isGrabbing) { CallbackBridge_nativeSendKey(GLFW_KEY_ESCAPE, 0, 1, 0); CallbackBridge_nativeSendKey(GLFW_KEY_ESCAPE, 0, 0, 0); } - - if (!showingWindow || !isUseStackQueueCall) { - // If the window is not shown, there is nothing to do yet. - // For Minecraft < 1.13, calling to JNI functions here crashes the JVM for some reason, therefore it is skipped for now. - return; - } - - (*runtimeJNIEnvPtr)->CallStaticVoidMethod( - runtimeJNIEnvPtr, - vmGlfwClass, method_glfwSetWindowAttrib, - (jlong) showingWindow, attrib, value - ); } diff --git a/Natives/utils.h b/Natives/utils.h index 7f503de1..6f4c6540 100644 --- a/Natives/utils.h +++ b/Natives/utils.h @@ -105,4 +105,4 @@ void CallbackBridge_nativeSendMouseButton(int button, int action, int mods); void CallbackBridge_nativeSendScreenSize(int width, int height); void CallbackBridge_nativeSendScroll(CGFloat xoffset, CGFloat yoffset); void CallbackBridge_sendKeycode(int keycode, jchar keychar, int scancode, int modifiers, BOOL isDown); -void CallbackBridge_setWindowAttrib(int attrib, int value); +void CallbackBridge_pauseGameIfNeed();