Hello, Here is a new layout that I called adaptile, in most situation it is very similar to the standard tiling layout, but with some applications (such as skype) which forces a minimal size on their windows, it will do it's best to use most of your screen without overlapping windows.
Currently it only support right tiling, no left/top/bottom, but I'd like to get some feedback on it before implementing that. Cheers, Mawww. --- lib/awful/layout/suit/adaptile.lua.in | 71 +++++++++++++++++++++++++++++++++ 1 files changed, 71 insertions(+), 0 deletions(-) create mode 100644 lib/awful/layout/suit/adaptile.lua.in diff --git a/lib/awful/layout/suit/adaptile.lua.in b/lib/awful/layout/suit/adaptile.lua.in new file mode 100644 index 0000000..2c34eaa --- /dev/null +++ b/lib/awful/layout/suit/adaptile.lua.in @@ -0,0 +1,71 @@ +--------------------------------------------------------------------------- +-- @author Maxime Coste <[email protected]> +-- @copyright 2009 Maxime Coste +-- @release @AWESOME_VERSION@ +-- based upon tile.lua by Julien Danjou +--------------------------------------------------------------------------- + +-- Grab environment +local setmetatable = setmetatable +local ipairs = ipairs +local table = table +local math = math +local client = require("awful.client") +local tag = require("awful.tag") +local capi = +{ + screen = screen +} + +module("awful.layout.suit.adaptile") + +-- Tile a column, may recurse in order to find the best width for the column +-- when a window forces it's width +-- @return the effective width of the column +local function tile_column(cls, col, wa, recurse) + -- By default allow 3 recursion to find a column layout + recurse = recurse or 3 + local y = wa.y + for c = col.first,col.last do + local height = (wa.height - (y - wa.y)) / (col.last - c + 1) + local geometry = { x = col.x, y = y, height = height, width = col.width } + local real_geom = cls[c]:geometry(geometry) + y = real_geom.y + real_geom.height + -- Retry to tile if a window force width larger than the column one + if recurse > 0 and real_geom.width >= col.width then + return tile_column(cls, { first = col.first, last = col.last, x = col.x, width = real_geom.width }, wa, recurse-1) + end + end + return col.width +end + +-- Apply the adaptile layout to the screen +local function tile(_, screen) + local cls = client.tiled(screen) + local t = tag.selected() + local mwfact = tag.getmwfact(t) + local masterwin = math.min(tag.getnmaster(t), #cls) + local otherwin = math.max(#cls - masterwin, 0) + local ncol = math.min(math.max(tag.getncol(t), 1), otherwin) + + local wa = capi.screen[screen].workarea + + local x = wa.x + if masterwin > 0 then + local width = wa.width + if otherwin > 0 then + width = wa.width * mwfact + end + x = x + tile_column(cls, { first = 1, last = masterwin, x = x, width = width }, wa) + end + local last = masterwin + for i = 1,ncol do + -- Try to get equal width among remaining columns + local width = (wa.width - x) / (ncol - i + 1) + local first = last + 1 + last = last + math.floor((#cls - last)/(ncol - i + 1)) + x = x + tile_column(cls, { first = first, last = last, x = x, width = width }, wa) + end +end + +setmetatable(_M, { __call = tile }) -- 1.6.0.6 -- To unsubscribe, send mail to [email protected].
