From a8f3809a855d9f0677f9dfb7eac0ce1fbb940ec1 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Wed, 1 Jan 2014 09:11:38 +0100 Subject: [PATCH] shifty: remove unused argument from `getpos()` Instead, use a generic optional `args` argument and use it to tell we don't want to spawn anything. --- lib/shifty.lua | 25 ++++++++----------------- rc/tags.lua | 4 ++-- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/lib/shifty.lua b/lib/shifty.lua index 7fce085..ce9f7f5 100644 --- a/lib/shifty.lua +++ b/lib/shifty.lua @@ -754,11 +754,12 @@ end --getpos : returns a tag to match position -- @param pos : the index to find -- @return v : the tag (found or created) at position == 'pos' -function getpos(pos, scr_arg, nospawn) +function getpos(pos, args) local v = nil local existing = {} local selected = nil - local scr = scr_arg or capi.mouse.screen or 1 + local scr = capi.mouse.screen or 1 + local args = args or {} -- search for existing tag assigned to pos for i = 1, capi.screen.count() do @@ -776,19 +777,9 @@ function getpos(pos, scr_arg, nospawn) -- if making another of an existing tag, return the end of -- the list the optional 2nd argument decides if we return -- only - if scr_arg ~= nil then - for _, tag in pairs(existing) do - if tag.screen == scr_arg then return tag end - end - -- no tag with a position and scr_arg match found, clear - -- v and allow the subseqeunt conditions to be evaluated - v = nil - else - v = (selected and - existing[awful.util.cycle(#existing, selected + 1)]) or - existing[1] - end - + v = (selected and + existing[awful.util.cycle(#existing, selected + 1)]) or + existing[1] end if not v then -- search for preconf with 'pos' and create it @@ -797,7 +788,7 @@ function getpos(pos, scr_arg, nospawn) v = add({name = i, position = pos, noswitch = true, - nospawn = nospawn}) + nospawn = args.nospawn}) end end end @@ -806,7 +797,7 @@ function getpos(pos, scr_arg, nospawn) v = add({position = pos, name = pos, noswitch = true, - nospawn = nospawn}) + nospawn = args.nospawn}) end return v end diff --git a/rc/tags.lua b/rc/tags.lua index 29918be..9494df1 100644 --- a/rc/tags.lua +++ b/rc/tags.lua @@ -158,7 +158,7 @@ for i = 1, (shifty.config.maxtags or 9) do function () local c = client.focus if c then - local t = shifty.getpos(i, nil, true) + local t = shifty.getpos(i, {nospawn = true }) awful.client.movetotag(t, c) end end, @@ -166,7 +166,7 @@ for i = 1, (shifty.config.maxtags or 9) do awful.key({ modkey, "Control", "Shift" }, i, function () if client.focus then - awful.client.toggletag(shifty.getpos(i, nil, true)) + awful.client.toggletag(shifty.getpos(i, {nospawn = true})) end end, i == 5 and "Toggle this tag on this window" or nil),