]>
Dogcows Code - chaz/openbox/blob - scripts/callbacks.py
4d5092680d3cc2baa98395f7ecc5d483c014c6fc
1 ############################################################################
2 ### Functions that can be used as callbacks for mouse/keyboard bindings ###
3 ############################################################################
5 #############################################################################
6 ### Options that can be modified to change the default hooks' behaviors. ###
8 #############################################################################
13 def state_above(data
, add
=2):
14 """Toggles, adds or removes the 'above' state on a window."""
15 if not data
.client
: return
16 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
17 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
18 add
, otk
.Property_atoms().net_wm_state_above
)
20 def state_below(data
, add
=2):
21 """Toggles, adds or removes the 'below' state on a window."""
22 if not data
.client
: return
23 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
24 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
25 add
, otk
.Property_atoms().net_wm_state_below
)
27 def state_shaded(data
, add
=2):
28 """Toggles, adds or removes the 'shaded' state on a window."""
29 if not data
.client
: return
30 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
31 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
32 add
, otk
.Property_atoms().net_wm_state_shaded
)
35 """Iconifies the window on which the event occured"""
36 if not data
.client
: return
37 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
38 otk
.Property_atoms().wm_change_state
,
39 data
.client
.window(), 3) # IconicState
42 """Un-iconifies the window on which the event occured, but does not focus
43 if. If you want to focus the window too, it is recommended that you
44 use the activate() function."""
45 if not data
.client
: return
46 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
47 otk
.Property_atoms().wm_change_state
,
48 data
.client
.window(), 1) # NormalState
51 """Closes the window on which the event occured"""
52 if not data
.client
: return
53 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
54 otk
.Property_atoms().net_close_window
,
55 data
.client
.window(), 0)
58 """Focuses the window on which the event occured"""
59 if not data
.client
: return
60 # !normal windows dont get focus from window enter events
61 if data
.action
== ob
.EventAction
.EnterWindow
and not data
.client
.normal():
65 def restart(data
, other
= ""):
66 """Restarts openbox, optionally starting another window manager."""
67 ob
.openbox
.restart(other
)
70 """Raises the window on which the event occured"""
71 if not data
.client
: return
72 ob
.openbox
.screen(data
.screen
).raiseWindow(data
.client
)
75 """Lowers the window on which the event occured"""
76 if not data
.client
: return
77 ob
.openbox
.screen(data
.screen
).lowerWindow(data
.client
)
79 def toggle_shade(data
):
80 """Toggles the shade status of the window on which the event occured"""
84 """Shades the window on which the event occured"""
88 """Unshades the window on which the event occured"""
91 def change_desktop(data
, num
):
92 """Switches to a specified desktop"""
93 root
= otk
.display
.screenInfo(data
.screen
).rootWindow()
94 ob
.send_client_msg(root
, otk
.Property_atoms().net_current_desktop
,
97 def next_desktop(data
, no_wrap
=0):
98 """Switches to the next desktop, optionally (by default) cycling around to
99 the first when going past the last."""
100 screen
= ob
.openbox
.screen(data
.screen
)
102 n
= screen
.numDesktops()
107 change_desktop(data
, d
)
109 def prev_desktop(data
, no_wrap
=0):
110 """Switches to the previous desktop, optionally (by default) cycling around
111 to the last when going past the first."""
112 screen
= ob
.openbox
.screen(data
.screen
)
114 n
= screen
.numDesktops()
119 change_desktop(data
, d
)
121 def send_to_desktop(data
, num
):
122 """Sends a client to a specified desktop"""
123 if not data
.client
: return
124 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
125 otk
.Property_atoms().net_wm_desktop
,
126 data
.client
.window(),num
)
128 def toggle_all_desktops(data
):
129 """Toggles between sending a client to all desktops and to the current
131 if not data
.client
: return
132 if not data
.client
.desktop() == 0xffffffff:
133 send_to_desktop(data
, 0xffffffff)
135 send_to_desktop(data
, openbox
.screen(data
.screen
).desktop())
137 def send_to_all_desktops(data
):
138 """Sends a client to all desktops"""
139 if not data
.client
: return
140 send_to_desktop(data
, 0xffffffff)
142 def send_to_next_desktop(data
, no_wrap
=0, follow
=1):
143 """Sends a window to the next desktop, optionally (by default) cycling
144 around to the first when going past the last. Also optionally moving to
145 the new desktop after sending the window."""
146 if not data
.client
: return
147 screen
= ob
.openbox
.screen(data
.screen
)
149 n
= screen
.numDesktops()
154 send_to_desktop(data
, d
)
156 change_desktop(data
, d
)
158 def send_to_prev_desktop(data
, no_wrap
=0, follow
=1):
159 """Sends a window to the previous desktop, optionally (by default) cycling
160 around to the last when going past the first. Also optionally moving to
161 the new desktop after sending the window."""
162 if not data
.client
: return
163 screen
= ob
.openbox
.screen(data
.screen
)
165 n
= screen
.numDesktops()
170 send_to_desktop(data
, d
)
172 change_desktop(data
, d
)
174 print "Loaded callbacks.py"
This page took 0.047605 seconds and 3 git commands to generate.