Use existing xkbcommon functionality instead of XKeysymToString

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2019-01-18 17:24:27 +01:00 committed by Emmanuel Lepage Vallee
parent 56db19fbef
commit 33cd091d02
3 changed files with 10 additions and 5 deletions

4
luaa.c
View File

@ -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);

View File

@ -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);

View File

@ -23,6 +23,7 @@
#define AWESOME_OBJECTS_KEY_H
#include "common/luaobject.h"
#include <xkbcommon/xkbcommon.h>
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