]>
Dogcows Code - chaz/openbox/blob - scripts/builtins.py
1 ###########################################################################
2 ### Functions that can be used as callbacks for mouse/keyboard bindings ###
3 ###########################################################################
6 """Closes the window on which the event occured"""
7 client
= Openbox_findClient(openbox
, data
.window())
8 if client
: OBClient_close(client
)
11 """Focuses the window on which the event occured"""
12 client
= Openbox_findClient(openbox
, data
.window())
14 type = OBClient_type(client
)
15 # these types of windows dont get focus from window enter events
16 if data
.action() == EventEnterWindow
:
17 if (type == OBClient_Type_Dock
or \
18 type == OBClient_Type_Desktop
):
20 OBClient_focus(client
)
23 """Moves the window interactively. This should only be used with
25 client
= Openbox_findClient(openbox
, data
.window())
28 dx
= data
.xroot() - data
.pressx()
29 dy
= data
.yroot() - data
.pressy()
30 OBClient_move(client
, data
.press_clientx() + dx
, data
.press_clienty() + dy
)
33 """Resizes the window interactively. This should only be used with
35 client
= Openbox_findClient(openbox
, data
.window())
40 dx
= data
.xroot() - px
41 dy
= data
.yroot() - py
43 # pick a corner to anchor
44 if not (resize_nearest
or data
.context() == MC_Grip
):
45 corner
= OBClient_TopLeft
47 x
= px
- data
.press_clientx()
48 y
= py
- data
.press_clienty()
49 if y
< data
.press_clientheight() / 2:
50 if x
< data
.press_clientwidth() / 2:
51 corner
= OBClient_BottomRight
54 corner
= OBClient_BottomLeft
57 if x
< data
.press_clientwidth() / 2:
58 corner
= OBClient_TopRight
61 corner
= OBClient_TopLeft
63 OBClient_resize(client
, corner
,
64 data
.press_clientwidth() + dx
,
65 data
.press_clientheight() + dy
);
68 Openbox_restart(openbox
, "")
70 def toggle_shade(data
):
74 client
= Openbox_findClient(openbox
, data
.window())
76 screen
= Openbox_screen(openbox
, OBClient_screen(client
))
77 OBScreen_restack(screen
, 1, client
)
80 client
= Openbox_findClient(openbox
, data
.window())
82 screen
= Openbox_screen(openbox
, OBClient_screen(client
))
83 OBScreen_restack(screen
, 0, client
)
85 def toggle_shade(data
):
86 client
= Openbox_findClient(openbox
, data
.window())
89 OBClient_shade(client
, not OBClient_shaded(client
))
92 client
= Openbox_findClient(openbox
, data
.window())
94 OBClient_shade(client
, 1)
97 client
= Openbox_findClient(openbox
, data
.window())
99 OBClient_shade(client
, 0)
101 #########################################
102 ### Convenience functions for scripts ###
103 #########################################
105 def execute(bin
, screen
= 0):
106 Openbox_execute(openbox
, screen
, bin
)
108 print "Loaded builtins.py"
This page took 0.04623 seconds and 5 git commands to generate.