diff --git a/awesome/awesome/layouts/browse.lua b/awesome/awesome/layouts/browse.lua new file mode 100644 index 0000000..b92765d --- /dev/null +++ b/awesome/awesome/layouts/browse.lua @@ -0,0 +1,131 @@ +-- Grab environment. +local awful = require("awful") +local beautiful = require("beautiful") +local ipairs = ipairs +local tonumber = tonumber +local math = math + +module("vain.layout.browse") + +extra_padding = 0 + +name = "browse" + +function arrange(p) + + -- Layout with one fixed column meant for the browser window. Its + -- width is calculated according to mwfact. Other clients are + -- stacked vertically in a slave column on the right. + + -- (1) (2) (3) (4) + -- +-----+---+ +-----+---+ +-----+---+ +-----+---+ + -- | | | | | | | | 3 | | | 4 | + -- | | | | | | | | | | +---+ + -- | 1 | | -> | 1 | 2 | -> | 1 +---+ -> | 1 | 3 | + -- | | | | | | | | 2 | | +---+ + -- | | | | | | | | | | | 2 | + -- +-----+---+ +-----+---+ +-----+---+ +-----+---+ + + -- 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 + + -- Screen. + local wa = p.workarea + local cls = p.clients + + -- Width of main column? + local t = awful.tag.selected(p.screen) + local mwfact = awful.tag.getmwfact(t) + + -- Make slave windows overlap main window? Do this if ncol is 1. + local overlap_main = awful.tag.getncol(t) + + if #cls > 0 + then + -- Main column, fixed width and height. + local c = cls[#cls] + local g = {} + local mainwid = math.floor(wa.width * mwfact) + local slavewid = wa.width - mainwid + + if overlap_main == 1 + then + g.width = wa.width + + -- The size of the main window may be reduced a little bit. + -- This allows you to see if there are any windows below the + -- main window. + -- This only makes sense, though, if the main window is + -- overlapping everything else. + g.width = g.width - extra_padding + else + g.width = mainwid + end + + g.height = wa.height + g.x = wa.x + g.y = wa.y + if useless_gap > 0 + then + -- Reduce width once and move window to the right. Reduce + -- height twice, however. + g.width = g.width - useless_gap + g.height = g.height - 2 * useless_gap + g.x = g.x + useless_gap + g.y = g.y + useless_gap + + -- When there's no window to the right, add an additional + -- gap. + if overlap_main == 1 + then + g.width = g.width - useless_gap + end + end + c:geometry(g) + + -- Remaining clients stacked in slave column, new ones on top. + if #cls > 1 + then + local slavehei = math.floor(wa.height / (#cls - 1)) + for i = (#cls - 1),1,-1 + do + c = cls[i] + g = {} + g.width = slavewid + if i == (#cls - 1) + then + g.height = wa.height - (#cls - 2) * slavehei + else + g.height = slavehei + end + g.x = wa.x + mainwid + g.y = wa.y + (i - 1) * slavehei + if useless_gap > 0 + then + g.width = g.width - 2 * useless_gap + if i == 1 + then + -- This is the topmost client. Push it away from + -- the screen border (add to g.y and subtract + -- useless_gap once) and additionally shrink its + -- height. + g.height = g.height - 2 * useless_gap + g.y = g.y + useless_gap + else + -- All other clients. + g.height = g.height - useless_gap + end + g.x = g.x + useless_gap + end + c:geometry(g) + end + end + end +end + +-- vim: set et : diff --git a/awesome/awesome/layouts/termfair.lua b/awesome/awesome/layouts/termfair.lua new file mode 100644 index 0000000..7579a81 --- /dev/null +++ b/awesome/awesome/layouts/termfair.lua @@ -0,0 +1,136 @@ +-- Grab environment. +local tag = require("awful.tag") +local beautiful = require("beautiful") +local math = math +local tonumber = tonumber + +module("vain.layout.termfair") + +name = "termfair" + +function arrange(p) + + -- Layout with fixed number of vertical columns (read from nmaster). + -- New windows align from left to right. When a row is full, a now + -- one above it is created. Like this: + + -- (1) (2) (3) + -- +---+---+---+ +---+---+---+ +---+---+---+ + -- | | | | | | | | | | | | + -- | 1 | | | -> | 2 | 1 | | -> | 3 | 2 | 1 | -> + -- | | | | | | | | | | | | + -- +---+---+---+ +---+---+---+ +---+---+---+ + + -- (4) (5) (6) + -- +---+---+---+ +---+---+---+ +---+---+---+ + -- | 4 | | | | 5 | 4 | | | 6 | 5 | 4 | + -- +---+---+---+ -> +---+---+---+ -> +---+---+---+ + -- | 3 | 2 | 1 | | 3 | 2 | 1 | | 3 | 2 | 1 | + -- +---+---+---+ +---+---+---+ +---+---+---+ + + -- 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 + + -- Screen. + local wa = p.workarea + local cls = p.clients + + -- How many vertical columns? Read from nmaster on the tag. + local t = tag.selected(p.screen) + local num_x = tag.getnmaster(t) + + -- Do at least "desired_y" rows. Read this from ncol. (Yes, I use a + -- *column* setting to set the number of *rows*. That's because + -- num_x is the *master* setting -- it's the setting that's most + -- important to me.) + local desired_y = tag.getncol(t) + + if #cls > 0 + then + local num_y = math.max(math.ceil(#cls / num_x), desired_y) + local cur_num_x = num_x + local at_x = 0 + local at_y = 0 + local remaining_clients = #cls + local width = math.floor(wa.width / num_x) + local height = math.floor(wa.height / num_y) + + -- We start the first row. Left-align by limiting the number of + -- available slots. + if remaining_clients < num_x + then + cur_num_x = remaining_clients + end + + -- Iterate in reversed order. + for i = #cls,1,-1 + do + -- Get x and y position. + local c = cls[i] + local this_x = cur_num_x - at_x - 1 + local this_y = num_y - at_y - 1 + + -- Calc geometry. + local g = {} + if this_x == (num_x - 1) + then + g.width = wa.width - (num_x - 1) * width + else + g.width = width + end + if this_y == (num_y - 1) + then + g.height = wa.height - (num_y - 1) * height + else + g.height = height + end + g.x = wa.x + this_x * width + g.y = wa.y + this_y * height + if useless_gap > 0 + then + -- Top and left clients are shrinked by two steps and + -- get moved away from the border. Other clients just + -- get shrinked in one direction. + if this_x == 0 + then + g.width = g.width - 2 * useless_gap + g.x = g.x + useless_gap + else + g.width = g.width - useless_gap + end + + if this_y == 0 + then + g.height = g.height - 2 * useless_gap + g.y = g.y + useless_gap + else + g.height = g.height - useless_gap + end + end + c:geometry(g) + remaining_clients = remaining_clients - 1 + + -- Next grid position. + at_x = at_x + 1 + if at_x == num_x + then + -- Row full, create a new one above it. + at_x = 0 + at_y = at_y + 1 + + -- We start a new row. Left-align. + if remaining_clients < num_x + then + cur_num_x = remaining_clients + end + end + end + end +end + +-- vim: set et : diff --git a/awesome/awesome/layouts/uselessfair.lua b/awesome/awesome/layouts/uselessfair.lua new file mode 100644 index 0000000..89110e9 --- /dev/null +++ b/awesome/awesome/layouts/uselessfair.lua @@ -0,0 +1,119 @@ +--------------------------------------------------------------------------- +-- @author Julien Danjou <julien@danjou.info> +-- @copyright 2008 Julien Danjou +-- @copyright 2010 Vain +-- @release v3.4.6 +--------------------------------------------------------------------------- + +-- Grab environment we need +local beautiful = require("beautiful") +local ipairs = ipairs +local math = math +local tonumber = tonumber + +module("vain.layout.uselessfair") + +local function fair(p, orientation) + -- 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 + + -- Mostly copied. + local wa = p.workarea + local cls = p.clients + + if #cls > 0 then + local cells = math.ceil(math.sqrt(#cls)) + local strips = math.ceil(#cls / cells) + + local cell = 0 + local strip = 0 + for k, c in ipairs(cls) do + local g = {} + -- Save actual grid index for use in the useless_gap + -- routine. + local this_x = 0 + local this_y = 0 + if ( orientation == "east" and #cls > 2 ) + or ( orientation == "south" and #cls <= 2 ) then + if #cls < (strips * cells) and strip == strips - 1 then + g.width = wa.width / (cells - ((strips * cells) - #cls)) + else + g.width = wa.width / cells + end + g.height = wa.height / strips + + this_x = cell + this_y = strip + + g.x = wa.x + cell * g.width + g.y = wa.y + strip * g.height + + else + if #cls < (strips * cells) and strip == strips - 1 then + g.height = wa.height / (cells - ((strips * cells) - #cls)) + else + g.height = wa.height / cells + end + g.width = wa.width / strips + + this_x = strip + this_y = cell + + g.x = wa.x + strip * g.width + g.y = wa.y + cell * g.height + end + + -- Useless gap. + if useless_gap > 0 + then + -- Top and left clients are shrinked by two steps and + -- get moved away from the border. Other clients just + -- get shrinked in one direction. + if this_x == 0 + then + g.width = g.width - 2 * useless_gap + g.x = g.x + useless_gap + else + g.width = g.width - useless_gap + end + + if this_y == 0 + then + g.height = g.height - 2 * useless_gap + g.y = g.y + useless_gap + else + g.height = g.height - useless_gap + end + end + -- End of useless gap. + + c:geometry(g) + + cell = cell + 1 + if cell == cells then + cell = 0 + strip = strip + 1 + end + end + end +end + +--- Horizontal fair layout. +-- @param screen The screen to arrange. +horizontal = {} +horizontal.name = "fairh" +function horizontal.arrange(p) + return fair(p, "east") +end + +-- Vertical fair layout. +-- @param screen The screen to arrange. +name = "fairv" +function arrange(p) + return fair(p, "south") +end diff --git a/awesome/awesome/layouts/uselesstile.lua b/awesome/awesome/layouts/uselesstile.lua new file mode 100644 index 0000000..7a2a1a7 --- /dev/null +++ b/awesome/awesome/layouts/uselesstile.lua @@ -0,0 +1,226 @@ +--------------------------------------------------------------------------- +-- @author Donald Ephraim Curtis +-- @author Julien Danjou +-- @copyright 2009 Donald Ephraim Curtis +-- @copyright 2008 Julien Danjou +-- @release v3.4.11 +--------------------------------------------------------------------------- + +-- Grab environment we need +local tag = require("awful.tag") +local beautiful = require("beautiful") +local ipairs = ipairs +local math = math + +module("vain.layout.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 + + -- get our orientation right + local height = "height" + local width = "width" + local x = "x" + local y = "y" + if orientation == "top" or orientation == "bottom" then + height = "width" + width = "height" + x = "y" + y = "x" + end + + -- make this more generic (not just width) + available = wa[width] - (group.coord - wa[x]) + + -- find our total values + local total_fact = 0 + local min_fact = 1 + local size = group.size + for c = group.first,group.last do + -- determine the width/height based on the size_hint + local i = c - group.first +1 + local size_hints = cls[c].size_hints + local size_hint = size_hints["min_"..width] or size_hints["base_"..width] or 0 + size_hint = size_hint + cls[c].border_width*2 + size = math.max(size_hint, size) + + -- calculate the height + if not fact[i] then + fact[i] = min_fact + else + min_fact = math.min(fact[i],min_fact) + end + total_fact = total_fact + fact[i] + end + size = math.min(size, available) + + local coord = wa[y] + local geom = {} + local used_size = 0 + local unused = wa[height] + 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 + + coord = coord + geom[height] + unused = unused - geom[height] + total_fact = total_fact - fact[i] + used_size = math.max(used_size, geom[width]) + + -- Useless gap + if useless_gap > 0 + then + -- Top and left clients are shrinked by two steps and + -- get moved away from the border. Other clients just + -- get shrinked in one direction. + + top = false + left = false + + if geom[y] == wa[y] then + top = true + end + + if geom[x] == 0 or geom[x] == wa[x] then + left = true + end + + if top then + 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[x] = geom[x] + useless_gap + else + geom[width] = geom[width] - useless_gap + end + end + -- End of useless gap. + + geom = cls[c]:geometry(geom) + end + + return used_size +end + +local function tile(param, orientation) + local t = tag.selected(param.screen) + orientation = orientation or "right" + + -- this handles are different orientations + local height = "height" + local width = "width" + local x = "x" + local y = "y" + if orientation == "top" or orientation == "bottom" then + height = "width" + width = "height" + x = "y" + y = "x" + end + + local cls = param.clients + local nmaster = math.min(tag.getnmaster(t), #cls) + local nother = math.max(#cls - nmaster,0) + + local mwfact = tag.getmwfact(t) + local wa = param.workarea + local ncol = tag.getncol(t) + + local data = tag.getdata(t).windowfact + + if not data then + data = {} + tag.getdata(t).windowfact = data + end + + local coord = wa[x] + local place_master = true + if orientation == "left" or orientation == "top" then + -- if we are on the left or top we need to render the other windows first + place_master = false + end + + -- this was easier than writing functions because there is a lot of data we need + for d = 1,2 do + if place_master and nmaster > 0 then + local size = wa[width] + if nother > 0 then + size = math.min(wa[width] * mwfact, wa[width] - (coord - wa[x])) + end + if not data[0] then + data[0] = {} + end + coord = coord + tile_group(cls, wa, orientation, data[0], {first=1, last=nmaster, coord = coord, size = size}) + end + + if not place_master and nother > 0 then + local last = nmaster + + -- we have to modify the work area size to consider left and top views + local wasize = wa[width] + if nmaster > 0 and (orientation == "left" or orientation == "top") then + wasize = wa[width] - wa[width]*mwfact + 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 first = last + 1 + last = last + math.floor((#cls - last)/(ncol - i + 1)) + -- tile the column and update our current x coordinate + if not data[i] then + data[i] = {} + end + coord = coord + tile_group(cls, wa, orientation, data[i], { first = first, last = last, coord = coord, size = size }) + end + end + place_master = not place_master + end + +end + +right = {} +right.name = "uselesstile" +right.arrange = tile + +--- The main tile algo, on left. +-- @param screen The screen number to tile. +left = {} +left.name = "uselesstileleft" +function left.arrange(p) + return tile(p, "left") +end + +--- The main tile algo, on bottom. +-- @param screen The screen number to tile. +bottom = {} +bottom.name = "uselesstilebottom" +function bottom.arrange(p) + return tile(p, "bottom") +end + +--- The main tile algo, on top. +-- @param screen The screen number to tile. +top = {} +top.name = "uselesstiletop" +function top.arrange(p) + return tile(p, "top") +end + +arrange = right.arrange +name = right.name