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.
This commit is contained in:
Vincent Bernat 2014-01-01 09:11:38 +01:00
parent 93f6bbc73d
commit a8f3809a85
2 changed files with 10 additions and 19 deletions

View file

@ -754,11 +754,12 @@ end
--getpos : returns a tag to match position --getpos : returns a tag to match position
-- @param pos : the index to find -- @param pos : the index to find
-- @return v : the tag (found or created) at position == 'pos' -- @return v : the tag (found or created) at position == 'pos'
function getpos(pos, scr_arg, nospawn) function getpos(pos, args)
local v = nil local v = nil
local existing = {} local existing = {}
local selected = nil 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 -- search for existing tag assigned to pos
for i = 1, capi.screen.count() do 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 -- if making another of an existing tag, return the end of
-- the list the optional 2nd argument decides if we return -- the list the optional 2nd argument decides if we return
-- only -- only
if scr_arg ~= nil then v = (selected and
for _, tag in pairs(existing) do existing[awful.util.cycle(#existing, selected + 1)]) or
if tag.screen == scr_arg then return tag end existing[1]
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
end end
if not v then if not v then
-- search for preconf with 'pos' and create it -- search for preconf with 'pos' and create it
@ -797,7 +788,7 @@ function getpos(pos, scr_arg, nospawn)
v = add({name = i, v = add({name = i,
position = pos, position = pos,
noswitch = true, noswitch = true,
nospawn = nospawn}) nospawn = args.nospawn})
end end
end end
end end
@ -806,7 +797,7 @@ function getpos(pos, scr_arg, nospawn)
v = add({position = pos, v = add({position = pos,
name = pos, name = pos,
noswitch = true, noswitch = true,
nospawn = nospawn}) nospawn = args.nospawn})
end end
return v return v
end end

View file

@ -158,7 +158,7 @@ for i = 1, (shifty.config.maxtags or 9) do
function () function ()
local c = client.focus local c = client.focus
if c then if c then
local t = shifty.getpos(i, nil, true) local t = shifty.getpos(i, {nospawn = true })
awful.client.movetotag(t, c) awful.client.movetotag(t, c)
end end
end, end,
@ -166,7 +166,7 @@ for i = 1, (shifty.config.maxtags or 9) do
awful.key({ modkey, "Control", "Shift" }, i, awful.key({ modkey, "Control", "Shift" }, i,
function () function ()
if client.focus then if client.focus then
awful.client.toggletag(shifty.getpos(i, nil, true)) awful.client.toggletag(shifty.getpos(i, {nospawn = true}))
end end
end, end,
i == 5 and "Toggle this tag on this window" or nil), i == 5 and "Toggle this tag on this window" or nil),