fix(glfw): implement missing methods

Added `glfwGetWindowTitle` (which doesn't seem to be used by Minecraft)
Added `glfwPlatformSupported`
Added `glfwSetPreeditCallback`, `glfwSetPreeditCandidateCallback`,
`glfwSetIMEStatusCallback`
This commit is contained in:
alexytomi
2026-03-11 00:53:41 +08:00
parent 11e3472a05
commit 6ca2bb12f7

View File

@@ -493,6 +493,10 @@ public class GLFW
/* volatile */ public static GLFWWindowPosCallback mGLFWWindowPosCallback;
/* volatile */ public static GLFWWindowRefreshCallback mGLFWWindowRefreshCallback;
public static GLFWPreeditCallback mGLFWPreeditCallback;
public static GLFWIMEStatusCallback mGLFWIMEStatusCallback;
public static GLFWPreeditCandidateCallback mGLFWPreeditCandidateCallback;
// Store callback method references directly to avoid a roundtrip through
// JNI when calling the default LWJGL callbacks.
@Nullable public static GLFWFramebufferSizeCallbackI mGLFWFramebufferSizeCallbackI;
@@ -794,6 +798,28 @@ public class GLFW
return lastCallback;
}
public static GLFWPreeditCallback glfwSetPreeditCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWpreeditfun") GLFWPreeditCallbackI cbfun) {
GLFWPreeditCallback lastCallback = mGLFWPreeditCallback;
if (cbfun == null) mGLFWPreeditCallback = null;
else mGLFWPreeditCallback = GLFWPreeditCallback.create(cbfun);
return lastCallback;
}
public static GLFWIMEStatusCallback glfwSetIMEStatusCallback(@NativeType("GLFWwindow *") long window, @NativeType("GLFWimestatusfun") @Nullable GLFWIMEStatusCallbackI cbfun) {
GLFWIMEStatusCallback lastCallback = mGLFWIMEStatusCallback;
if (cbfun == null) mGLFWIMEStatusCallback = null;
else mGLFWIMEStatusCallback = GLFWIMEStatusCallback.create(cbfun);
return lastCallback;
}
public static GLFWPreeditCandidateCallback glfwSetPreeditCandidateCallback(@NativeType("GLFWwindow *") long window, @NativeType("GLFWpreeditcandidatefun") @Nullable GLFWPreeditCandidateCallbackI cbfun) {
GLFWPreeditCandidateCallback lastCallback = mGLFWPreeditCandidateCallback;
if (cbfun == null) mGLFWPreeditCandidateCallback = null;
else mGLFWPreeditCandidateCallback = GLFWPreeditCandidateCallback.create(cbfun);
return lastCallback;
}
public static GLFWWindowSizeCallback glfwSetWindowSizeCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowsizefun") GLFWWindowSizeCallbackI cbfun) {
GLFWWindowSizeCallback previousCallback = null;
if(mGLFWWindowSizeCallbackI != null) {
@@ -832,6 +858,10 @@ public class GLFW
return GLFW_PLATFORM_X11;
}
public static boolean glfwPlatformSupported(int platform) {
return platform == GLFW_PLATFORM_X11;
}
@NativeType("GLFWwindow *")
public static long glfwGetCurrentContext() {
long __functionAddress = Functions.GetCurrentContext;
@@ -1047,6 +1077,10 @@ public class GLFW
nglfwSetShowingWindow(mGLFWWindowMap.size() == 0 ? 0 : mGLFWWindowMap.keyAt(mGLFWWindowMap.size() - 1));
}
public static String glfwGetWindowTitle(long window) {
return internalGetWindow(window).title.toString();
}
public static void glfwDefaultWindowHints() {
mGLFWWindowVisibleOnCreation = true;
}