key: looking up for a key use a keysym
We do not resolve keycode anymore. Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
bea4aa7f60
commit
e44d62cb09
18
key.c
18
key.c
|
@ -690,21 +690,17 @@ keysym_to_xkb(char *buf, ssize_t len, const xcb_keysym_t ksym)
|
|||
#undef CASE
|
||||
|
||||
bool
|
||||
key_press_lookup_string(uint16_t state,
|
||||
xcb_keycode_t detail,
|
||||
char *buf, ssize_t buf_len,
|
||||
xcb_keysym_t *ksym)
|
||||
key_press_lookup_string(xcb_keysym_t ksym,
|
||||
char *buf, ssize_t buf_len)
|
||||
{
|
||||
*ksym = key_getkeysym(detail, state);
|
||||
|
||||
/* Handle special KeySym (Tab, Newline...) */
|
||||
if((*ksym & 0xffffff00) == 0xff00)
|
||||
return keysym_to_str(buf, buf_len, *ksym);
|
||||
else if((*ksym & 0xfffffe00) == 0xfe00)
|
||||
return keysym_to_xkb(buf, buf_len, *ksym);
|
||||
if((ksym & 0xffffff00) == 0xff00)
|
||||
return keysym_to_str(buf, buf_len, ksym);
|
||||
else if((ksym & 0xfffffe00) == 0xfe00)
|
||||
return keysym_to_xkb(buf, buf_len, ksym);
|
||||
|
||||
/* Handle other KeySym (like unicode...) */
|
||||
return keysym_to_utf8(buf, buf_len, *ksym);
|
||||
return keysym_to_utf8(buf, buf_len, ksym);
|
||||
}
|
||||
|
||||
/** Return the keysym from keycode.
|
||||
|
|
2
key.h
2
key.h
|
@ -42,7 +42,7 @@ typedef struct keyb_t
|
|||
|
||||
ARRAY_TYPE(keyb_t *, key)
|
||||
|
||||
bool key_press_lookup_string(uint16_t, xcb_keycode_t, char *, ssize_t, xcb_keysym_t *);
|
||||
bool key_press_lookup_string(xcb_keysym_t, char *, ssize_t);
|
||||
xcb_keysym_t key_getkeysym(xcb_keycode_t, uint16_t);
|
||||
|
||||
void luaA_key_array_set(lua_State *, int, key_array_t *);
|
||||
|
|
|
@ -61,10 +61,12 @@ keygrabber_grab(void)
|
|||
bool
|
||||
keygrabber_handlekpress(lua_State *L, xcb_key_press_event_t *e)
|
||||
{
|
||||
xcb_keysym_t ksym = 0;
|
||||
char buf[MAX(MB_LEN_MAX, 32)];
|
||||
/* transfer event (keycode + modifiers) to keysym */
|
||||
xcb_keysym_t ksym = key_getkeysym(e->detail, e->state);
|
||||
|
||||
if(!key_press_lookup_string(e->state, e->detail, buf, countof(buf), &ksym))
|
||||
/* convert keysym to string */
|
||||
char buf[MAX(MB_LEN_MAX, 32)];
|
||||
if(!key_press_lookup_string(ksym, buf, countof(buf)))
|
||||
return false;
|
||||
|
||||
luaA_pushmodifiers(L, e->state);
|
||||
|
|
Loading…
Reference in New Issue