common/xutil.c: Stop using a_tokenize

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2010-09-02 19:12:21 +02:00
parent bf3aa6d79e
commit 1f9547b4e0
3 changed files with 23 additions and 20 deletions

View file

@ -29,7 +29,6 @@
#include <xcb/xcb_icccm.h>
#include "common/xutil.h"
#include "common/tokenize.h"
/** Get the lock masks (shiftlock, numlock, capslock, modeswitch).
* \param connection The X connection.
@ -94,23 +93,28 @@ xutil_lock_mask_get(xcb_connection_t *connection,
#define ERRORS_NBR 256
uint16_t
xutil_key_mask_fromstr(const char *keyname, size_t len)
xutil_key_mask_fromstr(const char *keyname)
{
switch(a_tokenize(keyname, len))
{
case A_TK_SHIFT: return XCB_MOD_MASK_SHIFT;
case A_TK_LOCK: return XCB_MOD_MASK_LOCK;
case A_TK_CTRL:
case A_TK_CONTROL: return XCB_MOD_MASK_CONTROL;
case A_TK_MOD1: return XCB_MOD_MASK_1;
case A_TK_MOD2: return XCB_MOD_MASK_2;
case A_TK_MOD3: return XCB_MOD_MASK_3;
case A_TK_MOD4: return XCB_MOD_MASK_4;
case A_TK_MOD5: return XCB_MOD_MASK_5;
if(a_strcmp(keyname, "Shift") == 0)
return XCB_MOD_MASK_SHIFT;
if(a_strcmp(keyname, "Lock") == 0)
return XCB_MOD_MASK_LOCK;
if(a_strcmp(keyname, "Ctrl") == 0 || a_strcmp(keyname, "Control") == 0)
return XCB_MOD_MASK_CONTROL;
if(a_strcmp(keyname, "Mod1") == 0)
return XCB_MOD_MASK_1;
if(a_strcmp(keyname, "Mod2") == 0)
return XCB_MOD_MASK_2;
if(a_strcmp(keyname, "Mod3") == 0)
return XCB_MOD_MASK_3;
if(a_strcmp(keyname, "Mod4") == 0)
return XCB_MOD_MASK_4;
if(a_strcmp(keyname, "Mod5") == 0)
return XCB_MOD_MASK_5;
if(a_strcmp(keyname, "Any") == 0)
/* this is misnamed but correct */
case A_TK_ANY: return XCB_BUTTON_MASK_ANY;
default: return XCB_NO_SYMBOL;
}
return XCB_BUTTON_MASK_ANY;
return XCB_NO_SYMBOL;
}
void

View file

@ -57,7 +57,7 @@ void xutil_lock_mask_get(xcb_connection_t *, xcb_get_modifier_mapping_cookie_t,
xcb_key_symbols_t *,
uint16_t *, uint16_t *, uint16_t *, uint16_t *);
uint16_t xutil_key_mask_fromstr(const char *, size_t);
uint16_t xutil_key_mask_fromstr(const char *);
void xutil_key_mask_tostr(uint16_t, const char **, size_t *);
#endif

View file

@ -147,9 +147,8 @@ luaA_tomodifiers(lua_State *L, int ud)
for(int i = 1; i <= len; i++)
{
lua_rawgeti(L, ud, i);
size_t blen;
const char *key = luaL_checklstring(L, -1, &blen);
mod |= xutil_key_mask_fromstr(key, blen);
const char *key = luaL_checkstring(L, -1);
mod |= xutil_key_mask_fromstr(key);
lua_pop(L, 1);
}
return mod;