commit 6c8280846abfd291364240ca8a3dc1f730f7cc1f
parent 76be3694d071a82863abe4a09f3d1ba128636eee
Author: Kris Maglione <bsdaemon@wmii.de>
Date: Sun, 25 Jun 2006 09:28:29 -0400
Fixed order of function declarations broken in last commit
Diffstat:
2 files changed, 99 insertions(+), 97 deletions(-)
diff --git a/cmd/wm/area.c b/cmd/wm/area.c
@@ -110,6 +110,103 @@ destroy_area(Area *a)
free(a);
}
+static void
+place_client(Area *a, Client *c)
+{
+ static unsigned int mx, my;
+ static Bool *field = nil;
+ Frame *fr;
+ Bool fit = False;
+ BlitzAlign align = CENTER;
+ unsigned int i, j, x, y, maxx, maxy, dx, dy, cx, cy, diff, num = 0;
+ XPoint p1 = {0, 0}, p2 = {0, 0};
+ Frame *f = c->sel;
+ int snap = rect.height / 66;
+ XRectangle *rects;
+
+ if(c->trans)
+ return;
+ if(c->rect.width >= a->rect.width
+ || c->rect.height >= a->rect.height
+ || c->size.flags & USPosition
+ || c->size.flags & PPosition)
+ return;
+
+ rects = rects_of_view(a->view, &num);
+ if(!field) {
+ mx = rect.width / 8;
+ my = rect.height / 8;
+ field = cext_emallocz(my * mx * sizeof(Bool));
+ }
+
+ for(y = 0; y < my; y++)
+ for(x = 0; x < mx; x++)
+ field[y*mx + x] = True;
+
+ dx = rect.width / mx;
+ dy = rect.height / my;
+ for(fr=a->frame; fr; fr=fr->anext) {
+ if(fr == f) {
+ cx = f->rect.width / dx;
+ cy = f->rect.height / dy;
+ continue;
+ }
+ if(fr->rect.x < 0)
+ x = 0;
+ else
+ x = fr->rect.x / dx;
+ if(fr->rect.y < 0)
+ y = 0;
+ else
+ y = fr->rect.y / dy;
+ maxx = (fr->rect.x + fr->rect.width) / dx;
+ maxy = (fr->rect.y + fr->rect.height) / dy;
+ for(j = y; j < my && j < maxy; j++)
+ for(i = x; i < mx && i < maxx; i++)
+ field[j*mx + i] = False;
+ }
+
+ for(y = 0; y < my; y++)
+ for(x = 0; x < mx; x++) {
+ if(field[y*mx + x]) {
+ for(i = x; (i < mx) && field[y*mx + i]; i++);
+ for(j = y; (j < my) && field[j*mx + x]; j++);
+ if(((i - x) * (j - y) > (p2.x - p1.x) * (p2.y - p1.y))
+ && (i - x > cx) && (j - y > cy))
+ {
+ fit = True;
+ p1.x = x;
+ p1.y = y;
+ p2.x = i;
+ p2.y = j;
+ }
+ }
+ }
+
+ if(fit) {
+ p1.x *= dx;
+ p1.y *= dy;
+ }
+
+ if(fit && (p1.x + f->rect.width < a->rect.x + a->rect.width))
+ f->rect.x = p1.x;
+ else {
+ diff = a->rect.width - f->rect.width;
+ f->rect.x = a->rect.x + (random() % (diff ? diff : 1));
+ }
+
+ if(fit && (p1.y + f->rect.height < a->rect.y + a->rect.height))
+ f->rect.y = p1.y;
+ else {
+ diff = a->rect.height - f->rect.height;
+ f->rect.y = a->rect.y + (random() % (diff ? diff : 1));
+ }
+
+ snap_rect(rects, num, &f->rect, &align, snap);
+ if(rects)
+ free(rects);
+}
+
void
send_to_area(Area *to, Area *from, Frame *f)
{
@@ -267,100 +364,3 @@ select_area(Area *a, char *arg)
draw_frames();
return nil;
}
-
-static void
-place_client(Area *a, Client *c)
-{
- static unsigned int mx, my;
- static Bool *field = nil;
- Frame *fr;
- Bool fit = False;
- BlitzAlign align = CENTER;
- unsigned int i, j, x, y, maxx, maxy, dx, dy, cx, cy, diff, num = 0;
- XPoint p1 = {0, 0}, p2 = {0, 0};
- Frame *f = c->sel;
- int snap = rect.height / 66;
- XRectangle *rects;
-
- if(c->trans)
- return;
- if(c->rect.width >= a->rect.width
- || c->rect.height >= a->rect.height
- || c->size.flags & USPosition
- || c->size.flags & PPosition)
- return;
-
- rects = rects_of_view(a->view, &num);
- if(!field) {
- mx = rect.width / 8;
- my = rect.height / 8;
- field = cext_emallocz(my * mx * sizeof(Bool));
- }
-
- for(y = 0; y < my; y++)
- for(x = 0; x < mx; x++)
- field[y*mx + x] = True;
-
- dx = rect.width / mx;
- dy = rect.height / my;
- for(fr=a->frame; fr; fr=fr->anext) {
- if(fr == f) {
- cx = f->rect.width / dx;
- cy = f->rect.height / dy;
- continue;
- }
- if(fr->rect.x < 0)
- x = 0;
- else
- x = fr->rect.x / dx;
- if(fr->rect.y < 0)
- y = 0;
- else
- y = fr->rect.y / dy;
- maxx = (fr->rect.x + fr->rect.width) / dx;
- maxy = (fr->rect.y + fr->rect.height) / dy;
- for(j = y; j < my && j < maxy; j++)
- for(i = x; i < mx && i < maxx; i++)
- field[j*mx + i] = False;
- }
-
- for(y = 0; y < my; y++)
- for(x = 0; x < mx; x++) {
- if(field[y*mx + x]) {
- for(i = x; (i < mx) && field[y*mx + i]; i++);
- for(j = y; (j < my) && field[j*mx + x]; j++);
- if(((i - x) * (j - y) > (p2.x - p1.x) * (p2.y - p1.y))
- && (i - x > cx) && (j - y > cy))
- {
- fit = True;
- p1.x = x;
- p1.y = y;
- p2.x = i;
- p2.y = j;
- }
- }
- }
-
- if(fit) {
- p1.x *= dx;
- p1.y *= dy;
- }
-
- if(fit && (p1.x + f->rect.width < a->rect.x + a->rect.width))
- f->rect.x = p1.x;
- else {
- diff = a->rect.width - f->rect.width;
- f->rect.x = a->rect.x + (random() % (diff ? diff : 1));
- }
-
- if(fit && (p1.y + f->rect.height < a->rect.y + a->rect.height))
- f->rect.y = p1.y;
- else {
- diff = a->rect.height - f->rect.height;
- f->rect.y = a->rect.y + (random() % (diff ? diff : 1));
- }
-
- snap_rect(rects, num, &f->rect, &align, snap);
- if(rects)
- free(rects);
-}
diff --git a/cmd/wm/view.c b/cmd/wm/view.c
@@ -312,6 +312,8 @@ view_index(View *v) {
n = snprintf(&buffer[buf_i], len, "%d %d %d %s\n",
a_i, idx_of_client(f->client),
r->width, f->client->props);
+ if(len - n < 0)
+ return buffer;
buf_i += n;
len -= n;
}