From 00283492268d8315f4b9c257517b93b620c3cb34 Mon Sep 17 00:00:00 2001 From: actionless Date: Wed, 15 Jul 2015 15:24:08 +0200 Subject: [PATCH 1/4] feat(lib: awful: tag, layout): add 'master_fill_policy' property to tag --- lib/awful/layout/init.lua | 1 + lib/awful/tag.lua | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) 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/tag.lua b/lib/awful/tag.lua index 93ad2ae2c..97d345c81 100644 --- a/lib/awful/tag.lua +++ b/lib/awful/tag.lua @@ -409,6 +409,36 @@ function tag.getgap(t) return tag.getproperty(t, "useless_gap") or beautiful.useless_gap or 0 end +--- Set sizing 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 tag t The tag to modify, if null tag.selected() is used. +function tag.setmfpol(enabled, t) + local t = t or tag.selected() + tag.setproperty(t, "master_fill_policy", enabled) +end + +--- Toggle sizing policy for the master client(s) +-- @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 sizing policy for the master client(s) +-- @tparam tag t Optional tag. +-- @treturn string Can be set to +-- "expand" (fill all the available workarea) 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. @@ -702,6 +732,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") From fb4a3310149387c027de296bc252e151bf57eb9b Mon Sep 17 00:00:00 2001 From: actionless Date: Thu, 16 Jul 2015 11:48:18 +0200 Subject: [PATCH 2/4] feat(lib: awful: layout: suit: tile): add support for 'master_fill_policy' --- lib/awful/layout/suit/tile.lua | 6 +++++- lib/awful/tag.lua | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/awful/layout/suit/tile.lua b/lib/awful/layout/suit/tile.lua index ba0a524e7..4b4fb367f 100644 --- a/lib/awful/layout/suit/tile.lua +++ b/lib/awful/layout/suit/tile.lua @@ -216,13 +216,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 97d345c81..694c72687 100644 --- a/lib/awful/tag.lua +++ b/lib/awful/tag.lua @@ -409,7 +409,7 @@ function tag.getgap(t) return tag.getproperty(t, "useless_gap") or beautiful.useless_gap or 0 end ---- Set sizing policy for the master client(s) +--- 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) @@ -419,7 +419,7 @@ function tag.setmfpol(enabled, t) tag.setproperty(t, "master_fill_policy", enabled) end ---- Toggle sizing policy for the master client(s) +--- Toggle size fill policy for the master client(s) -- @tparam tag t The tag to modify, if null tag.selected() is used. function tag.togglemfpol(t) if tag.getmfpol(t) == "expand" then @@ -429,7 +429,7 @@ function tag.togglemfpol(t) end end ---- Get sizing policy for the master client(s) +--- Get size fill policy for the master client(s) -- @tparam tag t Optional tag. -- @treturn string Can be set to -- "expand" (fill all the available workarea) or From 34290433c27ea743449a909afbb27c68577aabb4 Mon Sep 17 00:00:00 2001 From: actionless Date: Thu, 16 Jul 2015 12:22:14 +0200 Subject: [PATCH 3/4] feat(lib: awful: layout: suit: corner): add support for 'master_fill_policy' --- lib/awful/layout/suit/corner.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 From 95743683fe24903868b9ff11ad1e63d6e14843b5 Mon Sep 17 00:00:00 2001 From: actionless Date: Thu, 30 Jul 2015 09:21:59 +0200 Subject: [PATCH 4/4] style(lib: awful: tag): fix docs --- lib/awful/tag.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/awful/tag.lua b/lib/awful/tag.lua index 694c72687..b0a9137e0 100644 --- a/lib/awful/tag.lua +++ b/lib/awful/tag.lua @@ -413,13 +413,14 @@ end -- @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 tag t The tag to modify, if null tag.selected() is used. -function tag.setmfpol(enabled, t) +-- @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", enabled) + 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 @@ -430,9 +431,9 @@ function tag.togglemfpol(t) end --- Get size fill policy for the master client(s) --- @tparam tag t Optional tag. --- @treturn string Can be set to --- "expand" (fill all the available workarea) or +-- @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()