]> Dogcows Code - chaz/openbox/blob - scripts/clientmotion.py
global python scripts. client motion/resizing is all done via python now
[chaz/openbox] / scripts / clientmotion.py
1 posqueue = [];
2
3 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 motion_release(action, win, type, modifiers, button, xroot, yroot, time):
25 global posqueue
26 for i in posqueue:
27 if i[0] == button:
28 #delete_Rect i[3]
29 posqueue.remove(i)
30 break
31
32 # ButtonPressAction *a = 0;
33 # for (int i=0; i<BUTTONS; ++i) {
34 # if (_posqueue[i]->button == e.button)
35 # a = _posqueue[i];
36 # if (a) // found one and removed it
37 # _posqueue[i] = _posqueue[i+1];
38 # }
39 # if (a) { // found one
40 # _posqueue[BUTTONS-1] = a;
41 # a->button = 0;
42 # }
43
44
45 def motion(action, win, type, modifiers, xroot, yroot, time):
46 client = Openbox_findClient(openbox, win)
47
48 global posqueue
49 dx = xroot - posqueue[0][1]
50 dy = yroot - posqueue[0][2]
51 # _dx = x_root - _posqueue[0]->pos.x();
52 # _dy = y_root - _posqueue[0]->pos.y();
53
54 if not client:
55 return
56 area = posqueue[0][3] # A Rect
57 if (type == Type_Titlebar) or (type == Type_Label):
58 OBClient_move(client, Rect_x(area) + dx, Rect_y(area) + dy)
59 # c->move(_posqueue[0]->clientarea.x() + _dx,
60 # _posqueue[0]->clientarea.y() + _dy);
61 elif type == Type_LeftGrip:
62 OBClient_resize(client, OBClient_TopRight,
63 Rect_width(area) - dx, Rect_height(area) + dy)
64 # c->resize(OBClient::TopRight,
65 # _posqueue[0]->clientarea.width() - _dx,
66 # _posqueue[0]->clientarea.height() + _dy);
67 elif type == Type_RightGrip:
68 OBClient_resize(client, OBClient_TopLeft,
69 Rect_width(area) + dx, Rect_height(area) + dy)
70 # c->resize(OBClient::TopLeft,
71 # _posqueue[0]->clientarea.width() + _dx,
72 # _posqueue[0]->clientarea.height() + _dy);
73
74
75 register(Action_ButtonPress, motion_press)
76 register(Action_ButtonRelease, motion_release)
77 register(Action_MouseMotion, motion)
This page took 0.034565 seconds and 4 git commands to generate.