]> icculus.org git repositories - dana/openbox.git/blob - scripts/clientmotion.py
bindings work. now they have a reset key too.
[dana/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         #  ButtonPressAction *a = _posqueue[BUTTONS - 1];
13         #  for (int i=BUTTONS-1; i>0;)
14         #    _posqueue[i] = _posqueue[--i];
15         #  _posqueue[0] = a;
16         #  a->button = e.button;
17         #  a->pos.setPoint(e.x_root, e.y_root);
18         
19         #  OBClient *c = Openbox::instance->findClient(e.window);
20         #  // if it's not defined, they should have clicked on the root window, so this
21         #  // area would be meaningless anyways
22         #  if (c) a->clientarea = c->area();
23         
24 def def_motion_release(action, win, type, modifiers, button, xroot, yroot,
25                        time):
26         global posqueue
27         for i in posqueue:
28                 if i[0] == button:
29                         print "hi"
30                         client = Openbox_findClient(openbox, win)
31                         if client:
32                                 delete_Rect(i[3])
33                         posqueue.remove(i)
34                         break
35
36 def def_do_motion(client, xroot, yroot):
37         global posqueue
38         dx = xroot - posqueue[0][1]
39         dy = yroot - posqueue[0][2]
40         area = posqueue[0][3] # A Rect
41         OBClient_move(client, Rect_x(area) + dx, Rect_y(area) + dy)
42
43 def def_do_resize(client, xroot, yroot, archor_corner):
44         global posqueue
45         dx = xroot - posqueue[0][1]
46         dy = yroot - posqueue[0][2]
47         area = posqueue[0][3] # A Rect
48         OBClient_resize(client, anchor_corner,
49                         Rect_width(area) - dx, Rect_height(area) + dy)
50
51 def def_motion(action, win, type, modifiers, xroot, yroot, time):
52         client = Openbox_findClient(openbox, win)
53         if not client: return
54
55         if (type == Type_Titlebar) or (type == Type_Label):
56                 def_do_move(client, xroot, yroot)
57         elif type == Type_LeftGrip:
58                 def_do_resize(client, xroot, yroot, OBClient_TopRight)
59         elif type == Type_RightGrip:
60                 def_do_resize(client, xroot, yroot, OBClient_TopLeft)
61
62 def def_enter(action, win, type, modifiers):
63         client = Openbox_findClient(openbox, win)
64         if not client: return
65         OBClient_focus(client)
66
67 def def_leave(action, win, type, modifiers):
68         client = Openbox_findClient(openbox, win)
69         if not client: return
70
71
72 register(Action_EnterWindow, def_enter)
73 #register(Action_LeaveWindow, def_leave)
74
75 register(Action_ButtonPress, def_motion_press)
76 register(Action_ButtonRelease, def_motion_release)
77 register(Action_MouseMotion, def_motion)
78
79 print "Loaded clientmotion.py"