From a1b6eef873798a7f8c1f3ebb94c68e83476f33ad Mon Sep 17 00:00:00 2001 From: Xinhao Yuan Date: Sun, 21 Jul 2019 12:03:55 -0400 Subject: [PATCH] make useless_gap usage more friendly; minor fix --- README.md | 5 ++--- editor.lua | 8 ++++---- layout.lua | 17 ++++++++++------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index bc48eea..8aefe75 100644 --- a/README.md +++ b/README.md @@ -138,10 +138,9 @@ To differentiate tags with the same name, you may need a more advanced naming fu ## Caveats -`beautiful.useless_gap` is handled differently in layout-machi and it doesn't cooperate well with the standard way. -In my usage I set `gap = 0` for the tags and let machi handle the gaps. +1. layout-machi handles `beautiful.useless_gap` slightly differently. -Also, true transparency is required. Otherwise switcher and editor will block the clients. +2. True transparency is required. Otherwise switcher and editor will block the clients. ## TODO diff --git a/editor.lua b/editor.lua index 10f818b..d7c4116 100644 --- a/editor.lua +++ b/editor.lua @@ -458,8 +458,8 @@ local function create(data) end local function start_interactive(screen, layout) - local outer_gap = data.outer_gap or data.gap or api.beautiful.useless_gap or 0 - local inner_gap = data.inner_gap or data.gap or api.beautiful.useless_gap or 0 + local outer_gap = data.outer_gap or data.gap or api.beautiful.useless_gap * 2 or 0 + local inner_gap = data.inner_gap or data.gap or api.beautiful.useless_gap * 2 or 0 local label_font_family = api.beautiful.get_font( api.beautiful.mono_font or api.beautiful.font):get_family() local label_size = api.dpi(30) @@ -718,8 +718,8 @@ local function create(data) end local function run_cmd(init_area, cmd) - local outer_gap = data.outer_gap or data.gap or api.beautiful.useless_gap or 0 - local inner_gap = data.inner_gap or data.gap or api.beautiful.useless_gap or 0 + local outer_gap = data.outer_gap or data.gap or api.beautiful.useless_gap * 2 or 0 + local inner_gap = data.inner_gap or data.gap or api.beautiful.useless_gap * 2 or 0 init(init_area) push_history() diff --git a/layout.lua b/layout.lua index 8ee9ec4..ef1172c 100644 --- a/layout.lua +++ b/layout.lua @@ -85,7 +85,8 @@ local function create(name, editor) end local function arrange(p) - local wa = p.workarea + local useless_gap = p.useless_gap + local wa = get_screen(p.screen).workarea -- get the real workarea without the gap (instead of p.workarea) local cls = p.clients local regions = get_regions(wa, get_screen(p.screen).selected_tag) @@ -104,11 +105,13 @@ local function create(name, editor) end local region = c.machi_region + -- Editor already handled useless_gap in the stored regions. + -- We try to negate the gap of outer layer. p.geometries[c] = { - x = regions[region].x, - y = regions[region].y, - width = regions[region].width, - height = regions[region].height, + x = regions[region].x - useless_gap, + y = regions[region].y - useless_gap, + width = regions[region].width + useless_gap * 2, + height = regions[region].height + useless_gap * 2, } print("Put client " .. tostring(c) .. " to region " .. region) @@ -146,8 +149,8 @@ local function create(name, editor) c.machi_region = choice c.x = regions[choice].x c.y = regions[choice].y - c.width = regions[choice].width - c.height = regions[choice].height + c.width = max(1, regions[choice].width - 2 * border_width) + c.height = max(1, regions[choice].height - 2 * border_width) end end