Hey Awesome-Devel, I think one of only things that I found really nice about xmonad was that the child windows can be resized so you can have something like:
http://omploader.org/vMTRqcw The screenshot is Awesome with the 'vile' layout I developed. I am attaching a patch. I basically rewrite the tile layout by changing how the dimension calculations were handled. It's a little more CPU intense. Basically, each window is given a proportion. If one window had a 1.5 and the other has a 1, then these are averaged out and one window will take up 75% and the other will date up 25%. The proportions are normalized to 1 except in the case where you initially add a window. It definitely needs some tweaking but it's good enough to let me be in awesome again. PS: There are actually two patches, I forgot some stuff on my initial commit and well, now there are two. -- Donald
From 3b69f11a836476422759dc01eb6ddc70407c79dd Mon Sep 17 00:00:00 2001 From: [email protected] <[email protected]> Date: Tue, 13 Jan 2009 13:31:37 -0600 Subject: [PATCH 1/2] vile is a Variable tILE layout that allows the user to select a single client window and resize that in it's layout. This means that the slave windows do not necissarily need to be the same size all the time. --- lib/awful/layout/suit/vile.lua.in | 174 +++++++++++++++++++++++++++++++++++++ lib/awful/tag.lua.in | 42 +++++++++ 2 files changed, 216 insertions(+), 0 deletions(-) create mode 100644 lib/awful/layout/suit/vile.lua.in diff --git a/lib/awful/layout/suit/vile.lua.in b/lib/awful/layout/suit/vile.lua.in new file mode 100644 index 0000000..d21c3fb --- /dev/null +++ b/lib/awful/layout/suit/vile.lua.in @@ -0,0 +1,174 @@ +--------------------------------------------------------------------------- +-- @author Donald Ephraim Curtis <[email protected]> +-- @author Julien Danjou <[email protected]> +-- @copyright 2009 Donald Ephraim Curtis +-- @copyright 2008 Julien Danjou +-- @release @AWESOME_VERSION@ +--------------------------------------------------------------------------- + +-- Grab environment we need +local setmetatable = setmetatable +local ipairs = ipairs +local math = math +local client = require("awful.client") +local tag = require("awful.tag") +local capi = +{ + screen = screen +} + +--- Tiled layouts module for awful +module("awful.layout.suit.vile") + +local function vile(_, screen, position) + if not position then position = "right" end + local t = tag.selected() + local nmaster = tag.getnmaster(t) + local mwfact = tag.getmwfact(t) + local ncol = tag.getncol(t) + + local mwindows = tag.getproperty(t,"masterwindows") + local owindows = tag.getproperty(t,"otherwindows") + + if not mwindows then + mwindows = {} + tag.setproperty(t,"masterwindows", mwindows) + end + + if not owindows then + owindows = {} + tag.setproperty(t,"otherwindows", owindows) + end + + local wa = capi.screen[screen].workarea + local cls = client.tiled(screen) + + local masterwin = math.min(#cls, nmaster) + local otherwin = math.max(#cls - masterwin, 0); + + -- find our total values + local mtotal = 0 + for i = 1,masterwin do + if not mwindows[i] then + mwindows[i] = 1 + end + mtotal = mtotal + mwindows[i] + end + + local ototal = 0 + for i = 1,otherwin do + if not owindows[i] then + owindows[i] = 1 + end + ototal = ototal + owindows[i] + end + + local mh, mw, mx, my + local oh, ow, ox, oy + -- calculate the master window height and width + if position == "right" then + mw = math.floor(wa.width * mwfact) + ow = wa.width - mw + mx = wa.x + my = wa.y + ox = wa.x + mw + oy = wa.y + elseif position == "left" then + mw = math.floor(wa.width * mwfact) + ow = wa.width - mw + mx = wa.x + ow + my = wa.y + ox = wa.x + oy = wa.y + elseif position == "bottom" then + mh = math.floor(wa.height * mwfact) + oh = wa.height - mh + mx = wa.x + my = wa.y + ox = wa.x + oy = wa.y + mh + else + mh = math.floor(wa.height * mwfact) + oh = wa.height - mh + mx = wa.x + my = wa.y + oh + ox = wa.x + oy = wa.y + end + + if not (nmaster > 0) then + ox = wa.x + oy = wa.y + mh = 0 + mw = 0 + end + + local real_ncol + if ncol > 0 then + real_ncol = math.min(otherwin, ncol) + else + real_ncol = math.min(otherwin, 1) + end + + if position == "left" or position == "right" then + for i, c in ipairs(cls) do + local geometry = {} + if i<= nmaster then + geometry.x = mx + geometry.y = my + geometry.width = mw + geometry.height = math.floor(wa.height * mwindows[i] / mtotal) + my = my + geometry.height + else + local j = i - nmaster + geometry.x = ox + geometry.y = oy + geometry.width = ow + geometry.height = math.floor(wa.height * owindows[j] / ototal) + oy = oy + geometry.height + end + + c:geometry(geometry) + end + else + for i, c in ipairs(cls) do + local geometry = {} + if i<= masterwin then + geometry.x = mx + geometry.y = my + geometry.height = mh + geometry.width = math.floor(wa.width * mwindows[i] / mtotal) + mx = mx + geometry.width + else + local j = i - masterwin + geometry.x = ox + geometry.y = oy + geometry.height = oh + geometry.width = math.floor(wa.width * owindows[j] / ototal) + ox = ox + geometry.width + end + + c:geometry(geometry) + end + end +end + +--- The main tile algo, on left. +-- @param screen The screen number to tile. +function left(screen) + return vile(nil, screen, "left") +end + +--- The main tile algo, on bottom. +-- @param screen The screen number to tile. +function bottom(screen) + return vile(nil, screen, "bottom") +end + +--- The main tile algo, on top. +-- @param screen The screen number to tile. +function top(screen) + return vile(nil, screen, "top") +end + +setmetatable(_M, { __call = vile }) diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in index 40b5481..b16aa6c 100644 --- a/lib/awful/tag.lua.in +++ b/lib/awful/tag.lua.in @@ -11,6 +11,7 @@ local ipairs = ipairs local otable = otable local capi = { + client = client, hooks = hooks, screen = screen, mouse = mouse @@ -120,6 +121,47 @@ function getmwfact(t) return getproperty(t, "mwfact") or 0.5 end +local function normalize(set) + total = 0 + for i,v in ipairs(set) do + total = total + v + end + + for i,v in ipairs(set) do + set[i] = v / total + end +end + +-- Change the width factor of a window +function incwfact(add, t, w) + local t = t or selected() + local c = c + if not c then + c = capi.client.focus + local clients = capi.client.get() + for k, cl in ipairs(clients) do + if cl == c then + w = k + end + end + end + + local nmaster = getnmaster(t) + local windows + if w > nmaster then + windows = getproperty(t, "otherwindows") or {} + w = w - nmaster + else + windows = getproperty(t, "masterwindows") or {} + end + curr = windows[w] or 1 + windows[w] = curr + add + + -- keep our ratios normalized + normalize(windows) + capi.hooks.arrange()(t.screen) +end + --- Set the number of master windows. -- @param nmaster The number of master windows. -- @param t Optional tag. -- 1.6.1
From c31369682c47358cb35c5e9e30bac9e5473d633c Mon Sep 17 00:00:00 2001 From: [email protected] <[email protected]> Date: Tue, 13 Jan 2009 14:32:39 -0600 Subject: [PATCH 2/2] Forgot to include the initialization things for the vile layout. Also needed to update the vile.lua file. --- lib/awful/layout/init.lua.in | 4 ++++ lib/awful/layout/suit/init.lua.in | 1 + lib/awful/layout/suit/vile.lua.in | 10 ++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/awful/layout/init.lua.in b/lib/awful/layout/init.lua.in index bf45763..c4b7fd9 100644 --- a/lib/awful/layout/init.lua.in +++ b/lib/awful/layout/init.lua.in @@ -70,6 +70,10 @@ local layouts_name = [suit.tile.left] = "tileleft", [suit.tile.bottom] = "tilebottom", [suit.tile.top] = "tiletop", + [suit.vile] = "vile", + [suit.vile.left] = "vileleft", + [suit.vile.bottom] = "vilebottom", + [suit.vile.top] = "viletop", [suit.fair] = "fairv", [suit.fair.horizontal] = "fairh", [suit.max] = "max", diff --git a/lib/awful/layout/suit/init.lua.in b/lib/awful/layout/suit/init.lua.in index ae83edf..8c57bf7 100644 --- a/lib/awful/layout/suit/init.lua.in +++ b/lib/awful/layout/suit/init.lua.in @@ -1,5 +1,6 @@ require("awful.layout.suit.max") require("awful.layout.suit.tile") +require("awful.layout.suit.vile") require("awful.layout.suit.fair") require("awful.layout.suit.floating") require("awful.layout.suit.magnifier") diff --git a/lib/awful/layout/suit/vile.lua.in b/lib/awful/layout/suit/vile.lua.in index d21c3fb..0c65afe 100644 --- a/lib/awful/layout/suit/vile.lua.in +++ b/lib/awful/layout/suit/vile.lua.in @@ -48,17 +48,23 @@ local function vile(_, screen, position) -- find our total values local mtotal = 0 + local min = 1 for i = 1,masterwin do if not mwindows[i] then - mwindows[i] = 1 + mwindows[i] = min + else + min = math.min(owindows[i],min) end mtotal = mtotal + mwindows[i] end local ototal = 0 + local min = 1 for i = 1,otherwin do if not owindows[i] then - owindows[i] = 1 + owindows[i] = min + else + min = math.min(owindows[i],min) end ototal = ototal + owindows[i] end -- 1.6.1
pgpnKfel5MtjE.pgp
Description: PGP signature
