smater way to set latin1 locales in x11
This commit is contained in:
parent
f58ce52be8
commit
77d1ebc8c5
|
@ -193,6 +193,13 @@ void Platform::init()
|
||||||
x11.keyMap[XK_Super_R] = KC_RWIN;
|
x11.keyMap[XK_Super_R] = KC_RWIN;
|
||||||
x11.keyMap[XK_Menu] = KC_APPS;
|
x11.keyMap[XK_Menu] = KC_APPS;
|
||||||
|
|
||||||
|
// try to set a latin1 locales otherwise fallback to standard C locale
|
||||||
|
static char locales[][32] = { "en_US.iso88591", "iso88591", "en_US", "C" };
|
||||||
|
for(int i=0;i<4;++i) {
|
||||||
|
if(setlocale(LC_ALL, locales[i]))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// open display
|
// open display
|
||||||
x11.display = XOpenDisplay(0);
|
x11.display = XOpenDisplay(0);
|
||||||
if(!x11.display)
|
if(!x11.display)
|
||||||
|
@ -287,6 +294,7 @@ void Platform::poll()
|
||||||
keysym != XK_Delete &&
|
keysym != XK_Delete &&
|
||||||
keysym != XK_Escape
|
keysym != XK_Escape
|
||||||
) {
|
) {
|
||||||
|
//debug("char: %c code: %d", buf[0], (unsigned char)buf[0]);
|
||||||
inputEvent.type = EV_TEXT_ENTER;
|
inputEvent.type = EV_TEXT_ENTER;
|
||||||
inputEvent.key.keychar = buf[0];
|
inputEvent.key.keychar = buf[0];
|
||||||
inputEvent.key.keycode = KC_UNKNOWN;
|
inputEvent.key.keycode = KC_UNKNOWN;
|
||||||
|
@ -472,9 +480,7 @@ bool Platform::createWindow(int width, int height, int minWidth, int minHeight)
|
||||||
if(!x11.window)
|
if(!x11.window)
|
||||||
fatal("Unable to create X window");
|
fatal("Unable to create X window");
|
||||||
|
|
||||||
// setup locale to en_US.ISO-8859-1 characters
|
// create input context (to have better key input handling)
|
||||||
// and create input context (to get special characters from input)
|
|
||||||
if(setlocale(LC_ALL, "en_US.ISO-8859-1")) {
|
|
||||||
if(XSupportsLocale()) {
|
if(XSupportsLocale()) {
|
||||||
XSetLocaleModifiers("");
|
XSetLocaleModifiers("");
|
||||||
x11.xim = XOpenIM(x11.display, NULL, NULL, NULL);
|
x11.xim = XOpenIM(x11.display, NULL, NULL, NULL);
|
||||||
|
@ -489,9 +495,6 @@ bool Platform::createWindow(int width, int height, int minWidth, int minHeight)
|
||||||
error("Failed to open an input method");
|
error("Failed to open an input method");
|
||||||
} else
|
} else
|
||||||
error("X11 does not support the current locale");
|
error("X11 does not support the current locale");
|
||||||
}
|
|
||||||
else
|
|
||||||
error("Failed setting locale to latin1");
|
|
||||||
|
|
||||||
if(!x11.xic)
|
if(!x11.xic)
|
||||||
warning("Input of special keys maybe messed up because we couldn't create an input context");
|
warning("Input of special keys maybe messed up because we couldn't create an input context");
|
||||||
|
|
Loading…
Reference in New Issue