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 type(new_btns[1]) == "button" or new_btns[1]._is_capi_button
) or false ) or false
end, true) 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. /** 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. * @property keys
* @return The array of key bindings objects of this client. * @param table
* @staticfct keys * @see awful.key
*/ */
static int static int
luaA_root_keys(lua_State *L) luaA_root_keys(lua_State *L)
@ -597,7 +598,7 @@ luaA_root_newindex(lua_State *L)
const struct luaL_Reg awesome_root_methods[] = const struct luaL_Reg awesome_root_methods[] =
{ {
{ "_buttons", luaA_root_buttons }, { "_buttons", luaA_root_buttons },
{ "keys", luaA_root_keys }, { "_keys", luaA_root_keys },
{ "cursor", luaA_root_cursor }, { "cursor", luaA_root_cursor },
{ "fake_input", luaA_root_fake_input }, { "fake_input", luaA_root_fake_input },
{ "drawins", luaA_root_drawins }, { "drawins", luaA_root_drawins },

View File

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