From e8908e2c62306b8b47e9006e2dada1ec1732d677 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 11 Apr 2016 00:30:05 -0400 Subject: [PATCH] awful.tag: Rename mwfact to master_width_factor --- lib/awful/client.lua | 2 +- lib/awful/layout/init.lua | 4 +- lib/awful/layout/suit/corner.lua | 2 +- lib/awful/layout/suit/magnifier.lua | 5 +- lib/awful/layout/suit/tile.lua | 9 ++-- lib/awful/tag.lua | 74 ++++++++++++++++------------- tests/examples/shims/tag.lua | 2 + tests/test-awesomerc.lua | 12 ++--- 8 files changed, 62 insertions(+), 48 deletions(-) diff --git a/lib/awful/client.lua b/lib/awful/client.lua index af305672..6241856e 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -781,7 +781,7 @@ function client.idx(c) -- based on the how the tiling algorithm places clients we calculate -- the column, we could easily use the for loop in the program but we can -- calculate it. - local ncol = t.ncol + local ncol = t.column_count -- minimum number of clients per column local percol = math.floor(nother / ncol) -- number of columns with an extra client diff --git a/lib/awful/layout/init.lua b/lib/awful/layout/init.lua index 46853af3..43dd2344 100644 --- a/lib/awful/layout/init.lua +++ b/lib/awful/layout/init.lua @@ -219,9 +219,9 @@ end capi.screen.add_signal("arrange") -capi.tag.connect_signal("property::mwfact", arrange_tag) +capi.tag.connect_signal("property::master_width_factor", arrange_tag) capi.tag.connect_signal("property::nmaster", arrange_tag) -capi.tag.connect_signal("property::ncol", arrange_tag) +capi.tag.connect_signal("property::column_count", arrange_tag) capi.tag.connect_signal("property::layout", arrange_tag) capi.tag.connect_signal("property::windowfact", arrange_tag) capi.tag.connect_signal("property::selected", arrange_tag) diff --git a/lib/awful/layout/suit/corner.lua b/lib/awful/layout/suit/corner.lua index 7932e65a..4b8c2071 100644 --- a/lib/awful/layout/suit/corner.lua +++ b/lib/awful/layout/suit/corner.lua @@ -32,7 +32,7 @@ local function do_corner(p, orientation) -- Use the nmaster field of the tag in a cheaty way local row_privileged = ((cls[1].screen.selected_tag.nmaster % 2) == 0) - local master_factor = cls[1].screen.selected_tag.mwfact + local master_factor = cls[1].screen.selected_tag.master_width_factor master.width = master_factor * wa.width master.height = master_factor * wa.height diff --git a/lib/awful/layout/suit/magnifier.lua b/lib/awful/layout/suit/magnifier.lua index 979672fe..7842f72a 100644 --- a/lib/awful/layout/suit/magnifier.lua +++ b/lib/awful/layout/suit/magnifier.lua @@ -39,7 +39,8 @@ function magnifier.mouse_resize_handler(c, corner, x, y) -- New master width factor local mwfact = dist / maxdist_pow - c.screen.selected_tag.mwfact = math.min(math.max(0.01, mwfact), 0.99) + c.screen.selected_tag.master_width_factor + = math.min(math.max(0.01, mwfact), 0.99) return true end end @@ -53,7 +54,7 @@ function magnifier.arrange(p) local cls = p.clients local focus = p.focus or capi.client.focus local t = p.tag or capi.screen[p.screen].selected_tag - local mwfact = t.mwfact + local mwfact = t.master_width_factor local fidx -- Check that the focused window is on the right screen diff --git a/lib/awful/layout/suit/tile.lua b/lib/awful/layout/suit/tile.lua index 5637f7c1..ae1ff9b3 100644 --- a/lib/awful/layout/suit/tile.lua +++ b/lib/awful/layout/suit/tile.lua @@ -29,7 +29,7 @@ tile.resize_jump_to_corner = true local function mouse_resize_handler(c, _, _, _, orientation) orientation = orientation or "tile" local wa = capi.screen[c.screen].workarea - local mwfact = c.screen.selected_tag.mwfact + local mwfact = c.screen.selected_tag.master_width_factor local cursor local g = c:geometry() local offset = 0 @@ -126,7 +126,8 @@ local function mouse_resize_handler(c, _, _, _, orientation) wfact = wfact_x end - c.screen.selected_tag.mwfact = math.min(math.max(new_mwfact, 0.01), 0.99) + c.screen.selected_tag.master_width_factor + = math.min(math.max(new_mwfact, 0.01), 0.99) client.setwfact(math.min(math.max(wfact,0.01), 0.99), c) return true end @@ -211,9 +212,9 @@ local function do_tile(param, orientation) local nmaster = math.min(t.nmaster, #cls) local nother = math.max(#cls - nmaster,0) - local mwfact = t.mwfact + local mwfact = t.master_width_factor local wa = param.workarea - local ncol = t.ncol + local ncol = t.column_count local data = tag.getdata(t).windowfact diff --git a/lib/awful/tag.lua b/lib/awful/tag.lua index 170423a5..7391a268 100644 --- a/lib/awful/tag.lua +++ b/lib/awful/tag.lua @@ -530,53 +530,58 @@ end -- -- **Signal:** -- --- * *property::mwfact* +-- * *property::mwfact* (deprecated) +-- * *property::master_width_factor* -- --- @property mwfact +-- @property master_width_factor -- @param number Between 0 and 1 -- @see nmaster --- @see ncol +-- @see column_count -- @see master_fill_policy -- @see gap -function tag.object.set_mwfact(t, mwfact) +function tag.object.set_master_width_factor(t, mwfact) if mwfact >= 0 and mwfact <= 1 then tag.setproperty(t, "mwfact", mwfact) + tag.setproperty(t, "master_width_factor", mwfact) end end -function tag.object.get_mwfact(t) - return tag.getproperty(t, "mwfact") or 0.5 +function tag.object.get_master_width_factor(t) + return tag.getproperty(t, "master_width_factor") or 0.5 end --- Set master width factor. -- @deprecated awful.tag.setmwfact -- @see master_fill_policy +-- @see master_width_factor -- @param mwfact Master width factor. -- @param t The tag to modify, if null tag.selected() is used. function tag.setmwfact(mwfact, t) - util.deprecate("Use t.mwfact = mwfact instead of awful.tag.setmwfact") + util.deprecate("Use t.master_width_factor = mwfact instead of awful.tag.setmwfact") - tag.object.get_mwfact(t or ascreen.focused().selected_tag, mwfact) + tag.object.get_master_width_factor(t or ascreen.focused().selected_tag, mwfact) end --- Increase master width factor. -- @function awful.tag.incmwfact +-- @see master_width_factor -- @param add Value to add to master width factor. -- @param t The tag to modify, if null tag.selected() is used. function tag.incmwfact(add, t) t = t or t or ascreen.focused().selected_tag - tag.object.set_mwfact(t, tag.object.get_mwfact(t) + add) + tag.object.set_master_width_factor(t, tag.object.get_master_width_factor(t) + add) end --- Get master width factor. -- @deprecated awful.tag.getmwfact --- @see mwfact +-- @see master_width_factor +-- @see master_fill_policy -- @param[opt] t The tag. function tag.getmwfact(t) - util.deprecate("Use t.mwfact instead of awful.tag.getmwfact") + util.deprecate("Use t.master_width_factor instead of awful.tag.getmwfact") - return tag.object.get_mwfact(t or ascreen.focused().selected_tag) + return tag.object.get_master_width_factor(t or ascreen.focused().selected_tag) end --- An ordered list of layouts. @@ -805,7 +810,7 @@ end -- * *property::master_fill_policy* -- -- @property master_fill_policy --- @param string "expand" or "mwfact" +-- @param string "expand" or "master_width_factor" function tag.object.get_master_fill_policy(t) return tag.getproperty(t, "master_fill_policy") or "expand" @@ -816,7 +821,7 @@ end -- @see master_fill_policy -- @tparam string policy Can be set to -- "expand" (fill all the available workarea) or --- "mwfact" (fill only an area inside the master width factor) +-- "master_width_factor" (fill only an area inside the master width factor) -- @tparam[opt=tag.selected()] tag t The tag to modify function tag.setmfpol(policy, t) util.deprecate("Use t.master_fill_policy = policy instead of awful.tag.setmfpol") @@ -826,7 +831,7 @@ function tag.setmfpol(policy, t) end --- Toggle size fill policy for the master client(s) --- between "expand" and "mwfact". +-- between "expand" and "master_width_factor". -- @function awful.tag.togglemfpol -- @see master_fill_policy -- @tparam tag t The tag to modify, if null tag.selected() is used. @@ -834,7 +839,7 @@ function tag.togglemfpol(t) t = t or ascreen.focused().selected_tag if tag.getmfpol(t) == "expand" then - tag.setproperty(t, "master_fill_policy", "mwfact") + tag.setproperty(t, "master_fill_policy", "master_width_factor") else tag.setproperty(t, "master_fill_policy", "expand") end @@ -846,7 +851,7 @@ end -- @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) +-- "master_width_factor" (fill only an area inside the master width factor) function tag.getmfpol(t) util.deprecate("Use t.master_fill_policy instead of awful.tag.getmfpol") @@ -961,51 +966,54 @@ end -- -- **Signal:** -- --- * *property::ncol* +-- * *property::ncol* (deprecated) +-- * *property::column_count* -- --- @property ncol --- @param integer ncol Has to be greater than 1 +-- @property column_count +-- @tparam integer ncol Has to be greater than 1 -function tag.object.set_ncol(t, ncol) +function tag.object.set_column_count(t, ncol) if ncol >= 1 then tag.setproperty(t, "ncol", ncol) + tag.setproperty(t, "column_count", ncol) end end -function tag.object.get_ncol(t) - return tag.getproperty(t, "ncol") or 1 +function tag.object.get_column_count(t) + return tag.getproperty(t, "column_count") or 1 end --- Set number of column windows. -- @deprecated awful.tag.setncol --- @see ncol +-- @see column_count -- @param ncol The number of column. -- @param t The tag to modify, if null tag.selected() is used. function tag.setncol(ncol, t) - util.deprecate("Use t.ncol = new_index instead of awful.tag.setncol") + util.deprecate("Use t.column_count = new_index instead of awful.tag.setncol") t = t or ascreen.focused().selected_tag if ncol >= 1 then tag.setproperty(t, "ncol", ncol) + tag.setproperty(t, "column_count", ncol) end end --- Get number of column windows. -- @deprecated awful.tag.getncol --- @see ncol +-- @see column_count -- @param[opt] t The tag. function tag.getncol(t) - util.deprecate("Use t.ncol instead of awful.tag.getncol") + util.deprecate("Use t.column_count instead of awful.tag.getncol") t = t or ascreen.focused().selected_tag - return tag.getproperty(t, "ncol") or 1 + return tag.getproperty(t, "column_count") or 1 end --- Increase number of column windows. -- @function awful.tag.incncol -- @param add Value to add to number of column windows. -- @param[opt] t The tag to modify, if null tag.selected() is used. --- @tparam[opt=false] boolean sensible Limit ncol based on the number of visible +-- @tparam[opt=false] boolean sensible Limit column_count based on the number of visible -- tiled windows? function tag.incncol(add, t, sensible) t = t or ascreen.focused().selected_tag @@ -1016,7 +1024,7 @@ function tag.incncol(add, t, sensible) local nmaster = tag.object.get_nmaster(t) local nsecondary = ntiled - nmaster - local ncol = tag.object.get_ncol(t) + local ncol = tag.object.get_column_count(t) if ncol > nsecondary then ncol = nsecondary end @@ -1026,9 +1034,9 @@ function tag.incncol(add, t, sensible) newncol = nsecondary end - tag.object.set_ncol(t, newncol) + tag.object.set_column_count(t, newncol) else - tag.object.set_ncol(t, tag.object.get_ncol(t) + add) + tag.object.set_column_count(t, tag.object.get_column_count(t) + add) end end @@ -1304,9 +1312,11 @@ capi.tag.add_signal("property::icon") capi.tag.add_signal("property::icon_only") capi.tag.add_signal("property::layout") capi.tag.add_signal("property::mwfact") +capi.tag.add_signal("property::master_width_factor") 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::column_count") capi.tag.add_signal("property::nmaster") capi.tag.add_signal("property::windowfact") capi.tag.add_signal("property::screen") diff --git a/tests/examples/shims/tag.lua b/tests/examples/shims/tag.lua index c7bec175..de3a5f35 100644 --- a/tests/examples/shims/tag.lua +++ b/tests/examples/shims/tag.lua @@ -9,8 +9,10 @@ local function new_tag(_, args) ret:add_signal("property::name") ret:add_signal("property::geometry") ret:add_signal("property::screen") + ret:add_signal("property::master_width_factor") ret:add_signal("property::mwfact") ret:add_signal("property::ncol") + ret:add_signal("property::column_count") ret:add_signal("property::nmaster") ret:add_signal("property::index") ret:add_signal("property::useless_gap") diff --git a/tests/test-awesomerc.lua b/tests/test-awesomerc.lua index 0e26750a..75cc0773 100644 --- a/tests/test-awesomerc.lua +++ b/tests/test-awesomerc.lua @@ -79,8 +79,8 @@ function() assert(old_c.ontop) - -- Now, test the mwfact - assert(t.mwfact == 0.5) + -- Now, test the master_width_factor + assert(t.master_width_factor == 0.5) get_callback({modkey}, "l")() @@ -91,7 +91,7 @@ end, function() local _, t = get_c_and_t() - assert(t.mwfact == 0.55) + assert(t.master_width_factor == 0.55) -- Now, test the nmaster assert(t.nmaster == 1) @@ -107,8 +107,8 @@ function() assert(t.nmaster == 2) - -- Now, test the ncol - assert(t.ncol == 1) + -- Now, test the column_count + assert(t.column_count == 1) get_callback({modkey, "Control"}, "h")() get_callback({modkey, "Shift" }, "l")() @@ -120,7 +120,7 @@ end, function() local _, t = get_c_and_t() - assert(t.ncol == 2) + assert(t.column_count == 2) -- Now, test the switching tag assert(t.index == 1)