load config options from the python environment
[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_motion(action, win, type, modifiers, xroot, yroot, time):
24         client = Openbox_findClient(openbox, win)
25         if not client: return
26
27         global posqueue
28         dx = xroot - posqueue[0][1]
29         dy = yroot - posqueue[0][2]
30
31         area = posqueue[0][3] # A Rect
32         if (type == Type_Titlebar) or (type == Type_Label):
33                 OBClient_move(client, Rect_x(area) + dx, Rect_y(area) + dy)
34         elif type == Type_LeftGrip:
35                 OBClient_resize(client, OBClient_TopRight,
36                                 Rect_width(area) - dx, Rect_height(area) + dy)
37         elif type == Type_RightGrip:
38                 OBClient_resize(client, OBClient_TopLeft,
39                                 Rect_width(area) + dx, Rect_height(area) + dy)
40
41 def def_enter(action, win, type, modifiers):
42         client = Openbox_findClient(openbox, win)
43         if not client: return
44         if enter_focus != 0:
45                 OBClient_focus(client)
46
47 def def_leave(action, win, type, modifiers):
48         client = Openbox_findClient(openbox, win)
49         if not client: return
50         if leave_unfocus != 0:
51                 OBClient_unfocus(client)
52
53
54 register(Action_EnterWindow, def_enter)
55 register(Action_LeaveWindow, def_leave)
56
57 register(Action_ButtonPress, def_motion_press)
58 register(Action_ButtonRelease, def_motion_release)
59 register(Action_MouseMotion, def_motion)
60
61 print "Loaded clientmotion.py"