]>
Dogcows Code - chaz/openbox/blob - scripts/callbacks.py
1 ############################################################################
2 ### Functions that can be used as callbacks for mouse/keyboard bindings ###
3 ############################################################################
9 """Iconifies the window on which the event occured"""
10 if not data
.client
: return
11 data
.client
.iconify(1)
14 """Un-iconifies the window on which the event occured, but does not focus
15 if. If you want to focus the window too, it is recommended that you
16 use the activate() function."""
17 if not data
.client
: return
18 data
.client
.iconify(0)
21 """Closes the window on which the event occured"""
22 if not data
.client
: return
26 """Focuses the window on which the event occured"""
27 if not data
.client
: return
28 # !normal windows dont get focus from window enter events
29 if data
.action
== ob
.EventAction
.EnterWindow
and not data
.client
.normal():
34 """Raises the window on which the event occured"""
35 if not data
.client
: return
36 data
.client
.raiseWindow()
39 """Lowers the window on which the event occured"""
40 if not data
.client
: return
41 data
.client
.lowerWindow()
43 def toggle_maximize(data
):
44 """Toggles the maximized status of the window on which the event occured"""
45 if not data
.client
: return
46 data
.client
.maximize(not (data
.client
.maxHorz() or data
.client
.maxVert()))
48 def toggle_maximize_horz(data
):
49 """Toggles the horizontal maximized status of the window on which the event
51 if not data
.client
: return
52 data
.client
.maximizeHorizontal(not data
.client
.maxHorz())
54 def toggle_maximize_vert(data
):
55 """Toggles the vertical maximized status of the window on which the event
57 if not data
.client
: return
58 data
.client
.maximizeVertical(not data
.client
.maxVert())
61 """Maximizes the window on which the event occured"""
62 if not data
.client
: return
63 data
.client
.maximize(1)
65 def maximize_horz(data
):
66 """Horizontally maximizes the window on which the event occured"""
67 if not data
.client
: return
68 data
.client
.maximizeHorizontal(1)
70 def maximize_vert(data
):
71 """Vertically maximizes the window on which the event occured"""
72 if not data
.client
: return
73 data
.client
.maximizeVertical(1)
76 """Unmaximizes the window on which the event occured"""
77 if not data
.client
: return
78 data
.client
.maximize(0)
80 def unmaximize_horz(data
):
81 """Horizontally unmaximizes the window on which the event occured"""
82 if not data
.client
: return
83 data
.client
.maximizeHorizontal(0)
85 def unmaximize_vert(data
):
86 """Vertically unmaximizes the window on which the event occured"""
87 if not data
.client
: return
88 data
.client
.maximizeVertical(0)
90 def toggle_shade(data
):
91 """Toggles the shade status of the window on which the event occured"""
92 if not data
.client
: return
93 data
.client
.shade(not data
.client
.shaded())
96 """Shades the window on which the event occured"""
97 if not data
.client
: return
101 """Unshades the window on which the event occured"""
102 if not data
.client
: return
105 def change_desktop(data
, num
):
106 """Switches to a specified desktop"""
107 ob
.openbox
.screen(data
.screen
).changeDesktop(num
)
109 def show_desktop(data
, show
=1):
110 """Shows and focuses the desktop, hiding any client windows. Optionally,
111 if show is zero, this will hide the desktop, leaving show-desktop
113 ob
.openbox
.screen(data
.screen
).showDesktop(show
)
115 def hide_desktop(data
):
116 """Hides the desktop, re-showing the client windows. Leaves show-desktop
118 show_desktop(data
, 0)
120 def toggle_show_desktop(data
):
121 """Requests the Openbox to show the desktop, hiding the client windows, or
122 redisplay the clients."""
123 screen
= ob
.openbox
.screen(data
.screen
)
124 screen
.showDesktop(not screen
.showingDesktop())
126 def next_desktop(data
, no_wrap
=0):
127 """Switches to the next desktop, optionally (by default) cycling around to
128 the first when going past the last."""
129 screen
= ob
.openbox
.screen(data
.screen
)
131 n
= screen
.numDesktops()
136 change_desktop(data
, d
)
138 def prev_desktop(data
, no_wrap
=0):
139 """Switches to the previous desktop, optionally (by default) cycling around
140 to the last when going past the first."""
141 screen
= ob
.openbox
.screen(data
.screen
)
143 n
= screen
.numDesktops()
148 change_desktop(data
, d
)
150 def up_desktop(data
, num
=1):
151 """Switches to the desktop vertically above the current one. This is based
152 on the desktop layout chosen by an EWMH compliant pager. Optionally, num
153 can be specified to move more than one row at a time."""
154 screen
= ob
.openbox
.screen(data
.screen
)
156 n
= screen
.numDesktops()
157 l
= screen
.desktopLayout()
159 target
= d
- num
* l
.columns
161 target
+= l
.rows
* l
.columns
164 change_desktop(data
, target
)
166 def down_desktop(data
, num
=1):
167 """Switches to the desktop vertically below the current one. This is based
168 on the desktop layout chosen by an EWMH compliant pager. Optionally, num
169 can be specified to move more than one row at a time."""
170 screen
= ob
.openbox
.screen(data
.screen
)
172 n
= screen
.numDesktops()
173 l
= screen
.desktopLayout()
175 target
= d
+ num
* l
.columns
177 target
-= l
.rows
* l
.columns
180 change_desktop(data
, target
)
182 def left_desktop(data
, num
=1):
183 """Switches to the desktop horizotally left of the current one. This is
184 based on the desktop layout chosen by an EWMH compliant pager.
185 Optionally, num can be specified to move more than one column at a
187 screen
= ob
.openbox
.screen(data
.screen
)
189 n
= screen
.numDesktops()
190 l
= screen
.desktopLayout()
192 rowstart
= d
- d
% l
.columns
194 while target
< rowstart
:
196 change_desktop(data
, target
)
198 def right_desktop(data
, num
=1):
199 """Switches to the desktop horizotally right of the current one. This is
200 based on the desktop layout chosen by an EWMH compliant pager.
201 Optionally, num can be specified to move more than one column at a
203 screen
= ob
.openbox
.screen(data
.screen
)
205 n
= screen
.numDesktops()
206 l
= screen
.desktopLayout()
208 rowstart
= d
- d
% l
.columns
210 while target
>= rowstart
+ l
.columns
:
212 change_desktop(data
, target
)
214 def send_to_desktop(data
, num
):
215 """Sends a client to a specified desktop"""
216 if not data
.client
: return
217 data
.client
.setDesktop(num
)
219 def toggle_all_desktops(data
):
220 """Toggles between sending a client to all desktops and to the current
222 if not data
.client
: return
223 if not data
.client
.desktop() == 0xffffffff:
224 send_to_desktop(data
, 0xffffffff)
226 send_to_desktop(data
, ob
.openbox
.screen(data
.screen
).desktop())
228 def send_to_all_desktops(data
):
229 """Sends a client to all desktops"""
230 if not data
.client
: return
231 send_to_desktop(data
, 0xffffffff)
233 def send_to_next_desktop(data
, no_wrap
=0, follow
=1):
234 """Sends a window to the next desktop, optionally (by default) cycling
235 around to the first when going past the last. Also optionally moving to
236 the new desktop after sending the window."""
237 if not data
.client
: return
238 screen
= ob
.openbox
.screen(data
.screen
)
240 n
= screen
.numDesktops()
245 send_to_desktop(data
, d
)
247 change_desktop(data
, d
)
249 def send_to_prev_desktop(data
, no_wrap
=0, follow
=1):
250 """Sends a window to the previous desktop, optionally (by default) cycling
251 around to the last when going past the first. Also optionally moving to
252 the new desktop after sending the window."""
253 if not data
.client
: return
254 screen
= ob
.openbox
.screen(data
.screen
)
256 n
= screen
.numDesktops()
261 send_to_desktop(data
, d
)
263 change_desktop(data
, d
)
265 def restart(data
=0, other
= ""):
266 """Restarts Openbox, optionally starting another window manager."""
267 ob
.openbox
.restart(other
)
271 ob
.openbox
.shutdown()
273 export_functions
= iconify
, restore
, close
, focus
, raise_win
, lower_win
, \
274 toggle_maximize
, toggle_maximize_horz
, \
275 toggle_maximize_vert
, maximize
, maximize_horz
, \
276 maximize_vert
, unmaximize
, unmaximize_horz
, \
277 unmaximize_vert
, toggle_shade
, shade
, unshade
, \
278 change_desktop
, show_desktop
, hide_desktop
, \
279 toggle_show_desktop
, next_desktop
, prev_desktop
, \
280 up_desktop
, down_desktop
, left_desktop
, right_desktop
, \
281 send_to_desktop
, toggle_all_desktops
, send_to_all_desktops
,\
282 send_to_next_desktop
, send_to_prev_desktop
, restart
, exit
284 print "Loaded callbacks.py"
This page took 0.045706 seconds and 4 git commands to generate.