]>
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 type = OBClient_type(client
)
29 # these types of windows dont get moved
30 if type == OBClient_Type_Dock
or \
31 type == OBClient_Type_Desktop
:
34 dx
= data
.xroot() - data
.pressx()
35 dy
= data
.yroot() - data
.pressy()
36 OBClient_move(client
, data
.press_clientx() + dx
, data
.press_clienty() + dy
)
39 """Resizes the window interactively. This should only be used with
41 client
= Openbox_findClient(openbox
, data
.window())
44 type = OBClient_type(client
)
45 # these types of windows dont get resized
46 if type == OBClient_Type_Dock
or \
47 type == OBClient_Type_Desktop
:
52 dx
= data
.xroot() - px
53 dy
= data
.yroot() - py
55 # pick a corner to anchor
56 if not (resize_nearest
or data
.context() == MC_Grip
):
57 corner
= OBClient_TopLeft
59 x
= px
- data
.press_clientx()
60 y
= py
- data
.press_clienty()
61 if y
< data
.press_clientheight() / 2:
62 if x
< data
.press_clientwidth() / 2:
63 corner
= OBClient_BottomRight
66 corner
= OBClient_BottomLeft
69 if x
< data
.press_clientwidth() / 2:
70 corner
= OBClient_TopRight
73 corner
= OBClient_TopLeft
75 OBClient_resize(client
, corner
,
76 data
.press_clientwidth() + dx
,
77 data
.press_clientheight() + dy
);
80 Openbox_restart(openbox
, "")
82 def toggle_shade(data
):
86 client
= Openbox_findClient(openbox
, data
.window())
88 screen
= Openbox_screen(openbox
, OBClient_screen(client
))
89 OBScreen_restack(screen
, 1, client
)
92 client
= Openbox_findClient(openbox
, data
.window())
94 screen
= Openbox_screen(openbox
, OBClient_screen(client
))
95 OBScreen_restack(screen
, 0, client
)
97 def toggle_shade(data
):
98 client
= Openbox_findClient(openbox
, data
.window())
101 OBClient_shade(client
, not OBClient_shaded(client
))
104 client
= Openbox_findClient(openbox
, data
.window())
105 if not client
: return
106 OBClient_shade(client
, 1)
109 client
= Openbox_findClient(openbox
, data
.window())
110 if not client
: return
111 OBClient_shade(client
, 0)
113 #########################################
114 ### Convenience functions for scripts ###
115 #########################################
117 def execute(bin
, screen
= 0):
118 Openbox_execute(openbox
, screen
, bin
)
120 print "Loaded builtins.py"
This page took 0.04221 seconds and 5 git commands to generate.