Fixed X11 character input for C locale.

Fixes #396.
This commit is contained in:
Camilla Berglund 2014-12-18 02:52:06 +01:00
parent 44372b89f6
commit b2030f6d73
4 changed files with 11 additions and 3 deletions

View File

@ -144,6 +144,7 @@ GLFW bundles a number of dependencies in the `deps/` directory.
- [X11] Bugfix: X-axis scroll offsets were inverted
- [X11] Bugfix: Full screen override redirect windows were not always
positioned over the specified monitor
- [X11] Bugfix: Character input did not work for the default `"C"` locale
## Contact

View File

@ -1089,6 +1089,12 @@ typedef struct GLFWimage
* bundle, if present. This can be disabled with a
* [compile-time option](@ref compile_options_osx).
*
* @remarks __X11:__ If the `LC_CTYPE` category of the current locale is set to
* `"C"` then the environment's locale will be applied to that category. This
* is done because character input will not function when `LC_CTYPE` is set to
* `"C"`. If another locale was set before this function was called, it will
* be left untouched.
*
* @par Thread Safety
* This function may only be called from the main thread.
*

View File

@ -33,6 +33,7 @@
#include <string.h>
#include <limits.h>
#include <stdio.h>
#include <locale.h>
// Translate an X11 key code to a GLFW key code.
@ -709,6 +710,9 @@ Cursor _glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
int _glfwPlatformInit(void)
{
if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0)
setlocale(LC_CTYPE, "");
XInitThreads();
_glfw.x11.display = XOpenDisplay(NULL);

View File

@ -37,7 +37,6 @@
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <locale.h>
#include "getopt.h"
@ -443,8 +442,6 @@ int main(int argc, char** argv)
GLFWmonitor* monitor = NULL;
int ch, i, width, height, count = 1;
setlocale(LC_ALL, "");
glfwSetErrorCallback(error_callback);
if (!glfwInit())