root: Turn root.keys() into a property.

This commit is contained in:
Emmanuel Lepage Vallee 2018-12-26 22:51:58 -05:00
parent 296ad18922
commit cbb90d8bd1
3 changed files with 15 additions and 6 deletions

View file

@ -70,3 +70,11 @@ gprop._legacy_accessors(capi.root, "buttons", "_buttons", false, function(new_bt
type(new_btns[1]) == "button" or new_btns[1]._is_capi_button
) or false
end, true)
gprop._legacy_accessors(capi.root, "keys", "_keys", false, function(new_btns)
return new_btns[1] and (
type(new_btns[1]) == "key" or new_btns[1]._is_capi_button
) or false
end, true)
assert(root.keys)

11
root.c
View file

@ -335,11 +335,12 @@ luaA_root_fake_input(lua_State *L)
}
/** Get or set global key bindings.
* These bindings will be available when you press keys on the root window.
* These bindings will be available when you press keys on the root window
* (the wallpaper).
*
* @tparam table|nil keys_array An array of key binding objects, or nothing.
* @return The array of key bindings objects of this client.
* @staticfct keys
* @property keys
* @param table
* @see awful.key
*/
static int
luaA_root_keys(lua_State *L)
@ -597,7 +598,7 @@ luaA_root_newindex(lua_State *L)
const struct luaL_Reg awesome_root_methods[] =
{
{ "_buttons", luaA_root_buttons },
{ "keys", luaA_root_keys },
{ "_keys", luaA_root_keys },
{ "cursor", luaA_root_cursor },
{ "fake_input", luaA_root_fake_input },
{ "drawins", luaA_root_drawins },

View file

@ -32,7 +32,7 @@ function root.cursor() end
local keys = {}
function root.keys(k)
function root._keys(k)
keys = k or keys
return keys
end