X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=inline;f=openbox%2Ftranslate.c;h=a7cac55721328e0da76eeb14bfc272ccde86172e;hb=a6f52b90551621316a36f7cd7b20ef1d5dca0782;hp=97066519f4b9f0cf73e53826e77a59e398cf5777;hpb=5d5be2ba2a6e0b3886e0076475ed9d7a2d4ac9ab;p=chaz%2Fopenbox diff --git a/openbox/translate.c b/openbox/translate.c index 97066519..a7cac557 100644 --- a/openbox/translate.c +++ b/openbox/translate.c @@ -149,3 +149,19 @@ const gchar *translate_keycode(guint keycode) ret = XKeysymToString(sym); return g_locale_to_utf8(ret, -1, NULL, NULL, NULL); } + +gunichar translate_unichar(guint keycode) +{ + gunichar unikey = 0; + + const char *key; + if ((key = translate_keycode(keycode)) != NULL && + /* don't accept keys that aren't a single letter, like "space" */ + key[1] == '\0') + { + unikey = g_utf8_get_char_validated(key, -1); + if (unikey == (gunichar)-1 || unikey == (gunichar)-2 || unikey == 0) + unikey = 0; + } + return unikey; +}