X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/00a2951166f61cbbfe1d6e042fe0e53427c001cd..acece6c05439884cfd2ecd2e658a63d6f42f44b9:/layout/uselesstile.lua?ds=inline diff --git a/layout/uselesstile.lua b/layout/uselesstile.lua index b82c97e..eccfdad 100644 --- a/layout/uselesstile.lua +++ b/layout/uselesstile.lua @@ -2,7 +2,8 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2014 projektile + * (c) 2013 Luke Bonham * (c) 2009 Donald Ephraim Curtis * (c) 2008 Julien Danjolu @@ -11,7 +12,7 @@ local tag = require("awful.tag") local beautiful = require("beautiful") local ipairs = ipairs -local math = { floor = math.floor, +local math = { floor = math.floor, max = math.max, min = math.min } local tonumber = tonumber @@ -21,11 +22,16 @@ local uselesstile = {} local function tile_group(cls, wa, orientation, fact, group) -- A useless gap (like the dwm patch) can be defined with -- beautiful.useless_gap_width . - local useless_gap = tonumber(beautiful.useless_gap_width) - if useless_gap == nil - then - useless_gap = 0 - end + local useless_gap = tonumber(beautiful.useless_gap_width) or 0 + if useless_gap < 0 then useless_gap = 0 end + + -- A global border can be defined with + -- beautiful.global_border_width + local global_border = tonumber(beautiful.global_border_width) or 0 + if global_border < 0 then global_border = 0 end + + -- Themes border width requires an offset + local bw = tonumber(beautiful.border_width) or 0 -- get our orientation right local height = "height" @@ -40,7 +46,8 @@ local function tile_group(cls, wa, orientation, fact, group) end -- make this more generic (not just width) - available = wa[width] - (group.coord - wa[x]) + --if for top + available = wa[width] - (group.coord - wa[x]) -- it's truly not here -- find our total values local total_fact = 0 @@ -62,20 +69,19 @@ local function tile_group(cls, wa, orientation, fact, group) end total_fact = total_fact + fact[i] end - size = math.min(size, available) - + size = math.min(size, (available - global_border)) local coord = wa[y] local geom = {} local used_size = 0 - local unused = wa[height] + local unused = wa[height] - (global_border * 2) local stat_coord = wa[x] --stat_coord = size for c = group.first,group.last do local i = c - group.first +1 - geom[width] = size - geom[height] = math.floor(unused * fact[i] / total_fact) - geom[x] = group.coord - geom[y] = coord + geom[width] = size - global_border - (bw * 2) + geom[height] = math.floor(unused * fact[i] / total_fact) - (bw * 2) + geom[x] = group.coord + global_border + (useless_gap / 2) + geom[y] = coord + global_border + (useless_gap / 2) coord = coord + geom[height] unused = unused - geom[height] @@ -101,14 +107,14 @@ local function tile_group(cls, wa, orientation, fact, group) end if top then - geom[height] = geom[height] - 2 * useless_gap + geom[height] = geom[height] - (2 * useless_gap) geom[y] = geom[y] + useless_gap else geom[height] = geom[height] - useless_gap end if left then - geom[width] = geom[width] - 2 * useless_gap + geom[width] = geom[width] - (2 * useless_gap) geom[x] = geom[x] + useless_gap else geom[width] = geom[width] - useless_gap @@ -183,7 +189,7 @@ local function tile(param, orientation) end for i = 1,ncol do -- Try to get equal width among remaining columns - local size = math.min( (wasize - (coord - wa[x])) / (ncol - i + 1) ) + local size = math.min((wasize - (coord - wa[x])) / (ncol - i + 1)) --+ (global_border/(ncol))/(ncol+i^2) local first = last + 1 last = last + math.floor((#cls - last)/(ncol - i + 1)) -- tile the column and update our current x coordinate @@ -230,3 +236,4 @@ uselesstile.arrange = uselesstile.right.arrange uselesstile.name = uselesstile.right.name return uselesstile +