diff --git a/lib/awful/layout/init.lua b/lib/awful/layout/init.lua index 11e65bd2a..984786068 100755 --- a/lib/awful/layout/init.lua +++ b/lib/awful/layout/init.lua @@ -192,6 +192,7 @@ capi.tag.connect_signal("property::windowfact", arrange_tag) capi.tag.connect_signal("property::selected", arrange_tag) capi.tag.connect_signal("property::activated", arrange_tag) capi.tag.connect_signal("property::useless_gap", arrange_tag) +capi.tag.connect_signal("property::master_fill_policy", arrange_tag) capi.tag.connect_signal("tagged", arrange_tag) for s = 1, capi.screen.count() do diff --git a/lib/awful/layout/suit/corner.lua b/lib/awful/layout/suit/corner.lua index a55ca4732..2024f5107 100644 --- a/lib/awful/layout/suit/corner.lua +++ b/lib/awful/layout/suit/corner.lua @@ -89,7 +89,7 @@ local function do_corner(p, orientation) row.x_increment = row.win_width row.win_idx = 0 - -- Extend master if there is only a few windows + -- Extend master if there is only a few windows and "expand" policy is set if #cls < 3 then if row_privileged then master.x = wa.x @@ -98,8 +98,13 @@ local function do_corner(p, orientation) master.y = wa.y master.height = wa.height end - if #cls < 2 then - master = wa + if #cls < 2 then + if tag.getmfpol(t) == "expand" then + master = wa + else + master.x = master.x + (wa.width - master.width)/2 + master.y = master.y + (wa.height - master.height)/2 + end end end diff --git a/lib/awful/layout/suit/tile.lua b/lib/awful/layout/suit/tile.lua index 42808e736..976b7bca0 100644 --- a/lib/awful/layout/suit/tile.lua +++ b/lib/awful/layout/suit/tile.lua @@ -234,13 +234,17 @@ local function do_tile(param, orientation) place_master = false end + local grow_master = tag.getmfpol(t) == "expand" -- 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 + if nother > 0 or not grow_master then size = math.min(wa[width] * mwfact, wa[width] - (coord - wa[x])) end + if nother == 0 and not grow_master then + coord = coord + (wa[width] - size)/2 + end if not data[0] then data[0] = {} end diff --git a/lib/awful/tag.lua b/lib/awful/tag.lua index 7bd347507..6a664dc5d 100644 --- a/lib/awful/tag.lua +++ b/lib/awful/tag.lua @@ -410,6 +410,37 @@ function tag.getgap(t) return tag.getproperty(t, "useless_gap") or beautiful.useless_gap or 0 end +--- Set size fill policy for the master client(s) +-- @tparam string policy Can be set to +-- "expand" (fill all the available workarea) or +-- "mwfact" (fill only an area inside the master width factor) +-- @tparam[opt=tag.selected()] tag t The tag to modify +function tag.setmfpol(policy, t) + local t = t or tag.selected() + tag.setproperty(t, "master_fill_policy", policy) +end + +--- Toggle size fill policy for the master client(s) +-- between "expand" and "mwfact" +-- @tparam tag t The tag to modify, if null tag.selected() is used. +function tag.togglemfpol(t) + if tag.getmfpol(t) == "expand" then + tag.setmfpol("mwfact", t) + else + tag.setmfpol("expand", t) + end +end + +--- Get size fill policy for the master client(s) +-- @tparam[opt=tag.selected()] tag t The tag +-- @treturn string Possible values are +-- "expand" (fill all the available workarea, default one) or +-- "mwfact" (fill only an area inside the master width factor) +function tag.getmfpol(t) + local t = t or tag.selected() + return tag.getproperty(t, "master_fill_policy") or "expand" +end + --- Set the number of master windows. -- @param nmaster The number of master windows. -- @param[opt] t The tag. @@ -703,6 +734,7 @@ capi.tag.add_signal("property::icon_only") capi.tag.add_signal("property::layout") capi.tag.add_signal("property::mwfact") capi.tag.add_signal("property::useless_gap") +capi.tag.add_signal("property::master_fill_policy") capi.tag.add_signal("property::ncol") capi.tag.add_signal("property::nmaster") capi.tag.add_signal("property::windowfact")