]> Dogcows Code - chaz/openbox/blob - scripts/builtins.py
better focusing. support for the take_focus protocol
[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 OBClient_focus(client)
15
16 def move(data):
17 """Moves the window interactively. This should only be used with
18 MouseMotion events"""
19 client = Openbox_findClient(openbox, data.window())
20 if not client: return
21
22 dx = data.xroot() - data.pressx()
23 dy = data.yroot() - data.pressy()
24 OBClient_move(client, data.press_clientx() + dx, data.press_clienty() + dy)
25
26 def resize(data):
27 """Resizes the window interactively. This should only be used with
28 MouseMotion events"""
29 client = Openbox_findClient(openbox, data.window())
30 if not client: return
31
32 px = data.pressx()
33 py = data.pressy()
34 dx = data.xroot() - px
35 dy = data.yroot() - py
36
37 # pick a corner to anchor
38 if not (resize_nearest or data.context() == MC_Grip):
39 corner = OBClient_TopLeft
40 else:
41 x = px - data.press_clientx()
42 y = py - data.press_clienty()
43 if y < data.press_clientheight() / 2:
44 if x < data.press_clientwidth() / 2:
45 corner = OBClient_BottomRight
46 dx *= -1
47 else:
48 corner = OBClient_BottomLeft
49 dy *= -1
50 else:
51 if x < data.press_clientwidth() / 2:
52 corner = OBClient_TopRight
53 dx *= -1
54 else:
55 corner = OBClient_TopLeft
56
57 OBClient_resize(client, corner,
58 data.press_clientwidth() + dx,
59 data.press_clientheight() + dy);
60
61 def execute(bin, screen = 0):
62 Openbox_execute(openbox, screen, bin)
63
64 def restart(data):
65 Openbox_restart(openbox, "")
66
67 def toggle_shade(data):
68 print "toggle_shade"
69
70 def raise_win(data):
71 client = Openbox_findClient(openbox, data.window())
72 if not client: return
73 screen = Openbox_screen(openbox, OBClient_screen(client))
74 OBScreen_restack(screen, 1, client)
75
76 def lower_win(data):
77 client = Openbox_findClient(openbox, data.window())
78 if not client: return
79 screen = Openbox_screen(openbox, OBClient_screen(client))
80 OBScreen_restack(screen, 0, client)
81
82 def toggle_shade(data):
83 client = Openbox_findClient(openbox, data.window())
84 if not client: return
85 print "toggle_shade"
86 OBClient_shade(client, not OBClient_shaded(client))
87
88 def shade(data):
89 client = Openbox_findClient(openbox, data.window())
90 if not client: return
91 OBClient_shade(client, 1)
92
93 def unshade(data):
94 client = Openbox_findClient(openbox, data.window())
95 if not client: return
96 OBClient_shade(client, 0)
97
98 print "Loaded builtins.py"
This page took 0.04102 seconds and 4 git commands to generate.