]> icculus.org git repositories - mikachu/openbox.git/blob - scripts/clientmotion.py
add comments/headers
[mikachu/openbox.git] / scripts / clientmotion.py
1 posqueue = [];
2
3 def def_motion_press(action, win, type, modifiers, button, xroot, yroot, time):
4         client = Openbox_findClient(openbox, win)
5
6         global posqueue
7         newi = [button, xroot, yroot]
8         if client:
9                 newi.append(new_Rect(OBClient_area(client)))
10         posqueue.append(newi)
11
12 def def_motion_release(action, win, type, modifiers, button, xroot, yroot,
13                        time):
14         global posqueue
15         for i in posqueue:
16                 if i[0] == button:
17                         client = Openbox_findClient(openbox, win)
18                         if client:
19                                 delete_Rect(i[3])
20                         posqueue.remove(i)
21                         break
22
23 def def_do_motion(client, xroot, yroot):
24         global posqueue
25         dx = xroot - posqueue[0][1]
26         dy = yroot - posqueue[0][2]
27         area = posqueue[0][3] # A Rect
28         OBClient_move(client, Rect_x(area) + dx, Rect_y(area) + dy)
29
30 def def_do_resize(client, xroot, yroot, archor_corner):
31         global posqueue
32         dx = xroot - posqueue[0][1]
33         dy = yroot - posqueue[0][2]
34         area = posqueue[0][3] # A Rect
35         OBClient_resize(client, anchor_corner,
36                         Rect_width(area) - dx, Rect_height(area) + dy)
37
38 def def_motion(action, win, type, modifiers, xroot, yroot, time):
39         client = Openbox_findClient(openbox, win)
40         if not client: return
41
42         if (type == Type_Titlebar) or (type == Type_Label):
43                 def_do_motion(client, xroot, yroot)
44         elif type == Type_LeftGrip:
45                 def_do_resize(client, xroot, yroot, OBClient_TopRight)
46         elif type == Type_RightGrip:
47                 def_do_resize(client, xroot, yroot, OBClient_TopLeft)
48
49 def def_enter(action, win, type, modifiers):
50         client = Openbox_findClient(openbox, win)
51         if not client: return
52         if enter_focus != 0:
53                 OBClient_focus(client)
54
55 def def_leave(action, win, type, modifiers):
56         client = Openbox_findClient(openbox, win)
57         if not client: return
58         if leave_unfocus != 0:
59                 OBClient_unfocus(client)
60
61
62 register(Action_EnterWindow, def_enter)
63 register(Action_LeaveWindow, def_leave)
64
65 register(Action_ButtonPress, def_motion_press)
66 register(Action_ButtonRelease, def_motion_release)
67 register(Action_MouseMotion, def_motion)
68
69 print "Loaded clientmotion.py"