Skip to content

Commit

Permalink
feat(glfw) add experimental support for IME
Browse files Browse the repository at this point in the history
Close #946
  • Loading branch information
Spasi committed Dec 2, 2023
1 parent df470a4 commit 92777ed
Show file tree
Hide file tree
Showing 12 changed files with 1,014 additions and 13 deletions.
4 changes: 4 additions & 0 deletions doc/notes/3.3.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ This build includes the following changes:
- bgfx: Updated to API version 123 (up from 122)
* Windows: support for the Direct3D 9 backend has been dropped.
- FMOD: Updated to 2.02.19 (up from 2.02.16)
- glfw: Added experimental support for IME. (#946)
* Added `GLFW_SOFT_FULLSCREEN`, `GLFW_IME`, `GLFW_MANAGE_PREEDIT_CANDIDATE` and `GLFW_X11_ONTHESPOT`.
* Added `glfwGetPreeditCursorRectangle`, `glfwSetPreeditCursorRectangle`, `glfwResetPreeditText`, `glfwGetPreeditCandidate`.
* Added `glfwSetPreeditCallback`, `glfwSetIMEStatusCallback`, `glfwSetPreeditCandidateCallback`.
- harfbuzz: Updated to 8.3.0 (up from 8.2.0)
- liburing: Updated to 2.5 (up from 2.4)
- LLVM/Clang: Updated to 17.0.4 (up from 16.0.0)
Expand Down
4 changes: 4 additions & 0 deletions modules/lwjgl/core/src/generated/c/org_lwjgl_system_JNI.c
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_system_JNI_invokePPPV__JIIJIJIJ(JNIEnv *__
UNUSED_PARAMS(__env, clazz)
((void (*) (uintptr_t, jint, jint, uintptr_t, jint, uintptr_t, jint))(uintptr_t)__functionAddress)((uintptr_t)param0, param1, param2, (uintptr_t)param3, param4, (uintptr_t)param5, param6);
}
JNIEXPORT void JNICALL Java_org_lwjgl_system_JNI_invokePPPV__JIJIJIIJ(JNIEnv *__env, jclass clazz, jlong param0, jint param1, jlong param2, jint param3, jlong param4, jint param5, jint param6, jlong __functionAddress) {
UNUSED_PARAMS(__env, clazz)
((void (*) (uintptr_t, jint, uintptr_t, jint, uintptr_t, jint, jint))(uintptr_t)__functionAddress)((uintptr_t)param0, param1, (uintptr_t)param2, param3, (uintptr_t)param4, param5, param6);
}
JNIEXPORT void JNICALL Java_org_lwjgl_system_JNI_invokePPPV__JJFFFFJJ(JNIEnv *__env, jclass clazz, jlong param0, jlong param1, jfloat param2, jfloat param3, jfloat param4, jfloat param5, jlong param6, jlong __functionAddress) {
UNUSED_PARAMS(__env, clazz)
((void (*) (uintptr_t, uintptr_t, jfloat, jfloat, jfloat, jfloat, uintptr_t))(uintptr_t)__functionAddress)((uintptr_t)param0, (uintptr_t)param1, param2, param3, param4, param5, (uintptr_t)param6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ private JNI() {}
public static native void invokePPPV(long param0, long param1, long param2, int param3, boolean param4, boolean param5, long __functionAddress);
public static native void invokePPPV(long param0, boolean param1, int param2, long param3, long param4, int param5, long __functionAddress);
public static native void invokePPPV(long param0, int param1, int param2, long param3, int param4, long param5, int param6, long __functionAddress);
public static native void invokePPPV(long param0, int param1, long param2, int param3, long param4, int param5, int param6, long __functionAddress);
public static native void invokePPPV(long param0, long param1, float param2, float param3, float param4, float param5, long param6, long __functionAddress);
public static native void invokePPPV(long param0, long param1, long param2, float param3, float param4, float param5, float param6, long __functionAddress);
public static native void invokePPPV(long param0, long param1, int param2, int param3, int param4, long param5, int param6, boolean param7, long __functionAddress);
Expand Down
301 changes: 293 additions & 8 deletions modules/lwjgl/glfw/src/generated/java/org/lwjgl/glfw/GLFW.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;

import javax.annotation.*;

import org.lwjgl.system.*;

import static org.lwjgl.system.MemoryUtil.*;

import static org.lwjgl.glfw.GLFW.*;

/**
* Instances of this class may be passed to the {@link GLFW#glfwSetIMEStatusCallback SetIMEStatusCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window
* )</code></pre>
*
* @since version 3.X
*/
public abstract class GLFWIMEStatusCallback extends Callback implements GLFWIMEStatusCallbackI {

/**
* Creates a {@code GLFWIMEStatusCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWIMEStatusCallback}
*/
public static GLFWIMEStatusCallback create(long functionPointer) {
GLFWIMEStatusCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWIMEStatusCallback
? (GLFWIMEStatusCallback)instance
: new Container(functionPointer, instance);
}

/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWIMEStatusCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}

/** Creates a {@code GLFWIMEStatusCallback} instance that delegates to the specified {@code GLFWIMEStatusCallbackI} instance. */
public static GLFWIMEStatusCallback create(GLFWIMEStatusCallbackI instance) {
return instance instanceof GLFWIMEStatusCallback
? (GLFWIMEStatusCallback)instance
: new Container(instance.address(), instance);
}

protected GLFWIMEStatusCallback() {
super(CIF);
}

GLFWIMEStatusCallback(long functionPointer) {
super(functionPointer);
}

/** See {@link GLFW#glfwSetIMEStatusCallback SetIMEStatusCallback}. */
public GLFWIMEStatusCallback set(long window) {
glfwSetIMEStatusCallback(window, this);
return this;
}

private static final class Container extends GLFWIMEStatusCallback {

private final GLFWIMEStatusCallbackI delegate;

Container(long functionPointer, GLFWIMEStatusCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}

@Override
public void invoke(long window) {
delegate.invoke(window);
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;

import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;

import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;

/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetIMEStatusCallback SetIMEStatusCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window
* )</code></pre>
*
* @since version 3.X
*/
@FunctionalInterface
@NativeType("GLFWimestatusfun")
public interface GLFWIMEStatusCallbackI extends CallbackI {

FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer
);

@Override
default FFICIF getCallInterface() { return CIF; }

@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args))
);
}

