1 ###########################################################################
2 ### Functions for cycling focus (in a 'linear' order) between windows. ###
3 ###########################################################################
5 ###########################################################################
6 ### Options that affect the behavior of the focuscycle module. ###
7 ###########################################################################
9 """When cycling focus, raise the window chosen as well as focusing it. This
10 does not affect fallback focusing behavior."""
11 # See focus.AVOID_SKIP_TASKBAR
12 ###########################################################################
14 def next(data, num=1):
15 """Focus the next window."""
18 def previous(data, num=1):
19 """Focus the previous window."""
22 ###########################################################################
23 ###########################################################################
25 ###########################################################################
26 ### Internal stuff, should not be accessed outside the module. ###
27 ###########################################################################
32 def _cycle(data, num, forward):
33 screen = ob.openbox.screen(data.screen)
34 count = screen.clientCount()
36 if not count: return # no clients
40 client_win = data.client.window()
50 elif screen.client(i).window() == client_win:
52 if found == 1: # wraparound
53 if forward: target = 0
54 else: target = count - 1
57 desktop = screen.desktop()
59 client = screen.client(t)
60 if client and focus._focusable(client, desktop) and client.focus():
62 screen.raiseWindow(client)
66 if t >= count: t -= count
70 if t == target: return # nothing to focus
72 print "Loaded focuscycle.py"