key: add support for modifier mask Any

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-04-15 13:59:22 +02:00
parent 1a18088da5
commit f168bbdfa4
3 changed files with 7 additions and 2 deletions

View File

@ -1,3 +1,4 @@
Any
above above
align align
alpha alpha

View File

@ -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_MOD3: return XCB_MOD_MASK_3;
case A_TK_MOD4: return XCB_MOD_MASK_4; case A_TK_MOD4: return XCB_MOD_MASK_4;
case A_TK_MOD5: return XCB_MOD_MASK_5; 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; default: return XCB_NO_SYMBOL;
} }
} }

6
key.c
View File

@ -75,7 +75,8 @@ key_ev_cmp(xcb_keysym_t keysym, xcb_keycode_t keycode,
if(k->keycode != keycode) if(k->keycode != keycode)
return k->keycode > keycode ? 1 : -1; 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 static int
@ -288,7 +289,8 @@ luaA_keystore(keyb_t *key, const char *str, ssize_t len)
* \param L The Lua VM state. * \param L The Lua VM state.
* *
* \luastack * \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 key name.
* \lparam A function to execute on key press. * \lparam A function to execute on key press.
* \lparam A function to execute on key release. * \lparam A function to execute on key release.