X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/5d7c6078d11a697c4ea2a72300355d18ffd47d84..5318966270d86d52a2b9d7244b9336544a946d85:/layout/termfair.lua?ds=sidebyside diff --git a/layout/termfair.lua b/layout/termfair.lua index 6d24460..26a7130 100644 --- a/layout/termfair.lua +++ b/layout/termfair.lua @@ -9,7 +9,7 @@ --]] -local tag = require("awful.tag") +local scr = require("awful.screen") local math = { ceil = math.ceil, floor = math.floor, max = math.max } @@ -22,6 +22,9 @@ local function do_fair(p, orientation) -- Screen. local wa = p.workarea local cls = p.clients + local ta = scr.focused().selected_tag + + if not ta then return end if #cls <= 0 then return end @@ -50,12 +53,12 @@ local function do_fair(p, orientation) if #cls <= 0 then return end -- How many vertical columns? Read from nmaster on the tag. - local num_x = tonumber(termfair.nmaster) or tag.master_count - local ncol = tonumber(termfair.ncol) or tag.column_count - local width = math.floor((wa.width - (num_x + 1)*useless_gap) / num_x) + local num_x = tonumber(termfair.nmaster) or ta.master_count + local ncol = tonumber(termfair.ncol) or ta.column_count if num_x <= 2 then num_x = 2 end if ncol <= 1 then ncol = 1 end + local width = math.floor((wa.width - (num_x + 1)*useless_gap) / num_x) local num_y = math.max(math.ceil(#cls / num_x), ncol) local height = math.floor((wa.height - (num_y + 1)*useless_gap) / num_y) @@ -143,13 +146,14 @@ local function do_fair(p, orientation) -- +---+---+---+ +---+---+---+ -- How many vertical columns? Read from nmaster on the tag. - local num_x = tonumber(termfair.center.nmaster) or tag.master_count - local ncol = tonumber(termfair.center.ncol) or tag.column_count - local width = math.floor((wa.width - (num_x + 1)*useless_gap) / num_x) + local num_x = tonumber(termfair.center.nmaster) or ta.master_count + local ncol = tonumber(termfair.center.ncol) or ta.column_count if num_x <= 2 then num_x = 2 end if ncol <= 1 then ncol = 1 end + local width = math.floor((wa.width - (num_x + 1)*useless_gap) / num_x) + if #cls < num_x then -- Less clients than the number of columns, let's center it! local offset_x = wa.x + (wa.width - #cls*width - (#cls - 1)*useless_gap) / 2