mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-29 21:48:52 -05:00
Fix XBufferOverflow handling for XIM input
This commit is contained in:
parent
87ad8c0561
commit
0d759c8c1a
|
@ -100,6 +100,7 @@ GLFW bundles a number of dependencies in the `deps/` directory.
|
||||||
- [X11] Bugfix: `glfwWaitEvents` could return when no events were available
|
- [X11] Bugfix: `glfwWaitEvents` could return when no events were available
|
||||||
- [X11] Bugfix: `XkbGetKeyboard` fails on XWayland
|
- [X11] Bugfix: `XkbGetKeyboard` fails on XWayland
|
||||||
- [X11] Bugfix: Character input did not work correctly for non-UTF-8 locales
|
- [X11] Bugfix: Character input did not work correctly for non-UTF-8 locales
|
||||||
|
- [X11] Bugfix: Long input sequences generated by IMEs were discarded
|
||||||
- [WGL] Made all WGL functions dynamically loaded
|
- [WGL] Made all WGL functions dynamically loaded
|
||||||
- [WGL] Removed `GLFW_USE_DWM_SWAP_INTERVAL` compile-time option
|
- [WGL] Removed `GLFW_USE_DWM_SWAP_INTERVAL` compile-time option
|
||||||
- [WGL] Bugfix: Swap interval was ignored when DWM was enabled
|
- [WGL] Bugfix: Swap interval was ignored when DWM was enabled
|
||||||
|
|
|
@ -921,31 +921,60 @@ static void processEvent(XEvent *event)
|
||||||
|
|
||||||
if (!filtered)
|
if (!filtered)
|
||||||
{
|
{
|
||||||
|
int count;
|
||||||
|
Status status;
|
||||||
#if defined(X_HAVE_UTF8_STRING)
|
#if defined(X_HAVE_UTF8_STRING)
|
||||||
Status status;
|
|
||||||
char buffer[96];
|
char buffer[96];
|
||||||
const char* c = buffer;
|
char* chars = buffer;
|
||||||
|
|
||||||
const int count = Xutf8LookupString(window->x11.ic,
|
count = Xutf8LookupString(window->x11.ic,
|
||||||
&event->xkey,
|
&event->xkey,
|
||||||
buffer, sizeof(buffer),
|
buffer, sizeof(buffer),
|
||||||
NULL, &status);
|
NULL, &status);
|
||||||
|
|
||||||
while (c - buffer < count)
|
if (status == XBufferOverflow)
|
||||||
_glfwInputChar(window, decodeUTF8(&c), mods, plain);
|
{
|
||||||
|
chars = calloc(count, 1);
|
||||||
|
count = Xutf8LookupString(window->x11.ic,
|
||||||
|
&event->xkey,
|
||||||
|
chars, count,
|
||||||
|
NULL, &status);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == XLookupChars || status == XLookupBoth)
|
||||||
|
{
|
||||||
|
const char* c = chars;
|
||||||
|
while (c - chars < count)
|
||||||
|
_glfwInputChar(window, decodeUTF8(&c), mods, plain);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
int i;
|
|
||||||
Status status;
|
|
||||||
wchar_t buffer[16];
|
wchar_t buffer[16];
|
||||||
|
wchar_t* chars = buffer;
|
||||||
|
|
||||||
const int count = XwcLookupString(window->x11.ic,
|
count = XwcLookupString(window->x11.ic,
|
||||||
&event->xkey,
|
&event->xkey,
|
||||||
buffer, sizeof(buffer),
|
buffer, sizeof(buffer) / sizeof(wchar_t),
|
||||||
NULL, &status);
|
NULL, &status);
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
if (status == XBufferOverflow)
|
||||||
_glfwInputChar(window, buffer[i], mods, plain);
|
{
|
||||||
|
chars = calloc(count, sizeof(wchar_t));
|
||||||
|
count = XwcLookupString(window->x11.ic,
|
||||||
|
&event->xkey,
|
||||||
|
chars, count,
|
||||||
|
NULL, &status);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == XLookupChars || status == XLookupBoth)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
_glfwInputChar(window, chars[i], mods, plain);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (chars != buffer)
|
||||||
|
free(chars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user