diff --git a/keygrabber.c b/keygrabber.c index 710924732..19e1fc675 100644 --- a/keygrabber.c +++ b/keygrabber.c @@ -692,31 +692,7 @@ keygrabber_handlekpress(lua_State *L, xcb_key_press_event_t *e) if(!key_press_lookup_string(e, buf, countof(buf), &ksym)) return false; - lua_createtable(L, 0, 8); - - lua_pushboolean(L, e->state & XCB_MOD_MASK_CONTROL); - lua_setfield(L, -2, "Control"); - - lua_pushboolean(L, e->state & XCB_MOD_MASK_LOCK); - lua_setfield(L, -2, "Lock"); - - lua_pushboolean(L, e->state & XCB_MOD_MASK_SHIFT); - lua_setfield(L, -2, "Shift"); - - lua_pushboolean(L, e->state & XCB_MOD_MASK_1); - lua_setfield(L, -2, "Mod1"); - - lua_pushboolean(L, e->state & XCB_MOD_MASK_2); - lua_setfield(L, -2, "Mod2"); - - lua_pushboolean(L, e->state & XCB_MOD_MASK_3); - lua_setfield(L, -2, "Mod3"); - - lua_pushboolean(L, e->state & XCB_MOD_MASK_4); - lua_setfield(L, -2, "Mod4"); - - lua_pushboolean(L, e->state & XCB_MOD_MASK_5); - lua_setfield(L, -2, "Mod5"); + luaA_pushmodifiers(L, e->state); lua_pushstring(L, buf); diff --git a/lib/awful/prompt.lua.in b/lib/awful/prompt.lua.in index b0d54e78f..21939d5d7 100644 --- a/lib/awful/prompt.lua.in +++ b/lib/awful/prompt.lua.in @@ -9,6 +9,7 @@ local assert = assert local io = io local table = table local math = math +local ipairs = ipairs local capi = { keygrabber = keygrabber, @@ -161,8 +162,11 @@ function run(args, textbox, exe_callback, completion_callback, history_path, his end textbox.text = prettyprompt .. prompt_text_with_cursor(text, inv_col, cur_col, cur_pos, cur_ul, args.selectall) capi.keygrabber.run( - function (mod, key, event) + function (modifiers, key, event) if event ~= "press" then return true end + -- Convert index array to hash table + local mod = {} + for k, v in ipairs(modifiers) do mod[v] = true end -- Get out cases if (mod.Control and (key == "c" or key == "g")) or (not mod.Control and key == "Escape") then