1 ############################################################################
2 ### Functions that can be used as callbacks for mouse/keyboard bindings ###
3 ############################################################################
12 def state_above(data
, add
=StateAdd
):
13 """Toggles, adds or removes the 'above' state on a window.
14 The second paramater should one of: StateRemove, StateAdd, or
16 if not data
.client
: return
17 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
18 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
19 add
, otk
.Property_atoms().net_wm_state_above
)
21 def state_below(data
, add
=StateAdd
):
22 """Toggles, adds or removes the 'below' state on a window.
23 The second paramater should one of: StateRemove, StateAdd, or
25 if not data
.client
: return
26 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
27 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
28 add
, otk
.Property_atoms().net_wm_state_below
)
30 def state_shaded(data
, add
=StateAdd
):
31 """Toggles, adds or removes the 'shaded' state on a window.
32 The second paramater should one of: StateRemove, StateAdd, or
34 if not data
.client
: return
35 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
36 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
37 add
, otk
.Property_atoms().net_wm_state_shaded
)
39 def state_maximize(data
, add
=StateAdd
):
40 """Toggles, adds or removes the horizontal and vertical 'maximized' state
41 on a window. The second paramater should one of: StateRemove, StateAdd,
43 if not data
.client
: return
44 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
45 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
46 add
, otk
.Property_atoms().net_wm_state_maximized_horz
,
47 otk
.Property_atoms().net_wm_state_maximized_vert
)
49 def state_maximize_horz(data
, add
=StateAdd
):
50 """Toggles, adds or removes the horizontal 'maximized' state on a window.
51 The second paramater should one of: StateRemove, StateAdd, or
53 if not data
.client
: return
54 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
55 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
56 add
, otk
.Property_atoms().net_wm_state_maximized_horz
)
58 def state_maximize_vert(data
, add
=StateAdd
):
59 """Toggles, adds or removes the vertical 'maximized' state on a window.
60 The second paramater should one of: StateRemove, StateAdd, or
62 if not data
.client
: return
63 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
64 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
65 add
, otk
.Property_atoms().net_wm_state_maximized_vert
)
67 def state_skip_taskbar(data
, add
=StateAdd
):
68 """Toggles, adds or removes the 'skip_taskbar' state on a window.
69 The second paramater should one of: StateRemove, StateAdd, or
71 if not data
.client
: return
72 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
73 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
74 add
, otk
.Property_atoms().net_wm_state_skip_taskbar
)
76 def state_skip_pager(data
, add
=StateAdd
):
77 """Toggles, adds or removes the 'skip_pager' state on a window.
78 The second paramater should one of: StateRemove, StateAdd, or
80 if not data
.client
: return
81 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
82 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
83 add
, otk
.Property_atoms().net_wm_state_skip_pager
)
86 """Iconifies the window on which the event occured"""
87 if not data
.client
: return
88 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
89 otk
.Property_atoms().wm_change_state
,
90 data
.client
.window(), 3) # IconicState
93 """Un-iconifies the window on which the event occured, but does not focus
94 if. If you want to focus the window too, it is recommended that you
95 use the activate() function."""
96 if not data
.client
: return
97 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
98 otk
.Property_atoms().wm_change_state
,
99 data
.client
.window(), 1) # NormalState
102 """Closes the window on which the event occured"""
103 if not data
.client
: return
104 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
105 otk
.Property_atoms().net_close_window
,
106 data
.client
.window(), 0)
109 """Focuses the window on which the event occured"""
110 if not data
.client
: return
111 # !normal windows dont get focus from window enter events
112 if data
.action
== ob
.EventAction
.EnterWindow
and not data
.client
.normal():
116 def restart(data
, other
= ""):
117 """Restarts openbox, optionally starting another window manager."""
118 ob
.openbox
.restart(other
)
121 """Raises the window on which the event occured"""
122 if not data
.client
: return
123 ob
.openbox
.screen(data
.screen
).raiseWindow(data
.client
)
126 """Lowers the window on which the event occured"""
127 if not data
.client
: return
128 ob
.openbox
.screen(data
.screen
).lowerWindow(data
.client
)
130 def toggle_maximize(data
):
131 """Toggles the maximized status of the window on which the event occured"""
132 state_maximize(data
, StateToggle
)
134 def toggle_maximize_horz(data
):
135 """Toggles the horizontal maximized status of the window on which the event
137 state_maximize_horz(data
, StateToggle
)
139 def toggle_maximize_vert(data
):
140 """Toggles the vertical maximized status of the window on which the event
142 state_maximize_vert(data
, StateToggle
)
145 """Maximizes the window on which the event occured"""
146 state_maximize(data
, StateAdd
)
148 def maximize_horz(data
):
149 """Horizontally maximizes the window on which the event occured"""
150 state_maximize_horz(data
, StateAdd
)
152 def maximize_vert(data
):
153 """Vertically maximizes the window on which the event occured"""
154 state_maximize_vert(data
, StateAdd
)
156 def unmaximize(data
):
157 """Unmaximizes the window on which the event occured"""
158 state_maximize(data
, StateRemove
)
160 def unmaximize_horz(data
):
161 """Horizontally unmaximizes the window on which the event occured"""
162 state_maximize_horz(data
, StateRemove
)
164 def unmaximize_vert(data
):
165 """Vertically unmaximizes the window on which the event occured"""
166 state_maximize_vert(data
, StateRemove
)
168 def toggle_shade(data
):
169 """Toggles the shade status of the window on which the event occured"""
170 state_shaded(data
, StateToggle
)
173 """Shades the window on which the event occured"""
174 state_shaded(data
, StateAdd
)
177 """Unshades the window on which the event occured"""
178 state_shaded(data
, StateRemove
)
180 def change_desktop(data
, num
):
181 """Switches to a specified desktop"""
182 root
= otk
.display
.screenInfo(data
.screen
).rootWindow()
183 ob
.send_client_msg(root
, otk
.Property_atoms().net_current_desktop
,
186 def next_desktop(data
, no_wrap
=0):
187 """Switches to the next desktop, optionally (by default) cycling around to
188 the first when going past the last."""
189 screen
= ob
.openbox
.screen(data
.screen
)
191 n
= screen
.numDesktops()
196 change_desktop(data
, d
)
198 def prev_desktop(data
, no_wrap
=0):
199 """Switches to the previous desktop, optionally (by default) cycling around
200 to the last when going past the first."""
201 screen
= ob
.openbox
.screen(data
.screen
)
203 n
= screen
.numDesktops()
208 change_desktop(data
, d
)
210 def send_to_desktop(data
, num
):
211 """Sends a client to a specified desktop"""
212 if not data
.client
: return
213 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
214 otk
.Property_atoms().net_wm_desktop
,
215 data
.client
.window(),num
)
217 def toggle_all_desktops(data
):
218 """Toggles between sending a client to all desktops and to the current
220 if not data
.client
: return
221 if not data
.client
.desktop() == 0xffffffff:
222 send_to_desktop(data
, 0xffffffff)
224 send_to_desktop(data
, ob
.openbox
.screen(data
.screen
).desktop())
226 def send_to_all_desktops(data
):
227 """Sends a client to all desktops"""
228 if not data
.client
: return
229 send_to_desktop(data
, 0xffffffff)
231 def send_to_next_desktop(data
, no_wrap
=0, follow
=1):
232 """Sends a window to the next desktop, optionally (by default) cycling
233 around to the first when going past the last. Also optionally moving to
234 the new desktop after sending the window."""
235 if not data
.client
: return
236 screen
= ob
.openbox
.screen(data
.screen
)
238 n
= screen
.numDesktops()
243 send_to_desktop(data
, d
)
245 change_desktop(data
, d
)
247 def send_to_prev_desktop(data
, no_wrap
=0, follow
=1):
248 """Sends a window to the previous desktop, optionally (by default) cycling
249 around to the last when going past the first. Also optionally moving to
250 the new desktop after sending the window."""
251 if not data
.client
: return
252 screen
= ob
.openbox
.screen(data
.screen
)
254 n
= screen
.numDesktops()
259 send_to_desktop(data
, d
)
261 change_desktop(data
, d
)
263 print "Loaded callbacks.py"