commit c7cba3c123c6bc643cb362135c82c7300906f534
parent d12fe194b58299775e8e53ea51b814b2db50b443
Author: Sander van Dijk <sander@wmii.de>
Date: Sun, 26 Mar 2006 22:13:35 +0200
make drop_resize more reliable in cornercases.
Diffstat:
3 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/cmd/wm/area.c b/cmd/wm/area.c
@@ -393,7 +393,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) ? ... */
@@ -404,36 +403,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 == Colstack || a->mode == Colmax)
goto AfterVertical;
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -519,7 +519,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_tag(v, True);
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -66,7 +66,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;