tests: Improve the awful example template

* Support async operations
 * Support `awful.popup`
 * Support minimized clients
This commit is contained in:
Emmanuel Lepage Vallee 2017-08-10 00:27:09 -04:00
parent 90342b62c6
commit c3302c4bbe
1 changed files with 84 additions and 61 deletions

View File

@ -11,6 +11,11 @@ local wibox = require( "wibox" )
-- Run the test -- Run the test
local args = loadfile(file_path)() or {} local args = loadfile(file_path)() or {}
-- Emulate the event loop for 5 iterations
for _ = 1, 5 do
awesome.emit_signal("refresh")
end
-- Draw the result -- Draw the result
local img = cairo.SvgSurface.create(image_path..".svg", screen._get_extents() ) local img = cairo.SvgSurface.create(image_path..".svg", screen._get_extents() )
@ -30,6 +35,7 @@ local function draw_mouse(x, y)
end end
-- Print an outline for the screens -- Print an outline for the screens
if not screen.no_outline then
for _, s in ipairs(screen) do for _, s in ipairs(screen) do
cr:save() cr:save()
-- Draw the screen outline -- Draw the screen outline
@ -48,8 +54,9 @@ for _, s in ipairs(screen) do
--TODO --TODO
cr:restore() cr:restore()
end end
end
cr:set_line_width(beautiful.border_width) cr:set_line_width(beautiful.border_width/2)
cr:set_source(color(beautiful.border_color)) cr:set_source(color(beautiful.border_color))
@ -124,12 +131,8 @@ local function client_widget(c, col, label)
l.forced_height = c.height l.forced_height = c.height
return wibox.widget { return wibox.widget {
{
{ {
l, l,
margins = bw + 1, -- +1 because the the SVG AA
layout = wibox.container.margin
},
{ {
text = label or "", text = label or "",
align = "center", align = "center",
@ -138,22 +141,40 @@ local function client_widget(c, col, label)
}, },
layout = wibox.layout.stack layout = wibox.layout.stack
}, },
shape_border_width = bw*2, shape_border_width = bw,
shape_border_color = beautiful.border_color, shape_border_color = beautiful.border_color,
shape_clip = true, shape_clip = true,
fg = beautiful.fg_normal or "#000000", fg = beautiful.fg_normal or "#000000",
bg = col, bg = col,
forced_width = geo.width + 2*bw,
forced_height = geo.height + 2*bw,
shape = function(cr2, w, h) shape = function(cr2, w, h)
return shape.rounded_rect(cr2, w, h, args.radius or 5) return shape.rounded_rect(cr2, w, h, args.radius or 5)
end, end,
forced_width = geo.width + 2*bw,
forced_height = geo.height + 2*bw,
widget = wibox.container.background, widget = wibox.container.background,
} }
end end
-- Add all wiboxes -- Add all wiboxes
-- Fix the wibox geometries that have a dependency on their content
for _, d in ipairs(drawin.get()) do
local w = d.get_wibox and d:get_wibox() or nil
if w then
-- Force a full layout first as widgets with as the awful.popup have
-- interdependencies between the content and the container
if w._apply_size_now then
w:_apply_size_now()
end
end
end
-- Emulate the event loop for another 5 iterations
for _ = 1, 5 do
awesome.emit_signal("refresh")
end
for _, d in ipairs(drawin.get()) do for _, d in ipairs(drawin.get()) do
local w = d.get_wibox and d:get_wibox() or nil local w = d.get_wibox and d:get_wibox() or nil
if w then if w then
@ -164,6 +185,7 @@ end
-- Loop each clients geometry history and paint it -- Loop each clients geometry history and paint it
for _, c in ipairs(client.get()) do for _, c in ipairs(client.get()) do
if not c.minimized then
local pgeo = nil local pgeo = nil
for _, geo in ipairs(c._old_geo) do for _, geo in ipairs(c._old_geo) do
if not geo._hide then if not geo._hide then
@ -203,6 +225,7 @@ for _, c in ipairs(client.get()) do
pgeo = geo pgeo = geo
end end
end end
end
-- Draw the wiboxes/clients on top of the screen -- Draw the wiboxes/clients on top of the screen
wibox.widget.draw_to_cairo_context( wibox.widget.draw_to_cairo_context(