From cbb90d8bd172375b1f8caa68ac2ed5f34dc6c132 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 26 Dec 2018 22:51:58 -0500 Subject: [PATCH] root: Turn `root.keys()` into a property. --- lib/awful/_compat.lua | 8 ++++++++ root.c | 11 ++++++----- tests/examples/shims/root.lua | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/awful/_compat.lua b/lib/awful/_compat.lua index 135e32b1..b7af2bb2 100644 --- a/lib/awful/_compat.lua +++ b/lib/awful/_compat.lua @@ -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) diff --git a/root.c b/root.c index 778838d9..9c1b1465 100644 --- a/root.c +++ b/root.c @@ -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 }, diff --git a/tests/examples/shims/root.lua b/tests/examples/shims/root.lua index ef703156..47ee71b3 100644 --- a/tests/examples/shims/root.lua +++ b/tests/examples/shims/root.lua @@ -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