mirror of
https://github.com/glfw/glfw.git
synced 2024-11-29 23:54:37 +00:00
Fixed duplicate key presses caused by XIM.
Probably.
This commit is contained in:
parent
cc4c232956
commit
cf4206d987
@ -867,35 +867,42 @@ static void processEvent(XEvent *event)
|
|||||||
const int mods = translateState(event->xkey.state);
|
const int mods = translateState(event->xkey.state);
|
||||||
const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
|
const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
|
||||||
|
|
||||||
if (event->xkey.keycode)
|
|
||||||
_glfwInputKey(window, key, event->xkey.keycode, GLFW_PRESS, mods);
|
|
||||||
|
|
||||||
if (window->x11.ic)
|
if (window->x11.ic)
|
||||||
{
|
{
|
||||||
// Translate keys to characters with XIM input context
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
Status status;
|
Status status;
|
||||||
wchar_t buffer[16];
|
wchar_t buffer[16];
|
||||||
|
|
||||||
if (filtered)
|
if (filtered)
|
||||||
return;
|
{
|
||||||
|
// HACK: Ignore key press events intended solely for XIM
|
||||||
|
if (event->xkey.keycode)
|
||||||
|
{
|
||||||
|
_glfwInputKey(window,
|
||||||
|
key, event->xkey.keycode,
|
||||||
|
GLFW_PRESS, mods);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const int count = XwcLookupString(window->x11.ic,
|
||||||
|
&event->xkey,
|
||||||
|
buffer, sizeof(buffer),
|
||||||
|
NULL, &status);
|
||||||
|
|
||||||
const int count = XwcLookupString(window->x11.ic,
|
for (i = 0; i < count; i++)
|
||||||
&event->xkey,
|
_glfwInputChar(window, buffer[i], mods, plain);
|
||||||
buffer, sizeof(buffer),
|
}
|
||||||
NULL, &status);
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
_glfwInputChar(window, buffer[i], mods, plain);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Translate keys to characters with fallback lookup table
|
|
||||||
|
|
||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
XLookupString(&event->xkey, NULL, 0, &keysym, NULL);
|
XLookupString(&event->xkey, NULL, 0, &keysym, NULL);
|
||||||
|
|
||||||
|
_glfwInputKey(window,
|
||||||
|
key, event->xkey.keycode,
|
||||||
|
GLFW_PRESS, mods);
|
||||||
|
|
||||||
const long character = _glfwKeySym2Unicode(keysym);
|
const long character = _glfwKeySym2Unicode(keysym);
|
||||||
if (character != -1)
|
if (character != -1)
|
||||||
_glfwInputChar(window, character, mods, plain);
|
_glfwInputChar(window, character, mods, plain);
|
||||||
|
Loading…
Reference in New Issue
Block a user