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
-- @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

View file

@ -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),