diff --git a/lib/awful/client.lua b/lib/awful/client.lua index c4ff1f005..033898517 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -1344,6 +1344,12 @@ function client.object.is_transient_for(self, c2) return nil end +object.properties._legacy_accessors(client, "buttons", "_buttons", true, function(new_btns) + return new_btns[1] and ( + type(new_btns[1]) == "button" or new_btns[1]._is_capi_button + ) or false +end, true) + --- Set the client shape. -- @property shape -- @tparam gears.shape A gears.shape compatible function. diff --git a/lib/awful/wibar.lua b/lib/awful/wibar.lua index b29d6d846..4b4e9bb62 100644 --- a/lib/awful/wibar.lua +++ b/lib/awful/wibar.lua @@ -421,6 +421,8 @@ function awfulwibar.new(args) w:connect_signal("property::visible", function() reattach(w) end) + assert(w.buttons) + return w end diff --git a/lib/wibox/init.lua b/lib/wibox/init.lua index f55a899e3..3f68d5cb4 100644 --- a/lib/wibox/init.lua +++ b/lib/wibox/init.lua @@ -19,6 +19,7 @@ local beautiful = require("beautiful") local base = require("wibox.widget.base") local cairo = require("lgi").cairo + --- This provides widget box windows. Every wibox can also be used as if it were -- a drawin. All drawin functions and properties are also available on wiboxes! -- wibox @@ -63,6 +64,10 @@ function wibox:find_widgets(x, y) return self._drawable:find_widgets(x, y) end +function wibox:_buttons(btns) + return self.drawin:_buttons(btns) +end + --- Create a widget that reflects the current state of this wibox. -- @treturn widget A new widget. -- @method to_widget @@ -207,12 +212,18 @@ function wibox:get_children_by_id(name) return {} end -for _, k in pairs{ "buttons", "struts", "geometry", "get_xproperty", "set_xproperty" } do +for _, k in pairs{ "struts", "geometry", "get_xproperty", "set_xproperty" } do wibox[k] = function(self, ...) return self.drawin[k](self.drawin, ...) end end +object.properties._legacy_accessors(wibox.object, "buttons", "_buttons", true, function(new_btns) + return new_btns[1] and ( + type(new_btns[1]) == "button" or new_btns[1]._is_capi_button + ) or false +end, true) + local function setup_signals(_wibox) local obj local function clone_signal(name) @@ -264,6 +275,7 @@ local function new(args) return ret end + w._private = {} ret.drawin = w ret._drawable = wibox.drawable(w.drawable, { wibox = ret }, "wibox drawable (" .. object.modulename(3) .. ")") @@ -365,6 +377,8 @@ object.properties(capi.drawin, { auto_emit = true, }) +capi.drawin.object = wibox.object + return setmetatable(wibox, wibox.mt) -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/objects/client.c b/objects/client.c index 5f5d9de9e..6a881a625 100644 --- a/objects/client.c +++ b/objects/client.c @@ -949,9 +949,9 @@ /** Get or set mouse buttons bindings for a client. * - * @param buttons_table An array of mouse button bindings objects, or nothing. - * @return A table with all buttons. - * @method buttons + * @property buttons + * @param table + * @see awful.button */ /** Get the number of instances. diff --git a/objects/window.c b/objects/window.c index 3c0432730..623cdbb6e 100644 --- a/objects/window.c +++ b/objects/window.c @@ -515,7 +515,7 @@ window_class_setup(lua_State *L) static const struct luaL_Reg window_meta[] = { { "struts", luaA_window_struts }, - { "buttons", luaA_window_buttons }, + { "_buttons", luaA_window_buttons }, { "set_xproperty", luaA_window_set_xproperty }, { "get_xproperty", luaA_window_get_xproperty }, { NULL, NULL } diff --git a/tests/examples/shims/drawin.lua b/tests/examples/shims/drawin.lua index 2147b6232..0a9780ff6 100644 --- a/tests/examples/shims/drawin.lua +++ b/tests/examples/shims/drawin.lua @@ -37,7 +37,7 @@ local function new_drawin(_, args) ret.data.drawable.refresh = function() end ret.data._struts = { top = 0, right = 0, left = 0, bottom = 0 } - for _, k in pairs{ "buttons", "get_xproperty", "set_xproperty" } do + for _, k in pairs{ "_buttons", "get_xproperty", "set_xproperty" } do ret[k] = function() end end