]>
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 # !normal windows dont get focus from window enter events
16 if data
.action() == EventEnterWindow
and not OBClient_normal(client
):
18 OBClient_focus(client
)
21 """Moves the window interactively. This should only be used with
23 client
= Openbox_findClient(openbox
, data
.window())
26 # !normal windows dont get moved
27 if not OBClient_normal(client
): return
29 dx
= data
.xroot() - data
.pressx()
30 dy
= data
.yroot() - data
.pressy()
31 OBClient_move(client
, data
.press_clientx() + dx
, data
.press_clienty() + dy
)
34 """Resizes the window interactively. This should only be used with
36 client
= Openbox_findClient(openbox
, data
.window())
39 # !normal windows dont get moved
40 if not OBClient_normal(client
): return
44 dx
= data
.xroot() - px
45 dy
= data
.yroot() - py
47 # pick a corner to anchor
48 if not (resize_nearest
or data
.context() == MC_Grip
):
49 corner
= OBClient_TopLeft
51 x
= px
- data
.press_clientx()
52 y
= py
- data
.press_clienty()
53 if y
< data
.press_clientheight() / 2:
54 if x
< data
.press_clientwidth() / 2:
55 corner
= OBClient_BottomRight
58 corner
= OBClient_BottomLeft
61 if x
< data
.press_clientwidth() / 2:
62 corner
= OBClient_TopRight
65 corner
= OBClient_TopLeft
67 OBClient_resize(client
, corner
,
68 data
.press_clientwidth() + dx
,
69 data
.press_clientheight() + dy
);
72 Openbox_restart(openbox
, "")
74 def toggle_shade(data
):
78 client
= Openbox_findClient(openbox
, data
.window())
80 screen
= Openbox_screen(openbox
, OBClient_screen(client
))
81 OBScreen_restack(screen
, 1, client
)
84 client
= Openbox_findClient(openbox
, data
.window())
86 screen
= Openbox_screen(openbox
, OBClient_screen(client
))
87 OBScreen_restack(screen
, 0, client
)
89 def toggle_shade(data
):
90 client
= Openbox_findClient(openbox
, data
.window())
93 OBClient_shade(client
, not OBClient_shaded(client
))
96 client
= Openbox_findClient(openbox
, data
.window())
98 OBClient_shade(client
, 1)
101 client
= Openbox_findClient(openbox
, data
.window())
102 if not client
: return
103 OBClient_shade(client
, 0)
105 #########################################
106 ### Convenience functions for scripts ###
107 #########################################
109 def execute(bin
, screen
= 0):
110 Openbox_execute(openbox
, screen
, bin
)
112 print "Loaded builtins.py"
This page took 0.035535 seconds and 4 git commands to generate.