mirror of https://github.com/0intro/wmii
separated scaling stuff from arrange_column to scale_column (next is with views)
This commit is contained in:
parent
01db208f43
commit
df251f992d
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue