Etan Reisner <[EMAIL PROTECTED]> wrote:
> What do you mean it never attaches cleanly in the frame? What
> happens exactly?

The workspace that I was testing with has a layout like this.

WRootWin
    WGroupWS
        WTiling
            WFrame

I could get the client to attach in WGroupWS and WTiling but I
did not know how to find the WFrame object.

Now I have a working solution but to understand I think a little
more info is needed.

The theory I am trying out is based on three workspaces Split,
Fullscreen and Hidden.

Split is the normal workspace with two frames. Fullscreen is for
when the frame on Split is not enough like badly written
webpages. Hidden is for the windows that are not needed at the
moment like the media player.

Keybindings for sending clients to fullscreen and hidden.

defbindings("WMPlex",
    {
        submap(PREFIX,
            {
                submap("S",
                    {
                        kpress("F", "fh_toggle('Fullscreen', _chld)"),
                        kpress("H", "fh_toggle('Hidden', _chld)"),
                        kpress("S", "fh_toggle('Split', _chld)"),
                    }
                ),
            }
        ),
    }
)

Then I have two functions. "locations" is used for storing Frame
name when sending clients from Split to Fullscreen or Hidden this
is later used to return the client to the previous frame on
Split.

locations = {}

function fh_toggle(dest, cwin)
    local current_ws = ioncore.find_manager(cwin, "WGroupWS")
    local dest_ws = ioncore.lookup_region(dest)

    local fullscreen_ws = ioncore.lookup_region("Fullscreen")
    local hidden_ws = ioncore.lookup_region("Hidden")
    local split_ws = ioncore.lookup_region("Split")

    local xid = WClientWin.xid(cwin)

    if current_ws == split_ws then
        local current_frame = WRegion.name(ioncore.find_manager(cwin, "WFrame"))
        locations[xid] = current_frame
    end

    if dest_ws == split_ws then
        local dest_frame_name = locations[xid]
        local dest_frame = ioncore.lookup_region(dest_frame_name)

        WMPlex.attach(dest_frame, cwin)
        WRegion.goto(cwin)
    end

    if dest_ws == fullscreen_ws then
        send_to_ws(dest_ws, cwin, true)
    end

    if dest_ws == hidden_ws then
        send_to_ws(dest_ws, cwin, false)
    end
end

function send_to_ws(ws, cwin, goto)
    ioncore.region_i(
        function (frame) 
            if ws==ioncore.find_manager(frame, "WGroupWS") then
                ioncore.defer(
                    function ()
                        WMPlex.attach(frame, cwin)
                        if goto then
                            WRegion.goto(cwin)
                        end
                    end
                )
                return false
            else
                return true
            end
        end
        , "WFrame"
    )
end

So far the theory works quite nicely for me.

Reply via email to