]> Dogcows Code - chaz/openbox/blob - scripts/builtins.py
dont move/resize desktop windows or dock windows
[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 type = OBClient_type(client)
29 # these types of windows dont get moved
30 if type == OBClient_Type_Dock or \
31 type == OBClient_Type_Desktop:
32 return
33
34 dx = data.xroot() - data.pressx()
35 dy = data.yroot() - data.pressy()
36 OBClient_move(client, data.press_clientx() + dx, data.press_clienty() + dy)
37
38 def resize(data):
39 """Resizes the window interactively. This should only be used with
40 MouseMotion events"""
41 client = Openbox_findClient(openbox, data.window())
42 if not client: return
43
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:
48 return
49
50 px = data.pressx()
51 py = data.pressy()
52 dx = data.xroot() - px
53 dy = data.yroot() - py
54
55 # pick a corner to anchor
56 if not (resize_nearest or data.context() == MC_Grip):
57 corner = OBClient_TopLeft
58 else:
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
64 dx *= -1
65 else:
66 corner = OBClient_BottomLeft
67 dy *= -1
68 else:
69 if x < data.press_clientwidth() / 2:
70 corner = OBClient_TopRight
71 dx *= -1
72 else:
73 corner = OBClient_TopLeft
74
75 OBClient_resize(client, corner,
76 data.press_clientwidth() + dx,
77 data.press_clientheight() + dy);
78
79 def restart(data):
80 Openbox_restart(openbox, "")
81
82 def toggle_shade(data):
83 print "toggle_shade"
84
85 def raise_win(data):
86 client = Openbox_findClient(openbox, data.window())
87 if not client: return
88 screen = Openbox_screen(openbox, OBClient_screen(client))
89 OBScreen_restack(screen, 1, client)
90
91 def lower_win(data):
92 client = Openbox_findClient(openbox, data.window())
93 if not client: return
94 screen = Openbox_screen(openbox, OBClient_screen(client))
95 OBScreen_restack(screen, 0, client)
96
97 def toggle_shade(data):
98 client = Openbox_findClient(openbox, data.window())
99 if not client: return
100 print "toggle_shade"
101 OBClient_shade(client, not OBClient_shaded(client))
102
103 def shade(data):
104 client = Openbox_findClient(openbox, data.window())
105 if not client: return
106 OBClient_shade(client, 1)
107
108 def unshade(data):
109 client = Openbox_findClient(openbox, data.window())
110 if not client: return
111 OBClient_shade(client, 0)
112
113 #########################################
114 ### Convenience functions for scripts ###
115 #########################################
116
117 def execute(bin, screen = 0):
118 Openbox_execute(openbox, screen, bin)
119
120 print "Loaded builtins.py"
This page took 0.04221 seconds and 5 git commands to generate.