wmii

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

commit c8223a7d023eb9eb403c1d899f7f1b262aedf87c
parent ab2d1760f8777601daf1d5a7d1e4ef193702ec8c
Author: Kris Maglione <kris@suckless.org>
Date:   Sat, 22 May 2010 11:15:57 -0400

Allow colrules to be specified in pixels.

Diffstat:
cmd/wmii/area.c | 7+++----
cmd/wmii/client.c | 34+++++++++++++++-------------------
cmd/wmii/event.c | 4++--
cmd/wmii/ewmh.c | 12++++++------
cmd/wmii/fns.h | 3+--
cmd/wmii/frame.c | 8++++----
cmd/wmii/fs.c | 2+-
cmd/wmii/message.c | 4++--
cmd/wmii/view.c | 15+++++++++++----
doc/wmii.tex | 15++++++++++-----
man/wmii.1 | 16+++++++++++-----
man/wmii.man1 | 13++++++++-----
12 files changed, 74 insertions(+), 59 deletions(-)

diff --git a/cmd/wmii/area.c b/cmd/wmii/area.c @@ -85,16 +85,15 @@ area_create(View *v, Area *pos, int scrn, uint width) { SET(index); if(v->areas) { /* Creating a column. */ minwidth = column_minwidth(); - index = pos ? area_idx(pos) : 1; + index = pos ? area_idx(pos) : 0; numcols = 0; for(a=v->areas[scrn]; a; a=a->next) numcols++; - /* TODO: Need a better sizing/placing algorithm. - */ + /* TODO: Need a better sizing/placing algorithm. */ if(width == 0) { if(numcols >= 0) { - width = view_newcolwidth(v, index); + width = view_newcolwidth(v, scrn, index); if (width == 0) width = Dx(v->r[scrn]) / (numcols + 1); } diff --git a/cmd/wmii/client.c b/cmd/wmii/client.c @@ -191,7 +191,7 @@ client_create(XWindow w, XWindowAttributes *wa) { ewmh_initclient(c); - event("CreateClient %C\n", c); + event("CreateClient %#C\n", c); client_manage(c); return c; } @@ -312,7 +312,7 @@ client_destroy(Client *c) { ewmh_destroyclient(c); group_remove(c); if(starting > -1) - event("DestroyClient %C\n", c); + event("DestroyClient %#C\n", c); event_flush(FocusChangeMask, true); free(c->w.hints); @@ -351,17 +351,13 @@ Cfmt(Fmt *f) { c = va_arg(f->args, Client*); if(c) - return fmtprint(f, "%W", &c->w); + if(f->flags & FmtSharp) + return fmtprint(f, "%s", c->name); + else + return fmtprint(f, "%W", &c->w); return fmtprint(f, "<nil>"); } -char* -clientname(Client *c) { - if(c) - return c->name; - return "<nil>"; -} - Rectangle client_grav(Client *c, Rectangle rd) { Rectangle r, cr; @@ -505,10 +501,10 @@ client_focus(Client *c) { sync(); event_flush(FocusChangeMask, true); - Dprint(DFocus, "client_focus([%C]%s)\n", c, clientname(c)); - Dprint(DFocus, "\t[%C]%s\n\t=> [%C]%s\n", - disp.focus, clientname(disp.focus), - c, clientname(c)); + Dprint(DFocus, "client_focus([%#C]%C)\n", c, c); + Dprint(DFocus, "\t[%#C]%C\n\t=> [%#C]%C\n", + disp.focus, disp.focus, + c, c); if(disp.focus != c) { if(c) { if(!c->noinput) @@ -617,7 +613,7 @@ fullscreen(Client *c, int fullscreen, long screen) { if(fullscreen == (c->fullscreen >= 0)) return; - event("Fullscreen %C %s\n", c, (fullscreen ? "on" : "off")); + event("Fullscreen %#C %s\n", c, (fullscreen ? "on" : "off")); ewmh_updatestate(c); c->fullscreen = -1; @@ -670,7 +666,7 @@ client_seturgent(Client *c, int urgent, int from) { cnot = (urgent ? "" : "Not"); if(urgent != c->urgent) { - event("%sUrgent %C %s\n", cnot, c, cfrom); + event("%sUrgent %#C %s\n", cnot, c, cfrom); c->urgent = urgent; ewmh_updatestate(c); if(c->sel) { @@ -891,12 +887,12 @@ enter_event(Window *w, XCrossingEvent *e) { if(e->detail != NotifyInferior) { if(e->detail != NotifyVirtual) if(e->serial != ignoreenter && disp.focus != c) { - Dprint(DFocus, "enter_notify([%C]%s)\n", c, c->name); + Dprint(DFocus, "enter_notify([%#C]%s)\n", c, c->name); focus(c, false); } client_setcursor(c, cursor[CurNormal]); }else - Dprint(DFocus, "enter_notify(%C[NotifyInferior]%s)\n", c, c->name); + Dprint(DFocus, "enter_notify(%#C[NotifyInferior]%s)\n", c, c->name); } static void @@ -913,7 +909,7 @@ focusin_event(Window *w, XFocusChangeEvent *e) { old = disp.focus; disp.focus = c; if(c != old) { - event("ClientFocus %C\n", c); + event("ClientFocus %#C\n", c); if(c->sel) frame_draw(c->sel); } diff --git a/cmd/wmii/event.c b/cmd/wmii/event.c @@ -56,8 +56,8 @@ event_destroynotify(XDestroyWindowEvent *ev) { void print_focus(const char *fn, Client *c, const char *to) { Dprint(DFocus, "%s() disp.focus:\n", fn); - Dprint(DFocus, "\t%C => %C\n", disp.focus, c); - Dprint(DFocus, "\t%s => %s\n", clientname(disp.focus), to); + Dprint(DFocus, "\t%#C => %#C\n", disp.focus, c); + Dprint(DFocus, "\t%C => %s\n", disp.focus, to); } void diff --git a/cmd/wmii/ewmh.c b/cmd/wmii/ewmh.c @@ -139,7 +139,7 @@ ewmh_destroyclient(Client *c) { e = &c->w.ewmh; if(e->timer) if(!ixp_unsettimer(&srv, e->timer)) - fprint(2, "Badness: %C: Can't unset timer\n", c); + fprint(2, "Badness: %#C: Can't unset timer\n", c); free(c->strut); } @@ -149,7 +149,7 @@ pingtimeout(long id, void *v) { USED(id); c = v; - event("Unresponsive %C\n", c); + event("Unresponsive %#C\n", c); c->w.ewmh.ping = 0; c->w.ewmh.timer = 0; } @@ -297,7 +297,7 @@ ewmh_getstrut(Client *c) { free(strut); return; } - Dprint(DEwmh, "ewmh_getstrut(%C[%s]) Using WM_STRUT\n", c, clientname(c)); + Dprint(DEwmh, "ewmh_getstrut(%#C[%C]) Using WM_STRUT\n", c, c); strut = erealloc(strut, Last * sizeof *strut); strut[LeftMin] = strut[RightMin] = 0; strut[LeftMax] = strut[RightMax] = INT_MAX; @@ -309,7 +309,7 @@ ewmh_getstrut(Client *c) { c->strut->right = Rect(-strut[Right], strut[RightMin], 0, strut[RightMax]); c->strut->top = Rect(strut[TopMin], 0, strut[TopMax], strut[Top]); c->strut->bottom = Rect(strut[BottomMin], -strut[Bottom], strut[BottomMax], 0); - Dprint(DEwmh, "ewmh_getstrut(%C[%s])\n", c, clientname(c)); + Dprint(DEwmh, "ewmh_getstrut(%#C[%C])\n", c, c); Dprint(DEwmh, "\ttop: %R\n", c->strut->top); Dprint(DEwmh, "\tleft: %R\n", c->strut->left); Dprint(DEwmh, "\tright: %R\n", c->strut->right); @@ -374,7 +374,7 @@ ewmh_clientmessage(XClientMessageEvent *e) { c = win2client(e->window); if(c == nil) return 1; - Dprint(DEwmh, "\tclient: %s\n", clientname(c)); + Dprint(DEwmh, "\tclient: %C\n", c); if(l[0] != 2) return 1; focus(c, true); @@ -412,7 +412,7 @@ ewmh_clientmessage(XClientMessageEvent *e) { c = win2client(l[2]); if(c == nil) return 1; - Dprint(DEwmh, "\tclient = [%C]\"%s\"\n", c, clientname(c)); + Dprint(DEwmh, "\tclient = [%#C]\"%C\"\n", c, c); Dprint(DEwmh, "\ttimer = %ld, ping = %ld\n", c->w.ewmh.timer, c->w.ewmh.ping); if(c->w.ewmh.timer) diff --git a/cmd/wmii/fns.h b/cmd/wmii/fns.h @@ -88,7 +88,6 @@ void client_seturgent(Client*, int, int); void client_setviews(Client*, char**); void client_unmap(Client*, int state); Frame* client_viewframe(Client *c, View *v); -char* clientname(Client*); void focus(Client*, bool restack); void fullscreen(Client*, int, long); Client* group_leader(Group*); @@ -262,7 +261,7 @@ bool view_fullscreen_p(View*, int); char* view_index(View*); void view_init(View*, int iscreen); char** view_names(void); -uint view_newcolwidth(View*, int i); +uint view_newcolwidth(View*, int, int); void view_restack(View*); void view_scale(View*, int, int); Client* view_selclient(View*); diff --git a/cmd/wmii/frame.c b/cmd/wmii/frame.c @@ -145,7 +145,7 @@ bup_event(Window *w, XButtonEvent *e) { XAllowEvents(display, ReplayPointer, e->time); else XUngrabPointer(display, e->time); - event("ClientClick %C %d\n", w->aux, e->button); + event("ClientClick %#C %d\n", w->aux, e->button); } static void @@ -194,7 +194,7 @@ bdown_event(Window *w, XButtonEvent *e) { XUngrabPointer(display, e->time); sync(); - event("ClientMouseDown %C %d\n", f->client, e->button); + event("ClientMouseDown %#C %d\n", f->client, e->button); } } } @@ -213,7 +213,7 @@ enter_event(Window *w, XCrossingEvent *e) { c = w->aux; f = c->sel; if(disp.focus != c || selclient() != c) { - Dprint(DFocus, "enter_notify(f) => [%C]%s%s\n", + Dprint(DFocus, "enter_notify(f) => [%#C]%s%s\n", f->client, f->client->name, ignoreenter == e->serial ? " (ignored)" : ""); if(e->detail != NotifyInferior) @@ -234,7 +234,7 @@ expose_event(Window *w, XExposeEvent *e) { if(c->sel) frame_draw(c->sel); else - fprint(2, "Badness: Expose event on a client frame which shouldn't be visible: %C\n", + fprint(2, "Badness: Expose event on a client frame which shouldn't be visible: %#C\n", c); } diff --git a/cmd/wmii/fs.c b/cmd/wmii/fs.c @@ -263,7 +263,7 @@ lookup_file(IxpFileId *parent, char *name) } for(c=client; c; c=c->next) { if(!name || c->w.xid == id) { - push_file(sxprint("%C", c)); + push_file(sxprint("%#C", c)); file->volatil = true; file->p.client = c; file->id = c->w.xid; diff --git a/cmd/wmii/message.c b/cmd/wmii/message.c @@ -338,7 +338,7 @@ getframe(View *v, int scrn, IxpMsg *m) { char* readctl_client(Client *c) { bufclear(); - bufprint("%C\n", c); + bufprint("%#C\n", c); if(c->fullscreen >= 0) bufprint("Fullscreen %d\n", c->fullscreen); else @@ -639,7 +639,7 @@ readctl_view(View *v) { /* select client <client> */ if(v->sel->sel) - bufprint("select client %C\n", v->sel->sel->client); + bufprint("select client %#C\n", v->sel->sel->client); foreach_area(v, s, a) bufprint("colmode %a %s\n", a, column_getmode(a)); diff --git a/cmd/wmii/view.c b/cmd/wmii/view.c @@ -592,19 +592,26 @@ view_update_all(void) { } uint -view_newcolwidth(View *v, int num) { +view_newcolwidth(View *v, int scrn, int num) { Rule *r; char *toks[16]; char buf[sizeof r->value]; ulong n; + /* XXX: Multihead. */ for(r=def.colrules.rule; r; r=r->next) if(regexec(r->regex, v->name, nil, 0)) { utflcpy(buf, r->value, sizeof buf); n = tokenize(toks, 16, buf, '+'); + if(num < n) if(getulong(toks[num], &n)) - return Dx(v->screenr) * (n / 100.0); /* XXX: Multihead. */ + return Dx(v->r[scrn]) * (n / 100.0); + else if(!strcmp("px", strend(toks[num], 2))) { + toks[num][strlen(toks[num]) - 2] = '\0'; + if(getulong(toks[num], &n)) + return n; + } break; } return 0; @@ -627,13 +634,13 @@ view_index(View *v) { for(f=a->frame; f; f=f->anext) { r = &f->r; if(a->floating) - bufprint("%a %C %d %d %d %d %s\n", + bufprint("%a %#C %d %d %d %d %s\n", a, f->client, r->min.x, r->min.y, Dx(*r), Dy(*r), f->client->props); else - bufprint("%a %C %d %d %s\n", + bufprint("%a %#C %d %d %s\n", a, f->client, r->min.y, Dy(*r), f->client->props); diff --git a/doc/wmii.tex b/doc/wmii.tex @@ -1221,11 +1221,16 @@ The root filesystem contains the following: /‹regex›/ -> ‹width›{\color{gray}[}+‹width›{\color{gray}]*}} \end{quote} - When a new column, ‹n›, is created on a view whose - name matches ‹regex›, the ‹n›th given - ‹width› percentage of the screen is given to it. If - there is no ‹n›th width, $1/\mbox{‹ncol›th}$ of the - screen is given to it. + Where, + + \begin{code} + ‹width› := ‹percent of screen› | ‹pixels›px + \end{code} + + When a new column, ‹n›, is created on a view whose name + matches ‹regex›, it is given the ‹n›th supplied ‹width›. + If there is no ‹n›th width, it is given + $1/\mbox{‹ncol›th}$ of the screen. \item[tagrules] \index{filesystem!/!tagrules} diff --git a/man/wmii.1 b/man/wmii.1 @@ -272,11 +272,17 @@ Rules have the form: .fi -When a new column, \fIn\fR, is created on a view whose -name matches \fI<regex>\fR, the \fIn\fRth given -\fI<width>\fR percentage of the screen is given to it. If -there is no \fIn\fRth width, 1/\fIncol\fRth of the -screen is given to it. +Where, + +.nf + \fI<width>\fR := \fI<percent of screen>\fR | \fI<pixels>\fRpx +.fi + + +When a new column, \fI<n>\fR, is created on a view whose name +matches \fI<regex>\fR, it is given the \fI<n>\fRth supplied \fI<width>\fR. +If there is no \fI<n>\fRth width, it is given 1/\fI<ncol>\fRth of the +screen. .TP tagrules diff --git a/man/wmii.man1 b/man/wmii.man1 @@ -243,11 +243,14 @@ follows. ``` /<regex>/ -> <width>[+<width>]* - When a new column, _n_, is created on a view whose - name matches <regex>, the _n_th given - <width> percentage of the screen is given to it. If - there is no _n_th width, 1/_ncol_th of the - screen is given to it. + Where, + +``` <width> := <percent of screen> | <pixels>px + + When a new column, <n>, is created on a view whose name + matches <regex>, it is given the <n>th supplied <width>. + If there is no <n>th width, it is given 1/<ncol>th of the + screen. : tagrules The _tagrules_ file contains a list of