File: goto_multihead.lua

package info (click to toggle)
ion3-scripts 20050418-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 300 kB
  • ctags: 153
  • sloc: makefile: 18
file content (30 lines) | stat: -rw-r--r-- 715 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- A version of WIonWS.goto_dir that may be useful on multihead setups

function goto_multihead(ws, dir)
    if dir=="up" or dir=="down" then
        ws:goto_dir(dir)
        return
    end
    
    local nxt, nxtscr
    
    nxt=ws:next_to(ws:current(), dir)
    
    if not nxt then
        local otherdir
        local fid=find_screen_id
        if dir=="right" then
            otherdir="left"
            nxtscr=fid(ws:screen_of():id()+1) or fid(0)
        else
            otherdir="right"
            nxtscr=fid(ws:screen_of():id()-1) or fid(-1)
        end
        nxt=nxtscr:current()
        if obj_is(nxt, "WIonWS") then
            nxt=nxt:farthest(otherdir)
        end
    end
    
    nxt:goto()
end