]> Dogcows Code - chaz/openbox/blob - scripts/builtins.py
provide these functions for callbacks
[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
This page took 0.201994 seconds and 5 git commands to generate.