On Wed, Aug 20, 2003 at 09:35:08PM +0300, Tuomo Valkonen wrote:
> That should do it, but I haven't tried it.

OK, here's the final version. I've posted it here because (a) it might be
useful to others and (b) it reveals what might be a bug. Here's the code:

function ionws_move_current(frame, dir)
    local ws = frame
    while ws and not obj_is(ws, "WIonWS") do
        ws = ws:manager()
    end
    if not ws then return end
    local c = frame:current()
    local other = nil
    if dir == "left" then
        other = ws:left_of(frame) or ws:rightmost()
    elseif dir == "right" then
        other = ws:right_of(frame) or ws:leftmost()
    elseif dir == "up" then
        other = ws:above(frame) or ws:lowest()
    elseif dir == "down" then
        other = ws:below(frame) or ws:topmost()
    else
        return
    end
    if c and obj_is(other, "WMPlex") then
        other:attach(c, { switchto = true })
    end
    if other then
        other:goto()
    end
end

ionframe_bindings{
    kpress(DEFAULT_MOD.."Control+H", function(frame) ionws_move_current(frame, "left") 
end),
    kpress(DEFAULT_MOD.."Control+J", function(frame) ionws_move_current(frame, "down") 
end),
    kpress(DEFAULT_MOD.."Control+K", function(frame) ionws_move_current(frame, "up") 
end),
    kpress(DEFAULT_MOD.."Control+L", function(frame) ionws_move_current(frame, 
"right") end),
}

Now, the bug.

1. New workspace.
2. Split workspace horizontally:
        +---+---+
        |   |   |
        | a | b |
        |   |   |
        +---+---+
3. Split frame a vertically:
        +---+---+
        | a |   |
        +---+ b |
        | c |   |
        +---+---+
4. Split frame b vertically:
        +---+---+
        | a | b |
        +---+---+
        | c | d |
        +---+---+
5. Now create a client window in frame c, and focus it.
6. Observe:
a) WIonWS.goto_right switches to frame d
b) above code using "right" (which calls right_of) gos to frame b (should be
frame d).

Maybe right_of doesn't use the same algorithm as move_right? 

Cheers,

Tom

P.S. When I split frames I use split_empty, in case that's relevant.

Reply via email to