Hi all,

I've got a script that broke on upgrade to the version of ion3 that is
now in debian testing, which is rather a useful one.  Actually, a
couple of scripts broke, but I'll ask about one at a time, as the
answer to one question may give hints to the other.

My script allows binding that will either circulate focus on all
windows on a given workspace, or all visible windows, with exceptions
that shouldn't get focus like xclock (which need to be configured
separately).

I'll attach it, and if you've got an idea how to fix it, that would be
great.  I've been too busy to debug this, but it seriously impedes my
use of ion...
-- 
David Roundy
-- windowcycle.lua -- by David Roundy
--
-- Example usage:
--
-- dopath("windowcycle")
-- 
-- defbindings("WFrame-on-WIonWS", {
--   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",
    instance = "xclock",
    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, "WGenWS")
    if not obj_is(ws, "WIonWS") then
        warn("Expecting WIonWS")
        return
    end

    local current_window = WMPlex.lcurrent(frame, 1)
    
    foundit = 0
    for _, w in allwins do
      -- mod_query.warn(frame, "is it here? "..WRegion.name(w))
      if ioncore.find_manager(w, "WGenWS") == ws and isok(w) then
          -- mod_query.warn(frame, "is it here?")
          if foundit == 1 then
              -- mod_query.warn(frame, "bazbar")
              w:goto()
              return
          end
          if w == current_window then
              -- mod_query.warn(frame, "zing")
              foundit = 1
          end
      end
    end
    -- Okay, the current window must be last in the list
    for _, w in allwins do
      if ioncore.find_manager(w, "WGenWS") == 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