From df251f992d8596d2757b96b0a0bd62925eea6b78 Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Mon, 24 Apr 2006 16:54:56 +0200 Subject: [PATCH] separated scaling stuff from arrange_column to scale_column (next is with views) --- cmd/wm/area.c | 12 +++++++----- cmd/wm/column.c | 37 ++++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/cmd/wm/area.c b/cmd/wm/area.c index 18f3850e..6f477a1b 100644 --- a/cmd/wm/area.c +++ b/cmd/wm/area.c @@ -230,17 +230,19 @@ attach_to_area(Area *a, Client *c) Frame *f; c->floating = !aidx; - if(aidx && a->frame.size) { - h = a->rect.height / a->frame.size; - if(a->frame.size > 1) + if(aidx) { + h = a->rect.height / (a->frame.size + 1); + fprintf(stderr, "attach height=%d\n", h); + if(a->frame.size) scale_column(a, a->rect.height - h); } f = create_frame(a, c); - f->rect.height = h; - if(aidx) /* column */ + if(aidx) { /* column */ + f->rect.height = h; arrange_column(a, False); + } else { /* floating */ place_client(a, c); resize_client(c, &f->rect, False); diff --git a/cmd/wm/column.c b/cmd/wm/column.c index 2e5c6eb5..4fdce5b9 100644 --- a/cmd/wm/column.c +++ b/cmd/wm/column.c @@ -106,38 +106,31 @@ relax_column(Area *a) void scale_column(Area *a, float h) { - unsigned int i, yoff = a->rect.y; - unsigned int min_height = 2 * height_of_bar(); - int hdiff = 0; + unsigned int i; float scale, dy = 0; if(!a->frame.size) return; + fprintf(stderr, " >>> scale column h=%f\n", h); for(i = 0; i < a->frame.size; i++) dy += a->frame.data[i]->rect.height; scale = h / dy; for(i = 0; i < a->frame.size; i++) { Frame *f = a->frame.data[i]; - f->rect.x = a->rect.x; - f->rect.y = yoff; - f->rect.width = a->rect.width; + fprintf(stderr, "old height: %d, ", f->rect.height); f->rect.height *= scale; - if(f->rect.height < min_height) - f->rect.height = min_height; - else if((hdiff = yoff + f->rect.height - h + (a->frame.size - i) * min_height) > 0) - f->rect.height -= hdiff; - if(i == a->frame.size - 1) - f->rect.height = a->rect.height - yoff; - yoff += f->rect.height; - resize_client(f->client, &f->rect, True); + fprintf(stderr, "new height: %d\n", f->rect.height); } + fprintf(stderr, "%s", " <<< scale column\n"); } void arrange_column(Area *a, Bool dirty) { unsigned int i, yoff = a->rect.y, h; + unsigned int min_height = 2 * height_of_bar(); + int hdiff; if(!a->frame.size) return; @@ -145,13 +138,27 @@ arrange_column(Area *a, Bool dirty) switch(a->mode) { case Coldefault: h = a->rect.height / a->frame.size; - if(h < 2 * height_of_bar()) /* min height */ + if(h < min_height) goto Fallthrough; if(dirty) { for(i = 0; i < a->frame.size; i++) a->frame.data[i]->rect.height = h; } scale_column(a, a->rect.height); + for(i = 0; i < a->frame.size; i++) { + Frame *f = a->frame.data[i]; + f->rect.x = a->rect.x; + f->rect.y = yoff; + f->rect.width = a->rect.width; + if(f->rect.height < min_height) + f->rect.height = min_height; + else if((hdiff = yoff + f->rect.height - a->rect.height + (a->frame.size - i) * min_height) > 0) + f->rect.height -= hdiff; + if(i == a->frame.size - 1) + f->rect.height = a->rect.height - yoff; + yoff += f->rect.height; + resize_client(f->client, &f->rect, True); + } break; case Colstack: h = a->rect.height - (a->frame.size - 1) * height_of_bar();