For your perusal and enjoyment, now that I've gotten it working again, here
is my windowcycle.lua module.  Basically it defines two functions, one of
which allows you to cycle through the visible clients in the current
workspace, and the other allows you to cycle through all clients in the
current workspace.  Both allow you to excempt certain clients from the
cycle using winprops.  I use this for xclocks, korgac and kwalletmanager.

I don't know if the code is actually correct, but it works for me.  In
particular, the code to find the current client seems awfully fragile, but
I have no idea how to do this better.
-- 
David Roundy
Department of Physics
Oregon State University
-- windowcycle.lua -- by David Roundy
--
-- Example usage:
--
-- dopath("windowcycle")
-- 
-- defbindings("WFrame", {
--   kpress(MOD1.."Tab", "windowcycle.cycle(_)"),
--   kpress("Control+Tab", "windowcycle.visible_cycle(_)");
-- })
-- 
-- defwinprop{ -- an example of how to make the cycle skip certain windows:
--     name = "stupid",
--     windowcycle_skip = true
-- }

local windowcycle={}
_G["windowcycle"]=windowcycle

defwinprop{
    class = "XClock",
    windowcycle_skip = true
}

defwinprop{
    instance = "korgac",
    windowcycle_skip = true
}

defwinprop{
    class = "Kwalletmanager",
    windowcycle_skip = true
}

local function shouldnt_be_skipped(cwin)
    local p=ioncore.getwinprop(cwin)
    return not (p and p.windowcycle_skip)
end

local function isalsovisible(w)
  return shouldnt_be_skipped(w) and WRegion.is_mapped(w)
end

local generic_cycle

function generic_cycle(frame, isok)
   local allwins = ioncore.clientwin_list()
   local ws=ioncore.find_manager(frame, "WGroupWS")
   local current_window = WMPlex.current(WMPlex.current(frame, 1),1)

   foundit = 0
   for _, w in pairs(allwins) do
      if ioncore.find_manager(w, "WGroupWS") == ws and isok(w) then
         if foundit == 1 then
            w:goto()
            return
         end
         if w == current_window then
            foundit = 1
         end
      end
    end
    -- Okay, the current window must be last in the list
    for _, w in pairs(allwins) do
       if ioncore.find_manager(w, "WGroupWS") == ws and isok(w) then
          w:goto()
          return
       end
    end
end


function windowcycle.cycle(frame)
    generic_cycle(frame, shouldnt_be_skipped)
end

function windowcycle.visible_cycle(frame)
    generic_cycle(frame, isalsovisible)
end

Reply via email to