This commit is contained in:
Thomas Oltmann 2026-09-15 13:21:07 +00:00 • committed by GitHub
commit 85130d7821
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1250,6 +1250,14 @@ 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));
// HACK: If the control key modifier is applied, then X[utf8]LookupString()
// will interpret the key press not as (part of) a unicode codepoint,
// but instead as a (fake) ASCII control character.
// We avoid this behaviour by removing the control key modifier before
// handing the key press event to XLookupString().
XKeyEvent noctrlkey = event->xkey;
noctrlkey.state &= ~ControlMask;
if (window->x11.ic) if (window->x11.ic)
{ {
// HACK: Do not report the key press events duplicated by XIM // HACK: Do not report the key press events duplicated by XIM
@ -1276,7 +1284,7 @@ static void processEvent(XEvent *event)
char* chars = buffer; char* chars = buffer;
count = Xutf8LookupString(window->x11.ic, count = Xutf8LookupString(window->x11.ic,
&event->xkey, &noctrlkey,
buffer, sizeof(buffer) - 1, buffer, sizeof(buffer) - 1,
NULL, &status); NULL, &status);
@ -1284,7 +1292,7 @@ static void processEvent(XEvent *event)
{ {
chars = _glfw_calloc(count + 1, 1); chars = _glfw_calloc(count + 1, 1);
count = Xutf8LookupString(window->x11.ic, count = Xutf8LookupString(window->x11.ic,
&event->xkey, &noctrlkey,
chars, count, chars, count,
NULL, &status); NULL, &status);
} }
@ -1304,7 +1312,7 @@ static void processEvent(XEvent *event)
else else
{ {
KeySym keysym; KeySym keysym;
XLookupString(&event->xkey, NULL, 0, &keysym, NULL); XLookupString(&noctrlkey, NULL, 0, &keysym, NULL);
_glfwInputKey(window, key, keycode, GLFW_PRESS, mods); _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);