X11: Fix CJK IME input when locale CTYPE is "C"

Fixes #1587.
Fixes #1636.
This commit is contained in:
Camilla Löwy 2020-02-06 15:46:37 +01:00
parent 27d19d06ca
commit 4381b86b6b
3 changed files with 9 additions and 7 deletions

View File

@ -167,6 +167,7 @@ information on what to include when reporting a bug.
- [X11] Bugfix: Window position events were not emitted during resizing (#1613)
- [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM
- [X11] Bugfix: Querying a disconnected monitor could segfault (#1602)
- [X11] Bugfix: IME input of CJK was broken for "C" locale (#1587,#1636)
- [Wayland] Removed support for `wl_shell` (#1443)
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled

View File

@ -1831,6 +1831,10 @@ typedef struct GLFWgamepadstate
* bundle, if present. This can be disabled with the @ref
* GLFW_COCOA_CHDIR_RESOURCES init hint.
*
* @remark @x11 This function will set the `LC_CTYPE` category of the
* application locale according to the current environment if that category is
* still "C". This is because the "C" locale breaks Unicode text input.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref intro_init

View File

@ -936,15 +936,12 @@ Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot)
int _glfwPlatformInit(void)
{
#if !defined(X_HAVE_UTF8_STRING)
// HACK: If the current locale is "C" and the Xlib UTF-8 functions are
// unavailable, apply the environment's locale in the hope that it's
// both available and not "C"
// This is done because the "C" locale breaks wide character input,
// which is what we fall back on when UTF-8 support is missing
// HACK: If the application has left the locale as "C" then both wide
// character text input and explicit UTF-8 input via XIM will break
// This sets the CTYPE part of the current locale from the environment
// in the hope that it is set to something more sane than "C"
if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0)
setlocale(LC_CTYPE, "");
#endif
#if defined(__CYGWIN__)
_glfw.x11.xlib.handle = _glfw_dlopen("libX11-6.so");