awesome/tests/examples/shims/drawin.lua

75 lines
1.9 KiB
Lua
Raw Normal View History

2016-05-03 05:56:08 +02:00
local gears_obj = require("gears.object")
local drawin, meta = awesome._shim_fake_class()
2017-05-15 08:24:52 +02:00
local drawins = setmetatable({}, {__mode="v"})
local cairo = require("lgi").cairo
2016-05-03 05:56:08 +02:00
local function new_drawin(_, args)
local ret = gears_obj()
2017-05-29 10:53:49 +02:00
ret.data = {drawable = gears_obj()}
2016-05-03 05:56:08 +02:00
2017-05-15 08:24:52 +02:00
ret.x=0
ret.y=0
ret.width=1
ret.height=1
ret.border_width=0
ret.ontop = false
ret.below = false
ret.above = false
2017-05-15 08:24:52 +02:00
ret.geometry = function(_, new)
new = new or {}
ret.x = new.x or ret.x
ret.y = new.y or ret.y
ret.width = new.width or ret.width
ret.height = new.height or ret.height
return {
x = ret.x,
y = ret.y,
width = ret.width,
height = ret.height
}
end
ret.data.drawable.valid = true
ret.data.drawable.surface = cairo.ImageSurface(cairo.Format.ARGB32, 0, 0)
ret.data.drawable.geometry = ret.geometry
ret.data.drawable.refresh = function() end
2019-07-18 06:20:58 +02:00
ret.data._struts = { top = 0, right = 0, left = 0, bottom = 0 }
2019-07-18 06:20:58 +02:00
for _, k in pairs{ "buttons", "get_xproperty", "set_xproperty" } do
2017-05-15 08:24:52 +02:00
ret[k] = function() end
2016-05-03 05:56:08 +02:00
end
2019-07-18 06:20:58 +02:00
function ret:struts(new)
for k, v in pairs(new or {}) do
ret.data._struts[k] = v
end
return ret.data._struts
end
2017-05-15 08:24:52 +02:00
local md = setmetatable(ret, {
__index = function(...) return meta.__index(...) end,
__newindex = function(...) return meta.__newindex(...) end
})
2017-05-15 08:24:52 +02:00
for k, v in pairs(args) do
ret[k] = v
end
table.insert(drawins, md)
return md
end
function drawin.get()
return drawins
2016-05-03 05:56:08 +02:00
end
return setmetatable(drawin, {
__call = new_drawin,
})
2016-05-03 05:56:08 +02:00
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80