Guys, Made a new fix. I was able to get mouse resizing working (both horizontal and verticle) and it seems to work pretty well. I could really use someone to kinda go over the code and think of some optimizations. I know for a fact that in my layout code itself there are some assignments that are probably redundant and could be fixed but I haven't had the time to sit down and fix them. Please let me know of anymore bugs.
Oh, I also fixed it so if there is only one window it will take up the whole work area. I merged all my commits into one patch on top of the newest master (thanks git) so I am not officially seeing why git is so beautiful. -- Donald (Thu, Jan 15, 2009 at 02:05:02PM -0500) Alex Cornejo <[email protected]>: > Just tested. > > I'm not sure how it is supposed to work, I was not able to resize > vertically using the mouse, and actually not even horizontal resize > worked with the mouse (but it did with the keyb). > > Also, the layout icon for vile is missing and should be added. And in > tags with a single window vile failed to use the whole workspace (it > just displayed on the window on half the screen). > > Cheers, > > Alex > > > On Wed, Jan 14, 2009 at 10:45 AM, Julien Danjou <[email protected]> wrote: > > At 1231945407 time_t, Donald Ephraim Curtis wrote: > >> Properties masterwindows and otherwindows are what keep track of the > >> weights of the windows. Basically this is where I store everything. I kepp > >> them separate so in case you do something to the master windows (when you > >> have more than one) then they are saved separate from the slave windows. > >> > >> The reason that this implementation doesn't suffer from the same things > >> you mention is that I keep the calues normalized. > > > > Thanks for the explanation. > > > > It'd be nice to have usage feedbacks from people from this list. > > > > Anyone? > > > > -- > > Julien Danjou > > // ᐰ <[email protected]> http://julien.danjou.info > > // 9A0D 5FD9 EB42 22F6 8974 C95C A462 B51E C2FE E5CD > > > > -----BEGIN PGP SIGNATURE----- > > Version: GnuPG v1.4.9 (GNU/Linux) > > > > iEYEARECAAYFAkluCJsACgkQpGK1HsL+5c33CgCfX+cP7VjH5n45Yf0i1oBeWtEO > > +yYAn2dfHEP8kGE9kHKQ3C/OsYgHBH5c > > =OCPv > > -----END PGP SIGNATURE----- > > > >
From 9cea30ba79adb57f9cbf3f6b90dc2ee123f73e5b Mon Sep 17 00:00:00 2001 From: [email protected] <[email protected]> Date: Tue, 13 Jan 2009 13:31:37 -0600 Subject: [PATCH] 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. Fixed the bug where having only master or other windows would not display full screen. Added mouse resizing to the layout. --- lib/awful/client.lua.in | 88 +++++++++++++++++ lib/awful/layout/init.lua.in | 4 + lib/awful/layout/suit/init.lua.in | 1 + lib/awful/layout/suit/vile.lua.in | 186 +++++++++++++++++++++++++++++++++++++ lib/awful/mouse.lua.in | 73 +++++++++++++++ 5 files changed, 352 insertions(+), 0 deletions(-) create mode 100644 lib/awful/layout/suit/vile.lua.in diff --git a/lib/awful/client.lua.in b/lib/awful/client.lua.in index 65103a8..54c9d7f 100644 --- a/lib/awful/client.lua.in +++ b/lib/awful/client.lua.in @@ -593,6 +593,94 @@ function floating.delete(c) data.floating[c] = nil 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 + +function idx(c) + local c = c or capi.client.focus + local clients = tiled(c.screen) + for k, cl in ipairs(clients) do + if cl == c then + return k + end + end + return nil +end + +-- Set the window by index (or the currently selected window) +function setwfact(wfact, c) + local t = t or tag.selected() + + -- get the currently selected window + local c = c or capi.client.focus + local w = idx(c) + + local cls = tiled(t.screen) + local nmaster = tag.getnmaster(t) + + -- n is the number of windows currently visible for which we have to be concerned with the properties + local n + if w > nmaster then + n = #cls - nmaster + w = w - nmaster + windows = tag.getproperty(t, "otherwindows") or {} + else + windows = tag.getproperty(t, "masterwindows") or {} + n = nmaster + end + + -- set this window to the given wfact + windows[w] = wfact + local rest = 1 - wfact + + -- calculate the current denominator + local total = 0 + for i = 1,n do + if i ~= w then + total = total + windows[i] + end + end + + -- normalize the windows + for i = 1,n do + if i ~= w then + windows[i] = (windows[i] * rest) / total + end + end +end + +-- Change the width factor of a window (indexed by number) +function incwfact(add, c) + local c = c or capi.client.focus + local t = tag.selected() + + local w = idx(c, t) + + local nmaster = tag.getnmaster(t) + local windows + if w > nmaster then + windows = tag.getproperty(t, "otherwindows") or {} + w = w - nmaster + else + windows = tag.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 + + -- Register standards hooks hooks.focus.register(focus.history.add) hooks.unmanage.register(focus.history.delete) 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 new file mode 100644 index 0000000..11da9e8 --- /dev/null +++ b/lib/awful/layout/suit/vile.lua.in @@ -0,0 +1,186 @@ +--------------------------------------------------------------------------- +-- @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 nother = #cls - nmaster + + 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) + + + -- find our total values + local mtotal = 0 + local min = 1 + for i = 1,nmaster do + if not mwindows[i] then + mwindows[i] = min + else + min = math.min(mwindows[i],min) + end + mtotal = mtotal + mwindows[i] + end + + local ototal = 0 + local min = 1 + for i = 1,nother do + if not owindows[i] then + owindows[i] = min + else + min = math.min(owindows[i],min) + end + ototal = ototal + owindows[i] + end + + local mh, mw, mx, my + local oh, ow, ox, oy + -- calculate the master window height and width + if nmaster > 0 and nother > 0 then + 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 + elseif nmaster > 0 then + mh = wa.height + mw = wa.width + mx = wa.x + my = wa.y + ox = 0 + oy = 0 + oh = 0 + ow = 0 + else + ox = wa.x + oy = wa.y + oh = wa.height + ow = wa.width + mx = 0 + my = 0 + mh = 0 + mw = 0 + 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<= nmaster 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 - nmaster + 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/mouse.lua.in b/lib/awful/mouse.lua.in index 4390506..ac2fb68 100644 --- a/lib/awful/mouse.lua.in +++ b/lib/awful/mouse.lua.in @@ -392,6 +392,73 @@ local function client_resize_tiled(c, lay) end, cursor) end +local function client_resize_viled(c, lay) + local wa = capi.screen[c.screen].workarea + local mwfact = tag.getmwfact() + local cursor + if lay == layout.suit.vile then + capi.mouse.coords({ x = wa.x + wa.width * mwfact }) + cursor = "sb_h_double_arrow" + elseif lay == layout.suit.vile.left then + capi.mouse.coords({ x = wa.x + wa.width * (1 - mwfact) }) + cursor = "sb_h_double_arrow" + elseif lay == layout.suit.vile.bottom then + capi.mouse.coords({ y = wa.y + wa.height * mwfact }) + cursor = "sb_v_double_arrow" + else + capi.mouse.coords({ y = wa.y + wa.height * (1 - mwfact) }) + cursor = "sb_v_double_arrow" + end + + capi.mousegrabber.run(function (mouse) + for k, v in ipairs(mouse.buttons) do + if v then + local fact_x = (mouse.x - wa.x) / wa.width + local fact_y = (mouse.y - wa.y) / wa.height + local mwfact + + local g = c:geometry() + + + -- we have to make sure we're not on the last visible client where we have to use different settings. + local wfact + local wfact_x, wfact_y + if (g.y+g.height+15) > (wa.y+wa.height) then + wfact_y = (g.y + g.height - mouse.y) / wa.height + else + wfact_y = (mouse.y - g.y) / wa.height + end + + if (g.x+g.width+15) > (wa.x+wa.width) then + wfact_x = (g.x + g.width - mouse.x) / wa.width + else + wfact_x = (mouse.x - g.x) / wa.width + end + + + if lay == layout.suit.vile then + mwfact = fact_x + wfact = wfact_y + elseif lay == layout.suit.vile.left then + mwfact = 1 - fact_x + wfact = wfact_y + elseif lay == layout.suit.vile.bottom then + mwfact = fact_y + wfact = wfact_x + else + mwfact = 1 - fact_y + wfact = wfact_x + end + + tag.setmwfact(math.min(math.max(mwfact, 0.01), 0.99), tag.selected(c.screen)) + aclient.setwfact(math.min(math.max(wfact,0.01), 0.99), c) + return true + end + end + return false + end, cursor) +end + local function client_resize_floating(c, corner, fixed_x, fixed_y) local corner, x, y = client.corner(c, corner) local g = c:geometry() @@ -483,6 +550,12 @@ function client.resize(c, corner) or lay == layout.suit.tile.top or lay == layout.suit.tile.bottom then return client_resize_tiled(c, lay) + elseif lay == layout.suit.vile + or lay == layout.suit.vile.left + or lay == layout.suit.vile.top + or lay == layout.suit.vile.bottom + then + return client_resize_viled(c, lay) elseif lay == layout.suit.magnifier then return client_resize_magnifier(c, corner) end -- 1.6.1
pgp3rt7vg6CFh.pgp
Description: PGP signature
