Browse Source

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

Emmanuel Lepage Vallee 10 months ago
parent
commit
cbb90d8bd1
3 changed files with 15 additions and 6 deletions
  1. 8
    0
      lib/awful/_compat.lua
  2. 6
    5
      root.c
  3. 1
    1
      tests/examples/shims/root.lua

+ 8
- 0
lib/awful/_compat.lua View File

@@ -70,3 +70,11 @@ gprop._legacy_accessors(capi.root, "buttons", "_buttons", false, function(new_bt
70 70
         type(new_btns[1]) == "button" or new_btns[1]._is_capi_button
71 71
     ) or false
72 72
 end, true)
73
+
74
+gprop._legacy_accessors(capi.root, "keys", "_keys", false, function(new_btns)
75
+    return new_btns[1] and (
76
+        type(new_btns[1]) == "key" or new_btns[1]._is_capi_button
77
+    ) or false
78
+end, true)
79
+
80
+assert(root.keys)

+ 6
- 5
root.c View File

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

+ 1
- 1
tests/examples/shims/root.lua View File

@@ -32,7 +32,7 @@ function root.cursor() end
32 32
 
33 33
 local keys = {}
34 34
 
35
-function root.keys(k)
35
+function root._keys(k)
36 36
     keys = k or keys
37 37
     return keys
38 38
 end

Loading…
Cancel
Save