]>
Dogcows Code - chaz/openbox/blob - focus.py
c0d60b1ee7bb06308f05cd65d5ea268e3738a42a
1 ###########################################################################
2 ### Functions for helping out with your window focus. ###
3 ###########################################################################
11 global ob_focus_fallback
14 window
= data
.client
.window()
15 # add/move to front the stack
16 if window
in ob_focus_stack
:
17 ob_focus_stack
.remove(window
)
18 ob_focus_stack
.insert(0, window
)
19 elif ob_focus_fallback
:
21 desktop
= openbox
.screen(data
.screen
).desktop()
22 l
= len(ob_focus_stack
)
26 client
= openbox
.findClient(w
)
27 if not client
: # window is gone, remove it
30 elif client
.desktop() == desktop
and \
31 client
.normal() and client
.focus():
36 ebind(EventFocus
, ob_focused
)
38 def focus_next(data
, num
=1, forward
=1):
39 """Focus the next (or previous, with forward=0) window in a linear
41 screen
= openbox
.screen(data
.screen
)
42 count
= screen
.clientCount()
44 if not count
: return # no clients
48 client_win
= data
.client
.window()
57 elif screen
.client(i
).window() == client_win
:
59 if not found
: # wraparound
60 if forward
: target
= 0
61 else: target
= count
- 1
64 curdesk
= screen
.desktop()
66 client
= screen
.client(t
)
67 if client
.normal() and \
68 (client
.desktop() == curdesk
or client
.desktop() == 0xffffffff)\
71 screen
.raiseWindow(client
)
75 if t
>= count
: t
-= count
79 if t
== target
: return # nothing to focus
81 def focus_prev(data
, num
=1):
82 """Focus the previous window in a linear order."""
83 focus_next(data
, num
, forward
=0)
86 print "Loaded focus.py"
This page took 0.035747 seconds and 3 git commands to generate.