/**
* The function pointer type for IME status change callbacks.
*
* @param window the window that received the event
*/
void invoke(@NativeType("GLFWwindow *") long window);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;

import javax.annotation.*;

import org.lwjgl.system.*;

import static org.lwjgl.system.MemoryUtil.*;

import static org.lwjgl.glfw.GLFW.*;

/**
* Instances of this class may be passed to the {@link GLFW#glfwSetPreeditCallback SetPreeditCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int preedit_count,
* unsigned int *preedit_string,
* int block_count,
* int *block_sizes,
* int focused_block,
* int caret
* )</code></pre>
*
* @since version 3.X
*/
public abstract class GLFWPreeditCallback extends Callback implements GLFWPreeditCallbackI {

/**
* Creates a {@code GLFWPreeditCallback} instance from the specified function pointer.
*
* @return the new {@code GLFWPreeditCallback}
*/
public static GLFWPreeditCallback create(long functionPointer) {
GLFWPreeditCallbackI instance = Callback.get(functionPointer);
return instance instanceof GLFWPreeditCallback
? (GLFWPreeditCallback)instance
: new Container(functionPointer, instance);
}

/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
@Nullable
public static GLFWPreeditCallback createSafe(long functionPointer) {
return functionPointer == NULL ? null : create(functionPointer);
}

/** Creates a {@code GLFWPreeditCallback} instance that delegates to the specified {@code GLFWPreeditCallbackI} instance. */
public static GLFWPreeditCallback create(GLFWPreeditCallbackI instance) {
return instance instanceof GLFWPreeditCallback
? (GLFWPreeditCallback)instance
: new Container(instance.address(), instance);
}

protected GLFWPreeditCallback() {
super(CIF);
}

GLFWPreeditCallback(long functionPointer) {
super(functionPointer);
}

/** See {@link GLFW#glfwSetPreeditCallback SetPreeditCallback}. */
public GLFWPreeditCallback set(long window) {
glfwSetPreeditCallback(window, this);
return this;
}

private static final class Container extends GLFWPreeditCallback {

private final GLFWPreeditCallbackI delegate;

Container(long functionPointer, GLFWPreeditCallbackI delegate) {
super(functionPointer);
this.delegate = delegate;
}

@Override
public void invoke(long window, int preedit_count, long preedit_string, int block_count, long block_sizes, int focused_block, int caret) {
delegate.invoke(window, preedit_count, preedit_string, block_count, block_sizes, focused_block, caret);
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.glfw;

import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;

import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;

/**
* Instances of this interface may be passed to the {@link GLFW#glfwSetPreeditCallback SetPreeditCallback} method.
*
* <h3>Type</h3>
*
* <pre><code>
* void (*{@link #invoke}) (
* GLFWwindow *window,
* int preedit_count,
* unsigned int *preedit_string,
* int block_count,
* int *block_sizes,
* int focused_block,
* int caret
* )</code></pre>
*
* @since version 3.X
*/
@FunctionalInterface
@NativeType("GLFWpreeditfun")
public interface GLFWPreeditCallbackI extends CallbackI {

FFICIF CIF = apiCreateCIF(
FFI_DEFAULT_ABI,
ffi_type_void,
ffi_type_pointer, ffi_type_sint32, ffi_type_pointer, ffi_type_sint32, ffi_type_pointer, ffi_type_sint32, ffi_type_sint32
);

@Override
default FFICIF getCallInterface() { return CIF; }

@Override
default void callback(long ret, long args) {
invoke(
memGetAddress(memGetAddress(args)),
memGetInt(memGetAddress(args + POINTER_SIZE)),
memGetAddress(memGetAddress(args + 2 * POINTER_SIZE)),
memGetInt(memGetAddress(args + 3 * POINTER_SIZE)),
memGetAddress(memGetAddress(args + 4 * POINTER_SIZE)),
memGetInt(memGetAddress(args + 5 * POINTER_SIZE)),
memGetInt(memGetAddress(args + 6 * POINTER_SIZE))
);
}

/**
* The function pointer type for preedit callbacks.
*
* @param window the window that received the event
* @param preedit_count preedit string count
* @param preedit_string preedit string
* @param block_count attributed block count
* @param block_sizes list of attributed block size
* @param focused_block Focused block index
* @param caret Caret position
*/
void invoke(@NativeType("GLFWwindow *") long window, int preedit_count, @NativeType("unsigned int *") long preedit_string, int block_count, @NativeType("int *") long block_sizes, int focused_block, int caret);

}
Loading

0 comments on commit 92777ed

Please sign in to comment.