awful.client: new cycle() method

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-02-14 17:53:03 +01:00
parent 8ec2b33fb3
commit c69afaed58
1 changed files with 22 additions and 0 deletions

View File

@ -367,6 +367,28 @@ function swap.byidx(i, c)
end
end
--- Cycle clients.
-- @param clockwise True to cycle clients clockwise.
-- @param screen Optional screen where to cycle clients.
function cycle(clockwise, screen)
local screen = screen or capi.mouse.screen
local cls = visible(screen)
-- We can't rotate without at least 2 clients, buddy.
if #cls >= 2 then
local c = table.remove(cls, 1)
if clockwise then
for i = #cls, 1, -1 do
c:swap(cls[i])
end
else
for _, rc in pairs(cls) do
print(_)
c:swap(rc)
end
end
end
end
--- Get the master window.
-- @param screen Optional screen number, otherwise screen mouse is used.
-- @return The master window.