From 33cd091d02eb6a2c0cdbb2b43aeec009f6adc057 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 18 Jan 2019 17:24:27 +0100 Subject: [PATCH] Use existing xkbcommon functionality instead of XKeysymToString Signed-off-by: Uli Schlachter --- luaa.c | 4 +++- objects/key.c | 8 ++++---- objects/key.h | 3 +++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/luaa.c b/luaa.c index f0e98baa9..f01ca6edc 100644 --- a/luaa.c +++ b/luaa.c @@ -495,7 +495,9 @@ static int luaA_get_modifiers(lua_State *L) lua_settable(L, -3); lua_pushstring(L, "keysym"); - lua_pushstring(L, XKeysymToString(key_sym)); + char *string = key_get_keysym_name(key_sym); + lua_pushstring(L, string); + p_delete(&string); lua_settable(L, -3); lua_settable(L, -3); diff --git a/objects/key.c b/objects/key.c index 94f73ebad..932921ca2 100644 --- a/objects/key.c +++ b/objects/key.c @@ -275,8 +275,8 @@ luaA_key_set_modifiers(lua_State *L, keyb_t *k) LUA_OBJECT_EXPORT_PROPERTY(key, keyb_t, modifiers, luaA_pushmodifiers) /* It's caller's responsibility to release the returned string. */ -static char * -get_keysym_name(xkb_keysym_t keysym) +char * +key_get_keysym_name(xkb_keysym_t keysym) { const ssize_t bufsize = 64; char *buf = p_new(char, bufsize); @@ -310,7 +310,7 @@ luaA_key_get_key(lua_State *L, keyb_t *k) } else { - char *name = get_keysym_name(k->keysym); + char *name = key_get_keysym_name(k->keysym); if(!name) return 0; lua_pushstring(L, name); @@ -322,7 +322,7 @@ luaA_key_get_key(lua_State *L, keyb_t *k) static int luaA_key_get_keysym(lua_State *L, keyb_t *k) { - char *name = get_keysym_name(k->keysym); + char *name = key_get_keysym_name(k->keysym); if(!name) return 0; lua_pushstring(L, name); diff --git a/objects/key.h b/objects/key.h index f54273679..8aa07ffe3 100644 --- a/objects/key.h +++ b/objects/key.h @@ -23,6 +23,7 @@ #define AWESOME_OBJECTS_KEY_H #include "common/luaobject.h" +#include typedef struct keyb_t { @@ -47,6 +48,8 @@ int luaA_key_array_get(lua_State *, int, key_array_t *); int luaA_pushmodifiers(lua_State *, uint16_t); uint16_t luaA_tomodifiers(lua_State *L, int ud); +char * key_get_keysym_name(xkb_keysym_t keysym); + #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80