1 ###########################################################################
2 ### Functions for helping out with your window focus. ###
3 ###########################################################################
8 # maintain a list of clients, stacked in focus order
10 # maintaint he current focused window
15 if not len(ob_clients): ob_clients.append(data.client.window())
16 else: ob_clients.insert(1, data.client.window()) # insert in 2nd slot
18 def ob_close_win(data):
20 ob_clients.remove(data.client.window())
25 win = data.client.window()
28 ob_clients.remove(win)
29 ob_clients.insert(0, win)
30 elif ob_focus_fallback:
33 desktop = openbox.screen(data.screen).desktop()
35 client = openbox.findClient(w)
36 if client and (client.desktop() == desktop and \
37 client.normal() and client.focus()):
40 ebind(EventNewWindow, ob_new_win)
41 ebind(EventCloseWindow, ob_close_win)
42 ebind(EventFocus, ob_focused)
44 def focus_next(data, num=1, forward=1):
45 """Focus the next (or previous, with forward=0) window in a linear
47 screen = openbox.screen(data.screen)
48 count = screen.clientCount()
50 if not count: return # no clients
54 client_win = data.client.window()
63 elif screen.client(i).window() == client_win:
65 if not found: # wraparound
66 if forward: target = 0
67 else: target = count - 1
70 curdesk = screen.desktop()
72 client = screen.client(t)
73 if client.normal() and \
74 (client.desktop() == curdesk or client.desktop() == 0xffffffff)\
77 screen.raiseWindow(client)
81 if t >= count: t -= count
85 if t == target: return # nothing to focus
87 def focus_prev(data, num=1):
88 """Focus the previous window in a linear order."""
89 focus_next(data, num, forward=0)
92 print "Loaded focus.py"