drawin: Turn `:buttons()` into a property.
This commit is contained in:
parent
3d918258e2
commit
29e804a4f8
|
@ -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.
|
||||
|
|
|
@ -421,6 +421,8 @@ function awfulwibar.new(args)
|
|||
|
||||
w:connect_signal("property::visible", function() reattach(w) end)
|
||||
|
||||
assert(w.buttons)
|
||||
|
||||
return w
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue