From 6ad693eff00861c30a729970ac3d3f646777735f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Lepage=20Vall=C3=A9e?= Date: Wed, 7 Jul 2021 00:42:31 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Aire-One --- lib/awful/wibar.lua | 18 +++++++++--------- tests/examples/screen/template.lua | 14 ++++++++------ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/awful/wibar.lua b/lib/awful/wibar.lua index b816b483..d99e4be2 100644 --- a/lib/awful/wibar.lua +++ b/lib/awful/wibar.lua @@ -71,11 +71,11 @@ local align_map = { -- -- Values are: -- --- * top --- * bottom --- * left --- * right --- * centered +-- * `"top"` +-- * `"bottom"` +-- * `"left"` +-- * `"right"` +-- * `"centered"` -- -- @DOC_awful_wibar_align_EXAMPLE@ -- @@ -87,8 +87,8 @@ local align_map = { --- Margins on each side of the wibar. -- --- It can either be a table if `top`, `bottom`, `left`, `right` or a --- single number. +-- It can either be a table with `top`, `bottom`, `left` and `right` +-- properties, or a single number that apply to all fourth sides. -- -- @DOC_awful_wibar_margins_EXAMPLE@ -- @@ -385,12 +385,12 @@ function awfulwibar.set_margins(w, value) } end - value = value or { + value = gtable.crush({ left = 0, right = 0, top = 0, bottom = 0 - } + }, value or {}, true) w._private.margins = value diff --git a/tests/examples/screen/template.lua b/tests/examples/screen/template.lua index be2d8db8..4d6f9ed0 100644 --- a/tests/examples/screen/template.lua +++ b/tests/examples/screen/template.lua @@ -15,6 +15,8 @@ local args = loadfile(file_path)() or 10 args = args or {} args.factor = args.factor or 10 +local SCALE_FACTOR = 0.66 + local factor, img, cr = 1/args.factor require("gears.timer").run_delayed_calls_now() @@ -470,7 +472,7 @@ local function draw_struts(s) if left > 0 then draw_hruler( s, - s.geometry.y*0.66, + s.geometry.y*SCALE_FACTOR, get_text_height(), {x = s.geometry.x+tr_x*2, width = left, color = colors.gaps.."66", align = true}, 1 @@ -481,7 +483,7 @@ local function draw_struts(s) draw_vruler( s, get_text_height()*1.5, - s.geometry.x*0.66, + s.geometry.x*SCALE_FACTOR, {y=s.geometry.y+tr_y*(1/factor), height = top, color = colors.gaps.."66", align = true}, 1 ) @@ -490,7 +492,7 @@ local function draw_struts(s) if right > 0 then draw_hruler( s, - s.geometry.y*0.66, + s.geometry.y*SCALE_FACTOR, get_text_height(), {x = s.geometry.x, width = left, color = colors.gaps.."66", align = true}, 1 @@ -501,7 +503,7 @@ local function draw_struts(s) draw_vruler( s, get_text_height()*1.5, - s.geometry.x*0.66, + s.geometry.x*SCALE_FACTOR, { y = s.geometry.y+tr_y*(1/factor)+s.geometry.height - bottom, height = bottom, @@ -689,7 +691,7 @@ evaluate_translation( local sew, seh = screen._get_extents() sew, seh = sew/args.factor + (screen.count()-1)*10+2, seh/args.factor+2 -sew, seh = sew + tr_x, seh + 0.66*tr_y +sew, seh = sew + tr_x, seh + SCALE_FACTOR*tr_y sew, seh = sew + 5*get_text_height(), seh + 5*get_text_height() @@ -697,7 +699,7 @@ img = cairo.SvgSurface.create(image_path..".svg", sew, seh) cr = cairo.Context(img) -- Instead of adding origin offset everywhere, translate the viewport. -cr:translate(tr_x, tr_y * 0.66) +cr:translate(tr_x, tr_y * SCALE_FACTOR) -- Draw the various areas. for k=1, screen.count() do