tests: Fix the `screen` template rendering with multiple screens.
It only worked for a single screen. It still isn't perfect, but much better than it was.
This commit is contained in:
parent
dd6163ffe6
commit
b2368c54a8
|
@ -39,7 +39,7 @@ local clients = {
|
|||
return {
|
||||
factor = 2 ,
|
||||
show_boxes = true,
|
||||
draw_wibar = wibar,
|
||||
draw_wibars = {wibar},
|
||||
draw_clients = clients,
|
||||
display_screen_info = false,
|
||||
draw_client_snap = true, --FIXME
|
||||
|
|
|
@ -35,7 +35,7 @@ local clients = {
|
|||
return {
|
||||
factor = 2 ,
|
||||
show_boxes = true,
|
||||
draw_wibar = wibar,
|
||||
draw_wibars = {wibar},
|
||||
draw_clients = clients,
|
||||
display_screen_info = false,
|
||||
draw_gaps = true,
|
||||
|
|
|
@ -35,7 +35,7 @@ local clients = {
|
|||
return {
|
||||
factor = 2 ,
|
||||
show_boxes = true,
|
||||
draw_wibar = wibar,
|
||||
draw_wibars = {wibar},
|
||||
draw_clients = clients,
|
||||
display_screen_info = false,
|
||||
draw_gaps = true,
|
||||
|
|
|
@ -36,7 +36,7 @@ local clients = {
|
|||
return {
|
||||
factor = 2 ,
|
||||
show_boxes = true,
|
||||
draw_wibar = wibar,
|
||||
draw_wibars = {wibar},
|
||||
draw_clients = clients,
|
||||
display_screen_info = false,
|
||||
draw_gaps = true,
|
||||
|
|
|
@ -36,7 +36,7 @@ local clients = {
|
|||
return {
|
||||
factor = 2 ,
|
||||
show_boxes = true,
|
||||
draw_wibar = wibar,
|
||||
draw_wibars = {wibar},
|
||||
draw_clients = clients,
|
||||
display_screen_info = false,
|
||||
draw_gaps = true,
|
||||
|
|
|
@ -30,7 +30,7 @@ end --DOC_HIDE
|
|||
|
||||
return { --DOC_HIDE
|
||||
factor = 2 , --DOC_HIDE
|
||||
show_boxes = false, --DOC_HIDE
|
||||
show_boxes = false , --DOC_HIDE
|
||||
highlight_geometry = true , --DOC_HIDE
|
||||
draw_wibar = wibar, --DOC_HIDE
|
||||
draw_wibars = {wibar}, --DOC_HIDE
|
||||
} --DOC_HIDE
|
||||
|
|
|
@ -45,9 +45,9 @@ for _,c in ipairs(clients) do
|
|||
end
|
||||
|
||||
return {
|
||||
factor = 2 ,
|
||||
factor = 2,
|
||||
show_boxes = true,
|
||||
draw_wibar = wibar,
|
||||
draw_wibars = {wibar},
|
||||
draw_clients = clients,
|
||||
display_screen_info = false,
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ end
|
|||
return {
|
||||
factor = 2 ,
|
||||
show_boxes = true,
|
||||
draw_wibar = wibar,
|
||||
draw_wibars = {wibar},
|
||||
draw_clients = clients,
|
||||
display_screen_info = false,
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ end
|
|||
return {
|
||||
factor = 2 ,
|
||||
show_boxes = true,
|
||||
draw_wibar = wibar,
|
||||
draw_wibars = {wibar},
|
||||
draw_clients = clients,
|
||||
display_screen_info = false,
|
||||
draw_mwfact = true,
|
||||
|
|
|
@ -51,7 +51,7 @@ end
|
|||
return {
|
||||
factor = 2 ,
|
||||
show_boxes = true,
|
||||
draw_wibar = wibar,
|
||||
draw_wibars = {wibar},
|
||||
draw_clients = clients,
|
||||
display_screen_info = false,
|
||||
draw_mwfact = true,
|
||||
|
|
|
@ -33,7 +33,7 @@ end --DOC_HIDE
|
|||
|
||||
return { --DOC_HIDE
|
||||
factor = 2 , --DOC_HIDE
|
||||
show_boxes = false, --DOC_HIDE
|
||||
show_boxes = false , --DOC_HIDE
|
||||
highlight_padding_area = true , --DOC_HIDE
|
||||
draw_wibar = wibar, --DOC_HIDE
|
||||
draw_wibars = {wibar}, --DOC_HIDE
|
||||
} --DOC_HIDE
|
||||
|
|
|
@ -51,9 +51,9 @@ local clients = { --DOC_HIDE
|
|||
} --DOC_HIDE
|
||||
|
||||
return { --DOC_HIDE
|
||||
factor = 2 , --DOC_HIDE
|
||||
factor = 2, --DOC_HIDE
|
||||
show_boxes = true, --DOC_HIDE
|
||||
draw_wibar = wibar, --DOC_HIDE
|
||||
draw_wibars = {wibar}, --DOC_HIDE
|
||||
draw_clients = clients, --DOC_HIDE
|
||||
display_screen_info = false, --DOC_HIDE
|
||||
draw_struts = true, --DOC_HIDE
|
||||
|
|
|
@ -160,11 +160,12 @@ local function draw_client(_, c, name, offset, label, alpha)
|
|||
end
|
||||
|
||||
|
||||
local function compute_ruler(_, rect, name)
|
||||
table.insert(hrulers, {
|
||||
local function compute_ruler(s, rect, name)
|
||||
hrulers[s], vrulers[s] = hrulers[s] or {}, vrulers[s] or {}
|
||||
table.insert(hrulers[s], {
|
||||
label = name, x = rect.x, width = rect.width
|
||||
})
|
||||
table.insert(vrulers, {
|
||||
table.insert(vrulers[s], {
|
||||
label = name, y = rect.y, height = rect.height
|
||||
})
|
||||
end
|
||||
|
@ -309,8 +310,8 @@ end
|
|||
|
||||
local function draw_rulers(s)
|
||||
-- The table has a maximum of 4 entries, the sort algorithm is irrelevant.
|
||||
while not bubble_sort(hrulers, "x", "width" ) do end
|
||||
while not bubble_sort(vrulers, "y", "height") do end
|
||||
while not bubble_sort(hrulers[s], "x", "width" ) do end
|
||||
while not bubble_sort(vrulers[s], "y", "height") do end
|
||||
|
||||
cr:set_line_width(1)
|
||||
cr:set_dash(nil)
|
||||
|
@ -320,7 +321,7 @@ local function draw_rulers(s)
|
|||
|
||||
dx = get_text_height() + 10
|
||||
|
||||
for k, ruler in ipairs(vrulers) do
|
||||
for k, ruler in ipairs(vrulers[s]) do
|
||||
draw_vruler(s, dx, sx, ruler, k)
|
||||
end
|
||||
|
||||
|
@ -406,10 +407,6 @@ local function evaluate_translation(draw_gaps, draw_struts, draw_mwfact, draw_cl
|
|||
end
|
||||
end
|
||||
|
||||
local function translate()
|
||||
cr:translate(tr_x, tr_y * 0.66)
|
||||
end
|
||||
|
||||
local function draw_gaps(s)
|
||||
cr:translate(-tr_x, -tr_y)
|
||||
|
||||
|
@ -473,7 +470,7 @@ local function draw_struts(s)
|
|||
if left > 0 then
|
||||
draw_hruler(
|
||||
s,
|
||||
0,
|
||||
s.geometry.y*0.66,
|
||||
get_text_height(),
|
||||
{x = s.geometry.x+tr_x*2, width = left, color = colors.gaps.."66", align = true},
|
||||
1
|
||||
|
@ -484,7 +481,7 @@ local function draw_struts(s)
|
|||
draw_vruler(
|
||||
s,
|
||||
get_text_height()*1.5,
|
||||
0,
|
||||
s.geometry.x*0.66,
|
||||
{y=s.geometry.y+tr_y*(1/factor), height = top, color = colors.gaps.."66", align = true},
|
||||
1
|
||||
)
|
||||
|
@ -493,7 +490,7 @@ local function draw_struts(s)
|
|||
if right > 0 then
|
||||
draw_hruler(
|
||||
s,
|
||||
0,
|
||||
s.geometry.y*0.66,
|
||||
get_text_height(),
|
||||
{x = s.geometry.x, width = left, color = colors.gaps.."66", align = true},
|
||||
1
|
||||
|
@ -504,7 +501,7 @@ local function draw_struts(s)
|
|||
draw_vruler(
|
||||
s,
|
||||
get_text_height()*1.5,
|
||||
0,
|
||||
s.geometry.x*0.66,
|
||||
{
|
||||
y = s.geometry.y+tr_y*(1/factor)+s.geometry.height - bottom,
|
||||
height = bottom,
|
||||
|
@ -667,8 +664,8 @@ local function draw_info(s)
|
|||
end
|
||||
|
||||
-- Compute the rulers size.
|
||||
for _=1, screen.count() do
|
||||
local s = screen[1]
|
||||
for k=1, screen.count() do
|
||||
local s = screen[k]
|
||||
|
||||
-- The padding.
|
||||
compute_ruler(s, s.tiling_area, "tiling_area")
|
||||
|
@ -699,16 +696,15 @@ sew, seh = sew + 5*get_text_height(), seh + 5*get_text_height()
|
|||
img = cairo.SvgSurface.create(image_path..".svg", sew, seh)
|
||||
cr = cairo.Context(img)
|
||||
|
||||
cr:set_line_width(1.5)
|
||||
cr:set_dash({10,4},1)
|
||||
|
||||
-- Instead of adding origin offset everywhere, translate the viewport.
|
||||
translate()
|
||||
cr:translate(tr_x, tr_y * 0.66)
|
||||
|
||||
-- Draw the various areas.
|
||||
for k=1, screen.count() do
|
||||
local s = screen[1]
|
||||
local s = screen[k]
|
||||
|
||||
cr:set_line_width(1.5)
|
||||
cr:set_dash({10,4},1)
|
||||
|
||||
-- The outer geometry.
|
||||
draw_area(s, s.geometry, "geometry", (k-1)*10, args.highlight_geometry)
|
||||
|
@ -727,8 +723,10 @@ for k=1, screen.count() do
|
|||
draw_rulers(s)
|
||||
|
||||
-- Draw the wibar.
|
||||
if args.draw_wibar then
|
||||
draw_struct(s, args.draw_wibar, 'wibar', (k-1)*10, 'Wibar')
|
||||
for _, wibar in ipairs(args.draw_wibars or {}) do
|
||||
if wibar.screen == s then
|
||||
draw_struct(s, wibar, 'wibar', (k-1)*10, 'Wibar')
|
||||
end
|
||||
end
|
||||
|
||||
local skip_gaps = s.selected_tag
|
||||
|
@ -740,6 +738,7 @@ for k=1, screen.count() do
|
|||
-- Draw clients.
|
||||
if args.draw_clients then
|
||||
for label,c in pairs(args.draw_clients) do
|
||||
if c.screen == s then
|
||||
local gap = c:tags()[1].gap
|
||||
if args.draw_gaps and gap > 0 and (not c.floating) and not skip_gaps then
|
||||
local proxy = {
|
||||
|
@ -764,6 +763,7 @@ for k=1, screen.count() do
|
|||
draw_client(s, c, 'tiling_client', (k-1)*10, label)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if args.draw_struts and has_struts(s) then
|
||||
draw_struts(s)
|
||||
|
|
|
@ -47,7 +47,7 @@ end
|
|||
return {
|
||||
factor = 2 ,
|
||||
show_boxes = true,
|
||||
draw_wibar = wibar,
|
||||
draw_wibars = {wibar},
|
||||
draw_clients = clients,
|
||||
display_screen_info = false,
|
||||
}
|
||||
|
|
|
@ -27,5 +27,5 @@ return {
|
|||
factor = 2 ,
|
||||
show_boxes = false,
|
||||
highlight_tiling_area = true ,
|
||||
draw_wibar = wibar,
|
||||
draw_wibars = {wibar},
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ end --DOC_HIDE
|
|||
}
|
||||
|
||||
return { --DOC_HIDE
|
||||
factor = 2 , --DOC_HIDE
|
||||
factor = 2, --DOC_HIDE
|
||||
show_boxes = false, --DOC_HIDE
|
||||
highlight_workarea = true , --DOC_HIDE
|
||||
draw_wibar = wibar, --DOC_HIDE
|
||||
draw_wibars = {wibar}, --DOC_HIDE
|
||||
} --DOC_HIDE
|
||||
|
|
Loading…
Reference in New Issue