]>
Dogcows Code - chaz/openbox/blob - scripts/focus.py
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
12 ob_hold_client_list
= 0
16 if not len(ob_clients
): ob_clients
.append(data
.client
.window())
17 else: ob_clients
.insert(1, data
.client
.window()) # insert in 2nd slot
19 def ob_close_win(data
):
21 ob_clients
.remove(data
.client
.window())
26 if not ob_hold_client_list
:
27 win
= data
.client
.window()
30 ob_clients
.remove(win
)
31 ob_clients
.insert(0, win
)
32 elif ob_focus_fallback
:
33 ob_old_client_list
= 0 # something is wrong.. stop holding
36 desktop
= openbox
.screen(data
.screen
).desktop()
38 client
= openbox
.findClient(w
)
39 if client
and (client
.desktop() == desktop
and \
40 client
.normal() and client
.focus()):
43 ebind(EventNewWindow
, ob_new_win
)
44 ebind(EventCloseWindow
, ob_close_win
)
45 ebind(EventFocus
, ob_focused
)
50 def focus_next_stacked_grab(data
):
54 if data
.action
== EventKeyRelease
:
55 print "release: " + str(ob_cyc_mask
) + "..." + str(data
.state
)
56 # have all the modifiers this started with been released?
57 if not ob_cyc_mask
& data
.state
:
58 kungrab() # ungrab ourself
61 print "press: " + str(ob_cyc_mask
) + "..." + str(data
.state
) + \
63 if ob_cyc_key
== data
.key
:
66 def focus_next_stacked(data
, forward
=1):
69 ob_cyc_mask
= data
.state
72 kgrab(focus_next_stacked_grab
)
74 focus_next_stacked_grab(data
) # start with the first press
76 def focus_prev_stacked(data
):
79 def focus_next(data
, num
=1, forward
=1):
80 """Focus the next (or previous, with forward=0) window in a linear
82 screen
= openbox
.screen(data
.screen
)
83 count
= screen
.clientCount()
85 if not count
: return # no clients
89 client_win
= data
.client
.window()
99 elif screen
.client(i
).window() == client_win
:
101 if found
== 1: # wraparound
102 if forward
: target
= 0
103 else: target
= count
- 1
106 curdesk
= screen
.desktop()
108 client
= screen
.client(t
)
109 if client
.normal() and \
110 (client
.desktop() == curdesk
or client
.desktop() == 0xffffffff)\
113 screen
.raiseWindow(client
)
117 if t
>= count
: t
-= count
121 if t
== target
: return # nothing to focus
123 def focus_prev(data
, num
=1):
124 """Focus the previous window in a linear order."""
125 focus_next(data
, num
, forward
=0)
128 print "Loaded focus.py"
This page took 0.041656 seconds and 4 git commands to generate.