]> Dogcows Code - chaz/openbox/blob - scripts/builtins.py
remove a print
[chaz/openbox] / scripts / builtins.py
1 ###########################################################################
2 ### Functions that can be used as callbacks for mouse/keyboard bindings ###
3 ###########################################################################
4
5 def close(data):
6 """Closes the window on which the event occured"""
7 client = Openbox_findClient(openbox, data.window())
8 if client: OBClient_close(client)
9
10 def focus(data):
11 """Focuses the window on which the event occured"""
12 client = Openbox_findClient(openbox, data.window())
13 if not client: return
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):
19 return
20 OBClient_focus(client)
21
22 def move(data):
23 """Moves the window interactively. This should only be used with
24 MouseMotion events"""
25 client = Openbox_findClient(openbox, data.window())
26 if not client: return
27
28 dx = data.xroot() - data.pressx()
29 dy = data.yroot() - data.pressy()
30 OBClient_move(client, data.press_clientx() + dx, data.press_clienty() + dy)
31
32 def resize(data):
33 """Resizes the window interactively. This should only be used with
34 MouseMotion events"""
35 client = Openbox_findClient(openbox, data.window())
36 if not client: return
37
38 px = data.pressx()
39 py = data.pressy()
40 dx = data.xroot() - px
41 dy = data.yroot() - py
42
43 # pick a corner to anchor
44 if not (resize_nearest or data.context() == MC_Grip):
45 corner = OBClient_TopLeft
46 else:
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
52 dx *= -1
53 else:
54 corner = OBClient_BottomLeft
55 dy *= -1
56 else:
57 if x < data.press_clientwidth() / 2:
58 corner = OBClient_TopRight
59 dx *= -1
60 else:
61 corner = OBClient_TopLeft
62
63 OBClient_resize(client, corner,
64 data.press_clientwidth() + dx,
65 data.press_clientheight() + dy);
66
67 def restart(data):
68 Openbox_restart(openbox, "")
69
70 def toggle_shade(data):
71 print "toggle_shade"
72
73 def raise_win(data):
74 client = Openbox_findClient(openbox, data.window())
75 if not client: return
76 screen = Openbox_screen(openbox, OBClient_screen(client))
77 OBScreen_restack(screen, 1, client)
78
79 def lower_win(data):
80 client = Openbox_findClient(openbox, data.window())
81 if not client: return
82 screen = Openbox_screen(openbox, OBClient_screen(client))
83 OBScreen_restack(screen, 0, client)
84
85 def toggle_shade(data):
86 client = Openbox_findClient(openbox, data.window())
87 if not client: return
88 print "toggle_shade"
89 OBClient_shade(client, not OBClient_shaded(client))
90
91 def shade(data):
92 client = Openbox_findClient(openbox, data.window())
93 if not client: return
94 OBClient_shade(client, 1)
95
96 def unshade(data):
97 client = Openbox_findClient(openbox, data.window())
98 if not client: return
99 OBClient_shade(client, 0)
100
101 #########################################
102 ### Convenience functions for scripts ###
103 #########################################
104
105 def execute(bin, screen = 0):
106 Openbox_execute(openbox, screen, bin)
107
108 print "Loaded builtins.py"
This page took 0.04623 seconds and 5 git commands to generate.