[hackers] [wmii] Allow colrules to be specified in pixels. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Sat, 22 May 2010 15:16:19 +0000 (UTC)

changeset: 2620:56a90284a595
tag: tip
user: Kris Maglione <kris_AT_suckless.org>
date: Sat May 22 11:15:57 2010 -0400
files: cmd/wmii/area.c cmd/wmii/client.c cmd/wmii/event.c cmd/wmii/ewmh.c cmd/wmii/fns.h cmd/wmii/frame.c cmd/wmii/fs.c cmd/wmii/message.c cmd/wmii/view.c doc/wmii.tex man/wmii.1 man/wmii.man1
description:
Allow colrules to be specified in pixels.

diff -r ebbfca4f7874 -r 56a90284a595 cmd/wmii/area.c
--- a/cmd/wmii/area.c Fri May 21 22:52:47 2010 -0400
+++ b/cmd/wmii/area.c Sat May 22 11:15:57 2010 -0400
@@ -85,16 +85,15 @@
         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 -r ebbfca4f7874 -r 56a90284a595 cmd/wmii/client.c
--- a/cmd/wmii/client.c Fri May 21 22:52:47 2010 -0400
+++ b/cmd/wmii/client.c Sat May 22 11:15:57 2010 -0400
@@ -191,7 +191,7 @@
 
         ewmh_initclient(c);
 
- event("CreateClient %C\n", c);
+ event("CreateClient %#C\n", c);
         client_manage(c);
         return c;
 }
@@ -312,7 +312,7 @@
         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 @@
 
         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 @@
         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 @@
         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 @@
         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 @@
         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 @@
         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 -r ebbfca4f7874 -r 56a90284a595 cmd/wmii/event.c
--- a/cmd/wmii/event.c Fri May 21 22:52:47 2010 -0400
+++ b/cmd/wmii/event.c Sat May 22 11:15:57 2010 -0400
@@ -56,8 +56,8 @@
 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 -r ebbfca4f7874 -r 56a90284a595 cmd/wmii/ewmh.c
--- a/cmd/wmii/ewmh.c Fri May 21 22:52:47 2010 -0400
+++ b/cmd/wmii/ewmh.c Sat May 22 11:15:57 2010 -0400
@@ -139,7 +139,7 @@
         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 @@
 
         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 @@
                         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 @@
         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 @@
                 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 @@
                         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 -r ebbfca4f7874 -r 56a90284a595 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Fri May 21 22:52:47 2010 -0400
+++ b/cmd/wmii/fns.h Sat May 22 11:15:57 2010 -0400
@@ -88,7 +88,6 @@
 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 @@
 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 -r ebbfca4f7874 -r 56a90284a595 cmd/wmii/frame.c
--- a/cmd/wmii/frame.c Fri May 21 22:52:47 2010 -0400
+++ b/cmd/wmii/frame.c Sat May 22 11:15:57 2010 -0400
@@ -145,7 +145,7 @@
                 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 @@
                         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 @@
         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 @@
         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 -r ebbfca4f7874 -r 56a90284a595 cmd/wmii/fs.c
--- a/cmd/wmii/fs.c Fri May 21 22:52:47 2010 -0400
+++ b/cmd/wmii/fs.c Sat May 22 11:15:57 2010 -0400
@@ -263,7 +263,7 @@
                                 }
                                 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 -r ebbfca4f7874 -r 56a90284a595 cmd/wmii/message.c
--- a/cmd/wmii/message.c Fri May 21 22:52:47 2010 -0400
+++ b/cmd/wmii/message.c Sat May 22 11:15:57 2010 -0400
@@ -338,7 +338,7 @@
 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 @@
 
         /* 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 -r ebbfca4f7874 -r 56a90284a595 cmd/wmii/view.c
--- a/cmd/wmii/view.c Fri May 21 22:52:47 2010 -0400
+++ b/cmd/wmii/view.c Sat May 22 11:15:57 2010 -0400
@@ -592,19 +592,26 @@
 }
 
 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 @@
                 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 -r ebbfca4f7874 -r 56a90284a595 doc/wmii.tex
--- a/doc/wmii.tex Fri May 21 22:52:47 2010 -0400
+++ b/doc/wmii.tex Sat May 22 11:15:57 2010 -0400
@@ -1221,11 +1221,16 @@
           /‹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 -r ebbfca4f7874 -r 56a90284a595 man/wmii.1
--- a/man/wmii.1 Fri May 21 22:52:47 2010 -0400
+++ b/man/wmii.1 Sat May 22 11:15:57 2010 -0400
@@ -272,11 +272,17 @@
 .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 -r ebbfca4f7874 -r 56a90284a595 man/wmii.man1
--- a/man/wmii.man1 Fri May 21 22:52:47 2010 -0400
+++ b/man/wmii.man1 Sat May 22 11:15:57 2010 -0400
@@ -243,11 +243,14 @@
 
 ``` /<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
Received on Sat May 22 2010 - 15:16:19 UTC

This archive was generated by hypermail 2.2.0 : Sat May 22 2010 - 15:24:04 UTC