tests: Make the capi.screen shim more robust
Also add some private properties to be consumed by the template for a better rendered documentation example image.
This commit is contained in:
parent
2c8c274193
commit
3adad38c0a
|
@ -1,10 +1,7 @@
|
||||||
local gears_obj = require("gears.object")
|
local gears_obj = require("gears.object")
|
||||||
|
|
||||||
local screen, meta = awesome._shim_fake_class()
|
local screen, meta = awesome._shim_fake_class()
|
||||||
|
screen._count = 0
|
||||||
function screen.count()
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
|
|
||||||
local function create_screen(args)
|
local function create_screen(args)
|
||||||
local s = gears_obj()
|
local s = gears_obj()
|
||||||
|
@ -26,8 +23,18 @@ local function create_screen(args)
|
||||||
geo.height = args2.height or geo.height
|
geo.height = args2.height or geo.height
|
||||||
end
|
end
|
||||||
|
|
||||||
|
s.outputs = { ["LVDS1"] = {
|
||||||
|
mm_width = 0,
|
||||||
|
mm_height = 0,
|
||||||
|
}}
|
||||||
|
|
||||||
local wa = args.workarea_sides or 10
|
local wa = args.workarea_sides or 10
|
||||||
|
|
||||||
|
-- This will happen if `clear()` is called
|
||||||
|
if mouse and not mouse.screen then
|
||||||
|
mouse.screen = s
|
||||||
|
end
|
||||||
|
|
||||||
return setmetatable(s,{ __index = function(_, key)
|
return setmetatable(s,{ __index = function(_, key)
|
||||||
if key == "geometry" then
|
if key == "geometry" then
|
||||||
return {
|
return {
|
||||||
|
@ -62,6 +69,7 @@ function screen._add_screen(args)
|
||||||
|
|
||||||
screen[#screen+1] = s
|
screen[#screen+1] = s
|
||||||
screen[s] = s
|
screen[s] = s
|
||||||
|
screen._count = screen._count + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
function screen._get_extents()
|
function screen._get_extents()
|
||||||
|
@ -84,6 +92,12 @@ function screen._clear()
|
||||||
screen[i] = nil
|
screen[i] = nil
|
||||||
end
|
end
|
||||||
screens = {}
|
screens = {}
|
||||||
|
|
||||||
|
if mouse then
|
||||||
|
mouse.screen = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
screen._count = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function screen._setup_grid(w, h, rows, args)
|
function screen._setup_grid(w, h, rows, args)
|
||||||
|
@ -91,8 +105,8 @@ function screen._setup_grid(w, h, rows, args)
|
||||||
screen._clear()
|
screen._clear()
|
||||||
for i, row in ipairs(rows) do
|
for i, row in ipairs(rows) do
|
||||||
for j=1, row do
|
for j=1, row do
|
||||||
args.x = (j-1)*w + (j-1)*10
|
args.x = (j-1)*w + (j-1)*screen._grid_horizontal_margin
|
||||||
args.y = (i-1)*h + (i-1)*10
|
args.y = (i-1)*h + (i-1)*screen._grid_vertical_margin
|
||||||
args.width = w
|
args.width = w
|
||||||
args.height = h
|
args.height = h
|
||||||
screen._add_screen(args)
|
screen._add_screen(args)
|
||||||
|
@ -115,6 +129,14 @@ end
|
||||||
|
|
||||||
screen._add_screen {width=320, height=240}
|
screen._add_screen {width=320, height=240}
|
||||||
|
|
||||||
|
screen._grid_vertical_margin = 10
|
||||||
|
screen._grid_horizontal_margin = 10
|
||||||
|
|
||||||
|
|
||||||
|
function screen.count()
|
||||||
|
return screen._count
|
||||||
|
end
|
||||||
|
|
||||||
return setmetatable(screen, {
|
return setmetatable(screen, {
|
||||||
__call = iter_scr
|
__call = iter_scr
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue