wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit eeb62d2041868a7d2b6566e01d18ff5cd0664c01
parent 97495656b08f04b1d0ed9159cd29a404a8a4e914
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Wed, 31 May 2006 19:13:21 +0200

allowing size hints for /def/ncol (next push will rename /def/rules into /def/tagrules and /def/ncol into /def/colrules)


Diffstat:
cmd/wm/area.c | 19++++++++++---------
cmd/wm/client.c | 8++++----
cmd/wm/column.c | 8++++----
cmd/wm/view.c | 17++++++++++-------
cmd/wm/wm.h | 4++--
rc/wmiirc | 2+-
6 files changed, 31 insertions(+), 27 deletions(-)

diff --git a/cmd/wm/area.c b/cmd/wm/area.c @@ -15,16 +15,17 @@ vector_of_areas(AreaVector *av) } Area * -create_area(View *v, unsigned int pos) +create_area(View *v, unsigned int pos, unsigned int w) { static unsigned short id = 1; - unsigned int w; Area *a = nil; - if(v->area.size > 1) - w = rect.width / v->area.size - 1; - else - w = rect.width; + if(!w) { + if(v->area.size > 1) + w = rect.width / v->area.size - 1; + else + w = rect.width; + } if(w < MIN_COLWIDTH) w = MIN_COLWIDTH; @@ -250,9 +251,9 @@ attach_to_area(Area *a, Client *c, Bool send) } if(!send && aidx) { /* column */ - unsigned int nc = ncol_of_view(v); - if(v->area.data[1]->frame.size && nc && nc > v->area.size - 1) { - a = new_column(v, v->sel + 1); + unsigned int w = ncol_of_view(v); + if(v->area.data[1]->frame.size && w) { + a = new_column(v, v->area.size, w); arrange_view(v); } } diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -637,11 +637,11 @@ newcol_client(Client *c, char *arg) return; if(!strncmp(arg, "prev", 5)) { - to = new_column(v, i); + to = new_column(v, i, 0); send_to_area(to, a, c); } else if(!strncmp(arg, "next", 5)) { - to = new_column(v, i + 1); + to = new_column(v, i + 1, 0); send_to_area(to, a, c); } else @@ -698,7 +698,7 @@ send_client(Client *c, char *arg) if(i > 1) to = v->area.data[i - 1]; else if(a->frame.size > 1) - to = new_column(v, 1); + to = new_column(v, 1, 0); else return; send_to_area(to, a, c); @@ -707,7 +707,7 @@ send_client(Client *c, char *arg) if(i < v->area.size - 1) to = v->area.data[i + 1]; else if(a->frame.size > 1) - to = new_column(v, v->area.size); + to = new_column(v, v->area.size, 0); else return; send_to_area(to, a, c); diff --git a/cmd/wm/column.c b/cmd/wm/column.c @@ -365,13 +365,13 @@ drop_move(Frame *f, XRectangle *new, XPoint *pt) if(i < v->area.size) { if(pt->x <= 5) { if(src->frame.size > 1 || idx_of_area(src) != 1) { - tgt = new_column(v, 0); + tgt = new_column(v, 0, 0); send_to_area(tgt, src, f->client); } } else if(pt->x >= rect.width - 5) { if(src->frame.size > 1 || idx_of_area(src) != v->area.size - 1) { - tgt = new_column(v, v->area.size); + tgt = new_column(v, v->area.size, 0); send_to_area(tgt, src, f->client); } } @@ -423,9 +423,9 @@ resize_column(Client *c, XRectangle *r, XPoint *pt) } Area * -new_column(View *v, unsigned int pos) { +new_column(View *v, unsigned int pos, unsigned int w) { Area *a; - if(!(a = create_area(v, pos))) + if(!(a = create_area(v, pos, w))) return nil; arrange_view(v); return a; diff --git a/cmd/wm/view.c b/cmd/wm/view.c @@ -30,8 +30,8 @@ create_view(const char *name) v->id = id++; cext_strlcpy(v->name, name, sizeof(v->name)); - create_area(v, v->area.size); - create_area(v, v->area.size); + create_area(v, v->area.size, 0); + create_area(v, v->area.size, 0); cext_vattach(vector_of_views(&view), v); qsort(view.data, view.size, sizeof(View *), comp_view_name); return v; @@ -398,13 +398,16 @@ ncol_of_view(View *v) for(i = 0; i < vrule.size; i++) { Rule *r = vrule.data[i]; if(!regexec(&r->regex, v->name, 1, &tmpregm, 0)) { - if(sscanf(r->value, "%u", &n) == 1) { - fprintf(stderr, "r->value=%s n=%d\n", r->value, n); - return n; + char buf[256]; + char *toks[16]; + cext_strlcpy(buf, r->value, sizeof(buf)); + n = cext_tokenize(toks, 16, buf, '+'); + if(n && n > v->area.size - 1) { + if(sscanf(toks[v->area.size - 1], "%u", &n) == 1) + return (rect.width * n) / 100; } - fprintf(stderr, "r->value=%s n=%d\n", r->value, n); + break; } } return 0; } - diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -211,7 +211,7 @@ RuleVector vrule; /* area.c */ -Area *create_area(View *v, unsigned int pos); +Area *create_area(View *v, unsigned int pos, unsigned int w); void destroy_area(Area *a); int idx_of_area(Area *a); int idx_of_area_id(View *t, unsigned short id); @@ -268,7 +268,7 @@ void scale_column(Area *a, float h); void resize_column(Client *c, XRectangle *r, XPoint *pt); int column_mode_of_str(char *arg); char *str_of_column_mode(int mode); -Area *new_column(View *v, unsigned int pos); +Area *new_column(View *v, unsigned int pos, unsigned int w); /* event.c */ void init_x_event_handler(); diff --git a/rc/wmiirc b/rc/wmiirc @@ -37,7 +37,7 @@ xwrite /def/font $WMII_FONT xwrite /def/selcolors $WMII_SELCOLORS xwrite /def/normcolors $WMII_NORMCOLORS wmiir write /def/ncol <<EOF -/.*/ -> 2 +/1/ -> 60+40 EOF # TAGGING RULES