]> Dogcows Code - chaz/openbox/blob - scripts/clientmotion.py
way sexier buildtree
[chaz/openbox] / 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 client = Openbox_findClient(openbox, win)
30 if client:
31 delete_Rect(i[3])
32 posqueue.remove(i)
33 break
34
35 # ButtonPressAction *a = 0;
36 # for (int i=0; i<BUTTONS; ++i) {
37 # if (_posqueue[i]->button == e.button)
38 # a = _posqueue[i];
39 # if (a) // found one and removed it
40 # _posqueue[i] = _posqueue[i+1];
41 # }
42 # if (a) { // found one
43 # _posqueue[BUTTONS-1] = a;
44 # a->button = 0;
45 # }
46
47
48 def def_motion(action, win, type, modifiers, xroot, yroot, time):
49 client = Openbox_findClient(openbox, win)
50 if not client: return
51
52 global posqueue
53 dx = xroot - posqueue[0][1]
54 dy = yroot - posqueue[0][2]
55 # _dx = x_root - _posqueue[0]->pos.x();
56 # _dy = y_root - _posqueue[0]->pos.y();
57
58 area = posqueue[0][3] # A Rect
59 if (type == Type_Titlebar) or (type == Type_Label):
60 OBClient_move(client, Rect_x(area) + dx, Rect_y(area) + dy)
61 # c->move(_posqueue[0]->clientarea.x() + _dx,
62 # _posqueue[0]->clientarea.y() + _dy);
63 elif type == Type_LeftGrip:
64 OBClient_resize(client, OBClient_TopRight,
65 Rect_width(area) - dx, Rect_height(area) + dy)
66 # c->resize(OBClient::TopRight,
67 # _posqueue[0]->clientarea.width() - _dx,
68 # _posqueue[0]->clientarea.height() + _dy);
69 elif type == Type_RightGrip:
70 OBClient_resize(client, OBClient_TopLeft,
71 Rect_width(area) + dx, Rect_height(area) + dy)
72 # c->resize(OBClient::TopLeft,
73 # _posqueue[0]->clientarea.width() + _dx,
74 # _posqueue[0]->clientarea.height() + _dy);
75
76 def def_enter(action, win, type, modifiers):
77 client = Openbox_findClient(openbox, win)
78 if not client: return
79 OBClient_focus(client)
80
81 def def_leave(action, win, type, modifiers):
82 client = Openbox_findClient(openbox, win)
83 if not client: return
84
85
86 register(Action_EnterWindow, def_enter)
87 #register(Action_LeaveWindow, def_leave)
88
89 register(Action_ButtonPress, def_motion_press)
90 register(Action_ButtonRelease, def_motion_release)
91 register(Action_MouseMotion, def_motion)
92
93 print "Loaded clientmotion.py"
This page took 0.038456 seconds and 4 git commands to generate.