]> icculus.org git repositories - mikachu/openbox.git/blob - scripts/clientmotion.py
new mouse button code is seeming to work. you can move windows
[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_do_move(xroot, yroot, client):
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(xroot, yroot, client, anchor_corner):
31         global posqueue
32         dx = xroot - posqueue[0][1]
33         dy = yroot - posqueue[0][2]
34         OBClient_resize(client, anchor_corner,
35                         Rect_width(area) - dx, Rect_height(area) + dy)
36
37 def def_motion(data):
38         client = Openbox_findClient(openbox, data.window())
39         if not client: return
40
41         global posqueue
42         if not posqueue[0][0] == 1: return
43         
44         type = data.target()
45         if (type == Type_Titlebar) or (type == Type_Label) or \
46            (type == Type_Plate) or (type == Type_Handle):
47                 def_do_move(data.xroot(), data.yroot(), client)
48         elif type == Type_LeftGrip:
49                 def_do_resize(data.xroot(), data.yroot(), client,
50                               OBClient_TopRight)
51         elif type == Type_RightGrip:
52                 def_do_resize(data.xroot(), data.yroot(), client,
53                               OBClient_TopLeft)
54
55 def def_enter(data):
56         client = Openbox_findClient(openbox, data.window())
57         if not client: return
58         if enter_focus != 0:
59                 OBClient_focus(client)
60
61 def def_leave(data):
62         client = Openbox_findClient(openbox, data.window())
63         if not client: return
64         if leave_unfocus != 0:
65                 OBClient_unfocus(client)
66
67
68 register(Action_EnterWindow, def_enter)
69 register(Action_LeaveWindow, def_leave)
70
71 register(Action_ButtonPress, def_motion_press)
72 register(Action_ButtonRelease, def_motion_release)
73 register(Action_MouseMotion, def_motion)
74
75 print "Loaded clientmotion.py"