From c69afaed5893943ccda169d8db15c3a7849813b8 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sat, 14 Feb 2009 17:53:03 +0100 Subject: [PATCH] awful.client: new cycle() method Signed-off-by: Julien Danjou --- lib/awful/client.lua.in | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/awful/client.lua.in b/lib/awful/client.lua.in index 04979375..48fd6b6e 100644 --- a/lib/awful/client.lua.in +++ b/lib/awful/client.lua.in @@ -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.