2016-03-19 09:57:37 +01:00
|
|
|
local gears_obj = require("gears.object")
|
|
|
|
|
2016-04-05 05:35:03 +02:00
|
|
|
local screen, meta = awesome._shim_fake_class()
|
2016-03-19 09:57:37 +01:00
|
|
|
|
|
|
|
screen.count = 1
|
|
|
|
|
|
|
|
local function create_screen(args)
|
|
|
|
local s = gears_obj()
|
2016-09-30 11:03:56 +02:00
|
|
|
s.data = {}
|
2016-03-19 09:57:37 +01:00
|
|
|
|
|
|
|
-- Copy the geo in case the args are mutated
|
|
|
|
local geo = {
|
|
|
|
x = args.x ,
|
|
|
|
y = args.y ,
|
|
|
|
width = args.width ,
|
|
|
|
height = args.height,
|
|
|
|
}
|
|
|
|
|
|
|
|
function s._resize(args2)
|
|
|
|
geo.x = args2.x or geo.x
|
|
|
|
geo.y = args2.y or geo.y
|
|
|
|
geo.width = args2.width or geo.width
|
|
|
|
geo.height = args2.height or geo.height
|
|
|
|
end
|
|
|
|
|
|
|
|
local wa = args.workarea_sides or 10
|
|
|
|
|
|
|
|
return setmetatable(s,{ __index = function(_, key)
|
2016-12-27 21:39:08 +01:00
|
|
|
if key == "geometry" then
|
|
|
|
return {
|
|
|
|
x = geo.x or 0,
|
|
|
|
y = geo.y or 0,
|
|
|
|
width = geo.width ,
|
|
|
|
height = geo.height,
|
|
|
|
}
|
|
|
|
elseif key == "workarea" then
|
|
|
|
return {
|
|
|
|
x = (geo.x or 0) + wa ,
|
|
|
|
y = (geo.y or 0) + wa ,
|
|
|
|
width = geo.width - 2*wa,
|
|
|
|
height = geo.height - 2*wa,
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return meta.__index(_, key)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
__newindex = function(...) return meta.__newindex(...) end
|
|
|
|
})
|
2016-03-19 09:57:37 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local screens = {}
|
|
|
|
|
|
|
|
function screen._add_screen(args)
|
|
|
|
local s = create_screen(args)
|
|
|
|
table.insert(screens, s)
|
|
|
|
s.index = #screens
|
|
|
|
screen[#screen+1] = s
|
|
|
|
screen[s] = s
|
|
|
|
end
|
|
|
|
|
|
|
|
function screen._get_extents()
|
|
|
|
local xmax, ymax
|
|
|
|
for _, v in ipairs(screen) do
|
|
|
|
if not xmax or v.geometry.x+v.geometry.width > xmax.geometry.x+xmax.geometry.width then
|
|
|
|
xmax = v
|
|
|
|
end
|
|
|
|
if not ymax or v.geometry.y+v.geometry.height > ymax.geometry.y+ymax.geometry.height then
|
|
|
|
ymax = v
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return xmax.geometry.x+xmax.geometry.width, ymax.geometry.y+ymax.geometry.height
|
|
|
|
end
|
|
|
|
|
|
|
|
function screen._clear()
|
|
|
|
for i=1, #screen do
|
|
|
|
screen[screen[i]] = nil
|
|
|
|
screen[i] = nil
|
|
|
|
end
|
|
|
|
screens = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
function screen._setup_grid(w, h, rows, args)
|
|
|
|
args = args or {}
|
|
|
|
screen._clear()
|
|
|
|
for i, row in ipairs(rows) do
|
|
|
|
for j=1, row do
|
|
|
|
args.x = (j-1)*w + (j-1)*10
|
|
|
|
args.y = (i-1)*h + (i-1)*10
|
|
|
|
args.width = w
|
|
|
|
args.height = h
|
|
|
|
screen._add_screen(args)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
screen._add_screen {width=320, height=240}
|
|
|
|
|
|
|
|
return screen
|
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|