From f168bbdfa4768171c1b1762654008f43bb56bbee Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 15 Apr 2009 13:59:22 +0200 Subject: [PATCH] key: add support for modifier mask Any Signed-off-by: Julien Danjou --- common/tokenize.gperf | 1 + common/xutil.c | 2 ++ key.c | 6 ++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/common/tokenize.gperf b/common/tokenize.gperf index 64ea8eac4..c48d2bc49 100644 --- a/common/tokenize.gperf +++ b/common/tokenize.gperf @@ -1,3 +1,4 @@ +Any above align alpha diff --git a/common/xutil.c b/common/xutil.c index bcf8805f7..7e0c9a88c 100644 --- a/common/xutil.c +++ b/common/xutil.c @@ -109,6 +109,8 @@ xutil_key_mask_fromstr(const char *keyname, size_t len) 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; + /* this is misnamed but correct */ + case A_TK_ANY: return XCB_BUTTON_MASK_ANY; default: return XCB_NO_SYMBOL; } } diff --git a/key.c b/key.c index 972faf91c..cabad3173 100644 --- a/key.c +++ b/key.c @@ -75,7 +75,8 @@ key_ev_cmp(xcb_keysym_t keysym, xcb_keycode_t keycode, if(k->keycode != keycode) return k->keycode > keycode ? 1 : -1; } - return k->mod == mod ? 0 : (k->mod > mod ? 1 : -1); + return ((k->mod == mod || k->mod == XCB_BUTTON_MASK_ANY) ? + 0 : (k->mod > mod ? 1 : -1)); } static int @@ -288,7 +289,8 @@ luaA_keystore(keyb_t *key, const char *str, ssize_t len) * \param L The Lua VM state. * * \luastack - * \lparam A table with modifier keys. + * \lparam A table with modifier keys: can be Control or Ctrl, Shift, Lock, + * Mod1, Mod2, Mod3, Mod4, Mod5 or Any. * \lparam A key name. * \lparam A function to execute on key press. * \lparam A function to execute on key release.