]>
Dogcows Code - chaz/openbox/blob - scripts/focus.py
79da5a211d0349919c6238771627448787ae89f9
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()
64 elif screen
.client(i
).window() == client_win
:
66 if found
== 1: # wraparound
67 if forward
: target
= 0
68 else: target
= count
- 1
71 curdesk
= screen
.desktop()
73 client
= screen
.client(t
)
74 if client
.normal() and \
75 (client
.desktop() == curdesk
or client
.desktop() == 0xffffffff)\
78 screen
.raiseWindow(client
)
82 if t
>= count
: t
-= count
86 if t
== target
: return # nothing to focus
88 def focus_prev(data
, num
=1):
89 """Focus the previous window in a linear order."""
90 focus_next(data
, num
, forward
=0)
93 print "Loaded focus.py"
This page took 0.03536 seconds and 4 git commands to generate.