diff --git a/key.c b/key.c index 28f50534..ace5ab12 100644 --- a/key.c +++ b/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. diff --git a/key.h b/key.h index 9a8d986c..38dbd699 100644 --- a/key.h +++ b/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 *); diff --git a/keygrabber.c b/keygrabber.c index 15a93a90..c5b33bb2 100644 --- a/keygrabber.c +++ b/keygrabber.c @@ -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);