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