]> icculus.org git repositories - mikachu/openbox.git/blob - openbox/snap.c
rm debug print
[mikachu/openbox.git] / openbox / snap.c
1 #include "client.h"
2 #include "frame.h"
3 #include "stacking.h"
4 #include "screen.h"
5
6 static int resistance = 10;
7
8 void snap_move(Client *c, int *x, int *y, int w, int h)
9 {
10     GList *it;
11     Rect *area;
12     int l, t, r, b; /* requested edges */
13     int al, at, ar, ab; /* screen area edges */
14     int cl, ct, cr, cb; /* current edges */
15
16     /* add the frame to the dimensions */
17     l = *x;
18     t = *y;
19     r = l + w - 1;
20     b = t + h - 1;
21
22     cl = c->frame->area.x;
23     ct = c->frame->area.y;
24     cr = cl + c->frame->area.width - 1;
25     cb = ct + c->frame->area.height - 1;
26     
27     /* snap to other clients */
28     for (it = stacking_list; it != NULL; it = it->next) {
29         /* XXX foo */
30     }
31
32     /* get the screen boundaries */
33     area = screen_area(c->desktop);
34     al = area->x;
35     at = area->y;
36     ar = al + area->width - 1;
37     ab = at + area->height - 1;
38
39     /* snap to screen edges */
40     if (cl >= al && l < al && l >= al - resistance)
41         *x = al;
42     else if (cr <= ar && r > ar && r <= ar + resistance)
43             *x = ar - w + 1;
44     if (ct >= at && t < at && t >= at - resistance)
45         *y = at;
46     else if (cb <= ab && b > ab && b < ab + resistance)
47         *y = ab - h + 1;
48 }