re-applying Sanders patches which I accidently overwrote

This commit is contained in:
Anselm R. Garbe 2006-03-27 09:01:05 +02:00
parent 6ce7eb4337
commit c946b86cdf
3 changed files with 27 additions and 16 deletions

View File

@ -394,6 +394,7 @@ match_horiz(Area *a, XRectangle *r)
}
}
static void
drop_resize(Frame *f, XRectangle *new)
{
@ -402,7 +403,6 @@ drop_resize(Frame *f, XRectangle *new)
Frame *north = nil, *south = nil;
unsigned int i;
unsigned int min = 2 * bar_height();
Bool horiz_resize = False;
for(i = 1; (i < v->narea) && (v->area[i] != a); i++);
/* first managed area is indexed 1, thus (i > 1) ? ... */
@ -413,36 +413,47 @@ drop_resize(Frame *f, XRectangle *new)
north = i ? a->frame[i - 1] : nil;
south = i + 1 < a->nframe ? a->frame[i + 1] : nil;
/* horizontal resize */
/* validate (and trim if necessary) horizontal resize */
if(new->width < MIN_COLWIDTH) {
if(new->x + new->width == f->rect.x + f->rect.width)
new->x = a->rect.x + a->rect.width - MIN_COLWIDTH;
new->width = MIN_COLWIDTH;
}
if(west && (new->x != f->rect.x)) {
horiz_resize = True;
if(new->x < 0 || new->x < (west->rect.x + MIN_COLWIDTH)) {
new->width -= (west->rect.x + MIN_COLWIDTH) - new->x;
new->x = west->rect.x + MIN_COLWIDTH;
} else if(new->width < MIN_COLWIDTH) {
new->x -= MIN_COLWIDTH - new->width;
new->width = MIN_COLWIDTH;
}
} else {
new->width += new->x - a->rect.x;
new->x = a->rect.x;
}
if(east && (new->x + new->width != f->rect.x + f->rect.width)) {
if((new->x + new->width) > (east->rect.x + east->rect.width - MIN_COLWIDTH))
new->width = (east->rect.x + east->rect.width - MIN_COLWIDTH) - new->x;
} else
new->width = (a->rect.x + a->rect.width) - new->x;
if(new->width < MIN_COLWIDTH)
goto AfterHorizontal;
/* horizontal resize */
if(west && (new->x != a->rect.x)) {
west->rect.width = new->x - west->rect.x;
a->rect.width += a->rect.x - new->x;
a->rect.x = new->x;
match_horiz(a, &a->rect);
match_horiz(west, &west->rect);
relax_area(west);
}
if(east && (new->x + new->width != f->rect.x + f->rect.width)) {
horiz_resize = True;
if((new->x + new->width) > (east->rect.x + east->rect.width - MIN_COLWIDTH))
new->width = (east->rect.x + east->rect.width - MIN_COLWIDTH) - new->x;
else if(new->width < MIN_COLWIDTH)
new->width = MIN_COLWIDTH;
if(east && (new->x + new->width != a->rect.x + a->rect.width)) {
east->rect.width -= new->x + new->width - east->rect.x;
east->rect.x = new->x + new->width;
a->rect.width = (new->x + new->width) - a->rect.x;
match_horiz(a, &a->rect);
match_horiz(east, &east->rect);
relax_area(east);
}
if(horiz_resize)
match_horiz(a, &a->rect);
AfterHorizontal:
if(a->mode != Colequal)
goto AfterVertical;

View File

@ -548,7 +548,7 @@ send2area_client(Client *c, char *arg)
if(i == -1)
return;
if(!strncmp(arg, "new", 4) && i) {
if(a->nframe == 1 || v->narea - 1 >= rect.width / (2 * MIN_COLWIDTH))
if(a->nframe == 1 || v->narea - 1 >= rect.width / MIN_COLWIDTH)
return;
to = alloc_area(v);
arrange_view(v, True);

View File

@ -67,7 +67,7 @@ enum {
#define MAX_TAGS 8
#define MAX_TAGLEN 32
#define WM_PROTOCOL_DELWIN 1
#define MIN_COLWIDTH 32
#define MIN_COLWIDTH 64
typedef struct View View;
typedef struct Area Area;