[FEATURE] Linux 输入法增强
plusls opened this issue · 0 comments
Linux 下使用输入法时,如果按下退格键,会将已经打出的数据删除,按上下左右同样也会有这个现象,根本原因在于
https://github.com/glfw/glfw/blob/master/src/x11_window.c
case KeyPress:
{
const int key = translateKey(keycode);
const int mods = translateState(event->xkey.state);
const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
if (window->x11.ic)
{
// HACK: Do not report the key press events duplicated by XIM
// Duplicate key releases are filtered out implicitly by
// the GLFW key repeat logic in _glfwInputKey
// A timestamp per key is used to handle simultaneous keys
// NOTE: Always allow the first event for each key through
// (the server never sends a timestamp of zero)
// NOTE: Timestamp difference is compared to handle wrap-around
Time diff = event->xkey.time - window->x11.keyPressTimes[keycode];
if (diff == event->xkey.time || (diff > 0 && diff < (1 << 31)))
{
if (keycode)
_glfwInputKey(window, key, keycode, GLFW_PRESS, mods);
window->x11.keyPressTimes[keycode] = event->xkey.time;
}就算是存在输入法的情况下,glfw 同样也会把按键信息回馈给游戏,从而产生了 bug
想一下能不能 fix