[hackers] [wmii] Require that clients be given permission to activate themselves. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Fri, 11 Jun 2010 08:18:57 +0000 (UTC)

changeset: 2722:c3fa9a123147
tag: tip
user: Kris Maglione <kris_AT_suckless.org>
date: Fri Jun 11 04:18:40 2010 -0400
files: alternative_wmiircs/plan9port/wmiirc alternative_wmiircs/python/wmiirc.py cmd/wmii/client.c cmd/wmii/column.c cmd/wmii/dat.h cmd/wmii/debug.h cmd/wmii/ewmh.c cmd/wmii/fns.h cmd/wmii/main.c cmd/wmii/message.c cmd/wmii/rule.c include/stuff/util.h include/stuff/x11.h lib/libstuff/Makefile lib/libstuff/fmt/fmtbuf.c man/wmii.1 man/wmii.man1 rc/wmiirc.sh
description:
Require that clients be given permission to activate themselves.

diff -r 0b89c05b9de6 -r c3fa9a123147 alternative_wmiircs/plan9port/wmiirc
--- a/alternative_wmiircs/plan9port/wmiirc Thu Jun 10 19:49:17 2010 -0400
+++ b/alternative_wmiircs/plan9port/wmiirc Fri Jun 11 04:18:40 2010 -0400
@@ -47,8 +47,13 @@
 
 # Tagging Rules
 wmiir write /rules <<!
+ # Apps with system tray icons like to their main windows
+ # Give them permission.
+ /^Pidgin:/ allow=+activate
+
     # MPlayer and VLC don't float by default, but should.
     /MPlayer|VLC/ floating=on
+
     # ROX puts all of its windows in the same group, so they open
     # with the same tags. Disable grouping for ROX Filer.
     /^ROX-Filer:/ group=0
diff -r 0b89c05b9de6 -r c3fa9a123147 alternative_wmiircs/python/wmiirc.py
--- a/alternative_wmiircs/python/wmiirc.py Thu Jun 10 19:49:17 2010 -0400
+++ b/alternative_wmiircs/python/wmiirc.py Fri Jun 11 04:18:40 2010 -0400
@@ -60,11 +60,16 @@
     return wmii.cache['focuscolors'], datetime.datetime.now().strftime('%c')
 
 wmii.rules = (
+ # Apps with system tray icons like to their main windows
+ # Give them permission.
+ (ur'^Pidgin:' dict(allow='+activate')),
+
     # MPlayer and VLC don't float by default, but should.
- (ur'MPlayer|VLC', dict(floating=True)),
+ (ur'MPlayer|VLC', dict(floating=True)),
+
     # ROX puts all of its windows in the same group, so they open
     # with the same tags. Disable grouping for ROX Filer.
- (ur'^ROX-Filer:', dict(group=0)),
+ (ur'^ROX-Filer:', dict(group=0)),
 )
 
 def unresponsive_client(client):
diff -r 0b89c05b9de6 -r c3fa9a123147 cmd/wmii/client.c
--- a/cmd/wmii/client.c Thu Jun 10 19:49:17 2010 -0400
+++ b/cmd/wmii/client.c Fri Jun 11 04:18:40 2010 -0400
@@ -1111,103 +1111,58 @@
 bool
 client_applytags(Client *c, const char *tags) {
         Fmt fmt;
- uint i, j, k, n;
- bool add, found;
- char buf[512], last;
+ uint i, j, k;
+ char buf[512];
         char *toks[32];
         char **p;
         char *cur, *s;
+ int add, old;
 
         buf[0] = 0;
-
- for(n = 0; tags[n]; n++)
- if(!isspace(tags[n]))
- break;
-
- if(tags[n] == '+' || tags[n] == '-' || tags[n] == '\0')
+ if(memchr("+-^", tags[0], 4))
                 utflcpy(buf, c->tags, sizeof c->tags);
         else {
                 refree(&c->tagre);
                 refree(&c->tagvre);
         }
- strlcat(buf, &tags[n], sizeof buf);
-
- n = 0;
- add = true;
- if(buf[0] == '+')
- n++;
- else if(buf[0] == '-') {
- n++;
- add = false;
- }
-
- found = false;
+ strlcat(buf, tags, sizeof buf);
 
         j = 0;
- while(buf[n] && n < sizeof buf && j < 32) {
+ s = buf;
+ old = '+';
+ while((cur = mask(&s, &add, &old))) {
                 /* Check for regex. */
- if(buf[n] == '/') {
- for(i=n+1; i < sizeof buf - 1; i++)
- if(buf[i] == '/') break;
- if(buf[i] == '/') {
- i++;
- if(buf[i] == '+'
- || buf[i] == '-'
- || buf[i] == '\0') { /* Don't be lenient */
- buf[i-1] = '\0';
- if(add)
- reinit(&c->tagre, buf+n+1);
- else
- reinit(&c->tagvre, buf+n+1);
- last = buf[i];
- buf[i] = '\0';
+ if(cur[0] == '/') {
+ cur++;
+ *strchr(cur, '/') = '\0';
+ if(add == '+')
+ reinit(&c->tagre, cur);
+ else if(add == '-')
+ reinit(&c->tagvre, cur);
+ }
 
- found = true;
- goto next;
+ trim(cur, " \t\r\n");
+ if(!strcmp(cur, "~"))
+ c->floating = add ? On : Never;
+ else {
+ if(!strcmp(cur, "!") || !strcmp(cur, "sel"))
+ cur = selview->name;
+ else if(Mbsearch(cur, badtags, bsstrcmp))
+ continue;
+
+ if(j < nelem(toks)-1) {
+ if(add == '^')
+ add = bsearch(cur, toks, j, sizeof *toks, bsstrcmp) ? '-' : '+';
+ if(add == '+')
+ toks[j++] = cur;
+ else {
+ for(i = 0, k = 0; i < j; i++)
+ if(strcmp(toks[i], cur))
+ toks[k++] = toks[i];
+ j = k;
                                 }
                         }
                 }
-
- for(i = n; i < sizeof buf - 1; i++)
- if(buf[i] == '+'
- || buf[i] == '-'
- || buf[i] == '\0')
- break;
- last = buf[i];
- buf[i] = '\0';
-
- trim(buf+n, " \t/");
-
- cur = nil;
- if(!strcmp(buf+n, "~"))
- c->floating = add ? On : Never;
- else
- if(!strcmp(buf+n, "!") || !strcmp(buf+n, "sel"))
- cur = selview->name;
- else
- if(!Mbsearch(buf+n, badtags, bsstrcmp))
- cur = buf+n;
-
- if(cur && j < nelem(toks)-1) {
- if(add) {
- found = true;
- toks[j++] = cur;
- }else {
- for(i = 0, k = 0; i < j; i++)
- if(strcmp(toks[i], cur))
- toks[k++] = toks[i];
- j = k;
- }
- }
-
- next:
- n = i + 1;
- if(last == '+')
- add = true;
- if(last == '-')
- add = false;
- if(last == '\0')
- break;
         }
 
         toks[j] = nil;
@@ -1241,6 +1196,6 @@
         p = comm(~0, c->retags, toks);
         client_setviews(c, p);
         free(p);
- return found;
+ return true;
 }
 
diff -r 0b89c05b9de6 -r c3fa9a123147 cmd/wmii/column.c
--- a/cmd/wmii/column.c Thu Jun 10 19:49:17 2010 -0400
+++ b/cmd/wmii/column.c Fri Jun 11 04:18:40 2010 -0400
@@ -17,8 +17,8 @@
 
 bool
 column_setmode(Area *a, const char *mode) {
- char *str, *tok, *orig;
- char add, old;
+ char *str, *tok;
+ int add, old;
 
         /*
          * The mapping between the current internal
@@ -27,49 +27,36 @@
          * change.
          */
 
- orig = strdup(mode);
- str = orig;
- old = '\0';
- while(*(tok = str)) {
- add = old;
- while((old=*str) && !strchr("+-^", old))
- str++;
- *str = '\0';
- if(str > tok) {
- if(!strcmp(tok, "max")) {
- if(add == '\0' || add == '+')
- a->max = true;
- else if(add == '-')
- a->max = false;
- else
- a->max = !a->max;
- }else
- if(!strcmp(tok, "stack")) {
- if(add == '\0' || add == '+')
- a->mode = Colstack;
- else if(add == '-')
- a->mode = Coldefault;
- else
- a->mode = a->mode == Colstack ? Coldefault : Colstack;
- }else
- if(!strcmp(tok, "default")) {
- if(add == '\0' || add == '+') {
- a->mode = Coldefault;
- column_arrange(a, true);
- }else if(add == '-')
- a->mode = Colstack;
- else
- a->mode = a->mode == Coldefault ? Colstack : Coldefault;
- }else {
- free(orig);
- return false;
- }
- }
- if(old)
- str++;
-
+ str = freelater(estrdup(mode));
+ old = '+';
+ while((tok = mask(&str, &add, &old))) {
+ if(!strcmp(tok, "max")) {
+ if(add == '\0' || add == '+')
+ a->max = true;
+ else if(add == '-')
+ a->max = false;
+ else
+ a->max = !a->max;
+ }else
+ if(!strcmp(tok, "stack")) {
+ if(add == '\0' || add == '+')
+ a->mode = Colstack;
+ else if(add == '-')
+ a->mode = Coldefault;
+ else
+ a->mode = a->mode == Colstack ? Coldefault : Colstack;
+ }else
+ if(!strcmp(tok, "default")) {
+ if(add == '\0' || add == '+') {
+ a->mode = Coldefault;
+ column_arrange(a, true);
+ }else if(add == '-')
+ a->mode = Colstack;
+ else
+ a->mode = a->mode == Coldefault ? Colstack : Coldefault;
+ }else
+ return false;
         }
- free(orig);
         return true;
 }
 
diff -r 0b89c05b9de6 -r c3fa9a123147 cmd/wmii/dat.h
--- a/cmd/wmii/dat.h Thu Jun 10 19:49:17 2010 -0400
+++ b/cmd/wmii/dat.h Fri Jun 11 04:18:40 2010 -0400
@@ -43,6 +43,10 @@
         UrgClient,
 };
 
+enum ClientPermission {
+ PermActivate = 1<<0,
+};
+
 enum {
         SourceUnknown,
         SourceClient,
@@ -169,25 +173,26 @@
         Group* group;
         Strut* strut;
         Cursor cursor;
+ Rectangle configr;
         Rectangle r;
- Rectangle configr;
         char** retags;
+ char class[256];
         char name[256];
- char class[256];
+ char props[512];
         char tags[256];
- char props[512];
+ long permission;
         long proto;
- uint border;
+ int border;
+ int dead;
+ int floating;
+ int fullscreen;
         int pid;
- int dead;
- int fullscreen;
- int floating;
+ bool borderless;
         bool fixedsize;
- bool urgent;
- bool borderless;
- bool titleless;
         bool nofocus;
         bool noinput;
+ bool titleless;
+ bool urgent;
 };
 
 struct Divide {
diff -r 0b89c05b9de6 -r c3fa9a123147 cmd/wmii/debug.h
--- a/cmd/wmii/debug.h Thu Jun 10 19:49:17 2010 -0400
+++ b/cmd/wmii/debug.h Fri Jun 11 04:18:40 2010 -0400
@@ -20,5 +20,5 @@
 bool setdebug(int);
 void vdebug(int, const char*, va_list);
 
-int debugflag;
-int debugfile;
+long debugflag;
+long debugfile;
diff -r 0b89c05b9de6 -r c3fa9a123147 cmd/wmii/ewmh.c
--- a/cmd/wmii/ewmh.c Thu Jun 10 19:49:17 2010 -0400
+++ b/cmd/wmii/ewmh.c Fri Jun 11 04:18:40 2010 -0400
@@ -50,6 +50,8 @@
                 NET("WM_PID"),
                 NET("WM_STRUT"),
                 NET("WM_STRUT_PARTIAL"),
+ /* Set this so clients don't update Net("USER_TIME") */
+ NET("USER_TIME_WINDOW"),
                 /* States */
                 NET("WM_STATE"),
                 STATE("DEMANDS_ATTENTION"),
@@ -179,6 +181,25 @@
         free(c->strut);
 }
 
+#ifdef notdef
+static ulong
+usertime(Window *w) {
+ long *l;
+ long ret;
+
+ ret = 0;
+ if(getprop_long(w, Net("WM_USER_TIME_WINDOW"), "CARDINAL", 0, &l, 1)) {
+ w = window(*l);
+ free(l);
+ }
+ if(getprop_long(w, Net("WM_USER_TIME"), "CARDINAL", 0, &l, 1)) {
+ ret = *l;
+ free(l);
+ }
+ return ret;
+}
+#endif
+
 static bool
 event_client_clientmessage(Window *w, void *aux, XClientMessageEvent *e) {
         Client *c;
@@ -215,11 +236,13 @@
         if(msg == NET("ACTIVE_WINDOW")) {
                 if(e->format != 32)
                         return false;
+ Dprint(DEwmh, "\tsource: %uld\n", l[0]);
+ Dprint(DEwmh, "\ttimestamp: %,uld\n", l[1]);
+ Dprint(DEwmh, "\tactive: %#ulx\n", l[2]);
+ Dprint(DEwmh, "\twindow: %#ulx\n", e->window);
+ Dprint(DEwmh, "\tclient: %C\n", c);
 
- Dprint(DEwmh, "\tsource: %ld\n", l[0]);
- Dprint(DEwmh, "\twindow: %#ulx\n", e->window);
- Dprint(DEwmh, "\tclient: %C\n", c);
- if(l[0] == SourceClient && abs(event_xtime - l[1]) > 5000)
+ if(l[0] == SourceClient && !(c->permission & PermActivate))
                         return false;
                 if(l[0] == SourceClient || l[0] == SourcePager)
                         focus(c, true);
@@ -421,7 +444,9 @@
 
         l = (ulong*)e->data.l;
         msg = e->message_type;
- Dprint(DEwmh, "ClientMessage: %A\n", msg);
+ Debug(DEwmh)
+ if(msg != xatom("WM_PROTOCOLS") && l[0] != NET("WM_PING"))
+ Dprint(DEwmh, "ClientMessage: %A\n", msg);
 
         if(msg == NET("CURRENT_DESKTOP")) {
                 if(e->format != 32)
@@ -447,7 +472,6 @@
                         c->w.ewmh.lag = (c->w.ewmh.ping & 0xffffffff) - (l[1] & 0xffffffff);
                         if(i == false)
                                 frame_draw(c->sel);
- Dprint(DEwmh, "\twindow=%W lag=%,uld\n", &c->w, c->w.ewmh.lag);
                         return false;
                 }
                 return false;
diff -r 0b89c05b9de6 -r c3fa9a123147 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Thu Jun 10 19:49:17 2010 -0400
+++ b/cmd/wmii/fns.h Fri Jun 11 04:18:40 2010 -0400
@@ -203,12 +203,13 @@
 void spawn_command(const char*);
 
 /* message.c */
+char* mask(char**, int*, int*);
 char* message_client(Client*, IxpMsg*);
 char* message_root(void*, IxpMsg*);
 char* message_view(View*, IxpMsg*);
-char* msg_debug(IxpMsg*);
+void msg_debug(char*);
 void msg_eatrunes(IxpMsg*, int (*)(Rune), int);
-char* msg_getword(IxpMsg*);
+char* msg_getword(IxpMsg*, char*);
 void msg_parsecolors(IxpMsg*, CTuple*);
 char* msg_selectarea(Area*, IxpMsg*);
 char* msg_sendclient(View*, IxpMsg*, bool swap);
diff -r 0b89c05b9de6 -r c3fa9a123147 cmd/wmii/main.c
--- a/cmd/wmii/main.c Thu Jun 10 19:49:17 2010 -0400
+++ b/cmd/wmii/main.c Fri Jun 11 04:18:40 2010 -0400
@@ -330,9 +330,8 @@
 
 int
 main(int argc, char *argv[]) {
- IxpMsg m;
         char **oargv;
- char *wmiirc, *s;
+ char *wmiirc;
         int i;
 
         setlocale(LC_CTYPE, "");
@@ -356,9 +355,10 @@
                 lprint(1, "%s", version);
                 exit(0);
         case 'D':
- s = EARGF(usage());
- m = ixp_message(s, strlen(s), 0);
- msg_debug(&m);
+ if(waserror())
+ fatal("parsing debug flags: %r");
+ msg_debug(EARGF(usage()));
+ poperror();
                 break;
         default:
                 usage();
diff -r 0b89c05b9de6 -r c3fa9a123147 cmd/wmii/message.c
--- a/cmd/wmii/message.c Thu Jun 10 19:49:17 2010 -0400
+++ b/cmd/wmii/message.c Fri Jun 11 04:18:40 2010 -0400
@@ -24,6 +24,7 @@
 
 /* Edit |sort Edit |sed 's/"([^"]+)"/L\1/g' | tr 'a-z' 'A-Z' */
 enum {
+ LALLOW,
         LBAR,
         LBORDER,
         LCLIENT,
@@ -62,6 +63,7 @@
         LTILDE,
 };
 char *symtab[] = {
+ "allow",
         "bar",
         "border",
         "client",
@@ -100,6 +102,9 @@
         "~",
 };
 
+static char* barpostab[] = {
+ "bottom", "top",
+};
 char* debugtab[] = {
         "9p",
         "dnd",
@@ -108,16 +113,13 @@
         "focus",
         "generic",
         "stack",
+ nil
 };
-
-static char* barpostab[] = {
- "bottom",
- "top",
+static char* permtab[] = {
+ "activate", nil
 };
 static char* incmodetab[] = {
- "ignore",
- "show",
- "squeeze",
+ "ignore", "show", "squeeze",
 };
 static char* floatingtab[] = {
         "never", "off", "on", "always"
@@ -204,7 +206,7 @@
 getdirection(IxpMsg *m) {
         int i;
 
- switch(i = getsym(msg_getword(m))) {
+ switch(i = getsym(msg_getword(m, 0))) {
         case LLEFT:
         case LRIGHT:
         case LUP:
@@ -249,7 +251,7 @@
 }
 
 char*
-msg_getword(IxpMsg *m) {
+msg_getword(IxpMsg *m, char *errmsg) {
         char *ret;
         Rune r;
         int n;
@@ -271,8 +273,100 @@
                 if(ret[1] == '\\' || ret[1] == '#')
                         ret++;
         if(*ret == '\0')
+ ret = nil;
+ if(ret == nil && errmsg)
+ error(errmsg);
+ return ret;
+}
+
+typedef struct Mask Mask;
+struct Mask {
+ long* mask;
+ char** table;
+};
+
+static int
+Mfmt(Fmt *f) {
+ Mask m;
+ int i;
+
+ m = va_arg(f->args, Mask);
+ for(i=0; m.table[i]; i++)
+ if(*m.mask & (1<<i)) {
+ if(*m.mask & ((1<<i)-1))
+ fmtstrcpy(f, "+");
+ if(fmtstrcpy(f, m.table[i]))
+ return -1;
+ }
+ return 0;
+}
+
+char*
+mask(char **s, int *add, int *old) {
+ static char seps[] = "+-^";
+ char *p, *q;
+
+again:
+ p = *s;
+ if(*old == '\0')
                 return nil;
- return ret;
+ *add = *old;
+
+ if(*p == '/') {
+ /* Check for regex. */
+ if(!(q = strchr(p+1, '/')))
+ goto fail;
+ if(*q++ != '/' || !memchr(seps, (*old=*q), sizeof seps))
+ goto fail;
+ }
+ else {
+ for(q=p; (*old=*q) && !strchr(seps, *q);)
+ q++;
+ if(memchr(p, '/', q-p))
+ goto fail;
+ }
+
+ *q++ = '\0';
+ *s = q;
+ if(p + 1 == q)
+ goto again;
+ return p;
+fail:
+ while((*old=*q) && !strchr(seps, *q))
+ q++;
+ goto again;
+}
+
+static void
+unmask(Mask m, char *s) {
+ char *opt;
+ int add, old, i, n;
+ long newmask;
+
+ if(s == nil)
+ s = "";
+ for(n=0; m.table[n]; n++)
+ ;
+ newmask = memchr("+-^", s[0], 3) ? *m.mask : 0L;
+
+ old = '+';
+ while((opt = mask(&s, &add, &old))) {
+ i = _bsearch(opt, m.table, n);
+ if(i == -1)
+ error(Ebadvalue);
+ else if(add = '^')
+ newmask ^= 1<<i;
+ else if(add == '+')
+ newmask |= 1<<i;
+ else if(add == '-')
+ newmask &= ~(1<<i);
+ }
+ *m.mask = newmask;
+}
+
+void
+msg_debug(char *s) {
+ unmask((Mask){&debugflag, debugtab}, s);
 }
 
 static Client*
@@ -362,17 +456,17 @@
         char *s;
         ulong l;
 
- s = msg_getword(m);
- if(!s || !strcmp(s, "client"))
- f = client_viewframe(strclient(v, msg_getword(m)),
+ s = msg_getword(m, Ebadvalue);
+ if(!strcmp(s, "client"))
+ f = client_viewframe(strclient(v, msg_getword(m, Ebadvalue)),
                                      v);
         else {
                 /* XXX: Multihead */
                 a = strarea(v, scrn, s);
 
- s = msg_getword(m);
+ s = msg_getword(m, Ebadvalue);
                 f = nil;
- if(s && !strcmp(s, "sel"))
+ if(!strcmp(s, "sel"))
                         f = a->sel;
                 else {
                         l = msg_getulong(s);
@@ -389,6 +483,7 @@
 readctl_client(Client *c) {
         bufclear();
         bufprint("%#C\n", c);
+ bufprint("allow %M\n", (Mask){&c->permission, permtab});
         bufprint("floating %s\n", floatingtab[c->floating + 1]);
         if(c->fullscreen >= 0)
                 bufprint("fullscreen %d\n", c->fullscreen);
@@ -407,7 +502,7 @@
         char *s;
         long l;
 
- s = msg_getword(m);
+ s = msg_getword(m, Ebadcmd);
 
         /*
          * Toggle ::= on
@@ -423,11 +518,14 @@
          */
 
         switch(getsym(s)) {
+ case LALLOW:
+ unmask((Mask){&c->permission, permtab}, msg_getword(m, 0));
+ break;
         case LFLOATING:
- c->floating = -1 + _lsearch(msg_getword(m), floatingtab, nelem(floatingtab));
+ c->floating = -1 + _lsearch(msg_getword(m, Ebadvalue), floatingtab, nelem(floatingtab));
                 break;
         case LFULLSCREEN:
- s = msg_getword(m);
+ s = msg_getword(m, Ebadvalue);
                 if(getlong(s, &l))
                         fullscreen(c, On, l);
                 else
@@ -435,7 +533,7 @@
                 break;
         case LGROUP:
                 group_remove(c);
- c->w.hints->group = msg_getulong(msg_getword(m));
+ c->w.hints->group = msg_getulong(msg_getword(m, Ebadvalue));
                 if(c->w.hints->group)
                         group_init(c);
                 break;
@@ -449,7 +547,7 @@
                 client_applytags(c, m->pos);
                 break;
         case LURGENT:
- client_seturgent(c, gettoggle(msg_getword(m)), UrgManager);
+ client_seturgent(c, gettoggle(msg_getword(m, Ebadvalue)), UrgManager);
                 break;
         default:
                 error(Ebadcmd);
@@ -466,7 +564,7 @@
 
         USED(p);
         ret = nil;
- s = msg_getword(m);
+ s = msg_getword(m, 0);
         if(s == nil)
                 return nil;
 
@@ -477,21 +575,21 @@
 
         switch(getsym(s)) {
         case LBAR: /* bar on? <"top" | "bottom"> */
- s = msg_getword(m);
+ s = msg_getword(m, Ebadvalue);
                 if(!strcmp(s, "on"))
- s = msg_getword(m);
+ s = msg_getword(m, Ebadvalue);
                 setdef(&screen->barpos, s, barpostab, nelem(barpostab));
                 view_update(selview);
                 break;
         case LBORDER:
- def.border = msg_getulong(msg_getword(m));;
+ def.border = msg_getulong(msg_getword(m, 0));;
                 view_update(selview);
                 break;
         case LCOLMODE:
- setdef(&def.colmode, msg_getword(m), modes, Collast);
+ setdef(&def.colmode, msg_getword(m, 0), modes, Collast);
                 break;
         case LDEBUG:
- ret = msg_debug(m);
+ msg_debug(msg_getword(m, 0));
                 break;
         case LEXEC:
                 execstr = strdup(m->pos);
@@ -516,10 +614,10 @@
                 view_update(selview);
                 break;
         case LFONTPAD:
- if(!getint(msg_getword(m), &def.font->pad.min.x) ||
- !getint(msg_getword(m), &def.font->pad.max.x) ||
- !getint(msg_getword(m), &def.font->pad.max.y) ||
- !getint(msg_getword(m), &def.font->pad.min.y))
+ if(!getint(msg_getword(m, 0), &def.font->pad.min.x) ||
+ !getint(msg_getword(m, 0), &def.font->pad.max.x) ||
+ !getint(msg_getword(m, 0), &def.font->pad.max.y) ||
+ !getint(msg_getword(m, 0), &def.font->pad.min.y))
                         ret = "invalid rectangle";
                 else {
                         for(n=0; n < nscreens; n++)
@@ -528,7 +626,7 @@
                 }
                 break;
         case LGRABMOD:
- s = msg_getword(m);
+ s = msg_getword(m, Ebadvalue);
                 if(!parsekey(s, &i, nil) || i == 0)
                         return Ebadvalue;
 
@@ -536,7 +634,7 @@
                 def.mod = i;
                 break;
         case LINCMODE:
- setdef(&def.incmode, msg_getword(m), incmodetab, nelem(incmodetab));
+ setdef(&def.incmode, msg_getword(m, 0), incmodetab, nelem(incmodetab));
                 view_update(selview);
                 break;
         case LNORMCOLORS:
@@ -558,33 +656,17 @@
         return ret;
 }
 
-static void
-printdebug(int mask) {
- int i, j;
-
- for(i=0, j=0; i < nelem(debugtab); i++)
- if(mask & (1<<i)) {
- if(j++ > 0) bufprint(" ");
- bufprint("%s", debugtab[i]);
- }
-}
-
 char*
 readctl_root(void) {
+ fmtinstall('M', Mfmt);
         bufclear();
         bufprint("bar on %s\n", barpostab[screen->barpos]);
         bufprint("border %d\n", def.border);
         bufprint("colmode %s\n", modes[def.colmode]);
- if(debugflag) {
- bufprint("debug ");
- printdebug(debugflag);
- bufprint("\n");
- }
- if(debugfile) {
- bufprint("debugfile ");
- printdebug(debugfile);
- bufprint("\n");
- }
+ if(debugflag)
+ bufprint("debug %M\n", (Mask){&debugflag, debugtab});
+ if(debugfile)
+ bufprint("debugfile %M", (Mask){&debugfile, debugtab});
         bufprint("focuscolors %s\n", def.focuscolor.colstr);
         bufprint("font %s\n", def.font->name);
         bufprint("fontpad %d %d %d %d\n", def.font->pad.min.x, def.font->pad.max.x,
@@ -601,7 +683,7 @@
         Area *a;
         char *s;
 
- s = msg_getword(m);
+ s = msg_getword(m, 0);
         if(s == nil)
                 return nil;
 
@@ -648,11 +730,11 @@
 
         switch(getsym(s)) {
         case LCOLMODE:
- s = msg_getword(m);
+ s = msg_getword(m, Ebadvalue);
                 a = strarea(v, screen->idx, s);
 
- s = msg_getword(m);
- if(s == nil || !column_setmode(a, s))
+ s = msg_getword(m, Ebadvalue);
+ if(!column_setmode(a, s))
                         return Ebadvalue;
 
                 column_arrange(a, false);
@@ -699,38 +781,12 @@
         return buffer;
 }
 
-char*
-msg_debug(IxpMsg *m) {
- char *opt;
- int d;
- char add;
-
- bufclear();
- while((opt = msg_getword(m))) {
- add = '+';
- if(opt[0] == '+' || opt[0] == '-')
- add = *opt++;
- d = _bsearch(opt, debugtab, nelem(debugtab));
- if(d == -1) {
- bufprint(", %s", opt);
- continue;
- }
- if(add == '+')
- debugflag |= 1<<d;
- else
- debugflag &= ~(1<<d);
- }
- if(buffer[0] != '\0')
- return sxprint("Bad debug options: %s", buffer+2);
- return nil;
-}
-
 static void
 getamt(IxpMsg *m, Point *amt) {
         char *s, *p;
         long l;
 
- s = msg_getword(m);
+ s = msg_getword(m, 0);
         if(s) {
                 p = strend(s, 2);
                 if(!strcmp(p, "px")) {
@@ -863,7 +919,7 @@
         int sym;
 
         v = a->view;
- s = msg_getword(m);
+ s = msg_getword(m, Ebadvalue);
         sym = getsym(s);
 
         switch(sym) {
@@ -889,7 +945,8 @@
                 ap = strarea(v, a->screen, s);
                 if(ap->floating)
                         return Ebadvalue;
- if((s = msg_getword(m))) {
+
+ if((s = msg_getword(m, 0))) {
                         i = msg_getulong(s);
                         for(f = ap->frame; f; f = f->anext)
                                 if(--i == 0) break;
@@ -917,14 +974,14 @@
 
         stack = false;
         if(sym == LUP || sym == LDOWN)
- if((s = msg_getword(m)))
+ if((s = msg_getword(m, 0)))
                         if(!strcmp(s, "stack"))
                                 stack = true;
                         else
                                 return Ebadvalue;
 
         if(sym == LCLIENT) {
- s = msg_getword(m);
+ s = msg_getword(m, Ebadvalue);
                 i = msg_getulong(s);
                 c = win2client(i);
                 if(c == nil)
@@ -985,8 +1042,7 @@
         char *s;
         int sym;
 
- s = msg_getword(m);
- c = strclient(v, s);
+ c = strclient(v, msg_getword(m, 0));
         f = client_viewframe(c, v);
         if(f == nil)
                 return Ebadvalue;
@@ -994,7 +1050,7 @@
         a = f->area;
         to = nil;
 
- s = msg_getword(m);
+ s = msg_getword(m, Ebadvalue);
         sym = getsym(s);
 
         /* FIXME: Should use a helper function. */
diff -r 0b89c05b9de6 -r c3fa9a123147 cmd/wmii/rule.c
--- a/cmd/wmii/rule.c Thu Jun 10 19:49:17 2010 -0400
+++ b/cmd/wmii/rule.c Fri Jun 11 04:18:40 2010 -0400
@@ -88,7 +88,7 @@
         valuebuf.end = valuebuf.pos;
         valuebuf.pos = valuebuf.data;
         rvp = &r->values;
- while((w = msg_getword(&valuebuf))) {
+ while((w = msg_getword(&valuebuf, 0))) {
                 free(r->value);
                 r->value = estrdup(w);
                 if(strchr(w, '=')) {
diff -r 0b89c05b9de6 -r c3fa9a123147 include/stuff/util.h
--- a/include/stuff/util.h Thu Jun 10 19:49:17 2010 -0400
+++ b/include/stuff/util.h Fri Jun 11 04:18:40 2010 -0400
@@ -56,6 +56,7 @@
 char* estrdup(const char*);
 char* estrndup(const char*, uint);
 void fatal(const char*, ...);
+Fmt fmtbuf(char*, int);
 void* freelater(void*);
 int getbase(const char**, long*);
 bool getint(const char*, int*);
diff -r 0b89c05b9de6 -r c3fa9a123147 include/stuff/x11.h
--- a/include/stuff/x11.h Thu Jun 10 19:49:17 2010 -0400
+++ b/include/stuff/x11.h Fri Jun 11 04:18:40 2010 -0400
@@ -4,6 +4,7 @@
 #define Window XWindow
 #define Font XFont
 #define Screen XScreen
+#define Mask XMask
 #include <stuff/geom.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
@@ -16,6 +17,7 @@
 #undef Window
 #undef Font
 #undef Screen
+#undef Mask
 
 enum FontType {
         FX11 = 1,
diff -r 0b89c05b9de6 -r c3fa9a123147 lib/libstuff/Makefile
--- a/lib/libstuff/Makefile Thu Jun 10 19:49:17 2010 -0400
+++ b/lib/libstuff/Makefile Fri Jun 11 04:18:40 2010 -0400
@@ -36,6 +36,7 @@
         event/xtime \
         fmt/blprint \
         fmt/bvlprint \
+ fmt/fmtbuf \
         fmt/localefmt \
         fmt/localelen \
         fmt/lprint \
diff -r 0b89c05b9de6 -r c3fa9a123147 lib/libstuff/fmt/fmtbuf.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libstuff/fmt/fmtbuf.c Fri Jun 11 04:18:40 2010 -0400
@@ -0,0 +1,15 @@
+#include "fmtdef.h"
+
+Fmt
+fmtbuf(char *buf, int len) {
+ Fmt f;
+
+ f.runes = 0;
+ f.start = buf;
+ f.to = buf;
+ f.stop = buf + len - 1;
+ f.flush = 0;
+ f.farg = nil;
+ f.nfmt = 0;
+ return f;
+}
diff -r 0b89c05b9de6 -r c3fa9a123147 man/wmii.1
--- a/man/wmii.1 Thu Jun 10 19:49:17 2010 -0400
+++ b/man/wmii.1 Fri Jun 11 04:18:40 2010 -0400
@@ -384,9 +384,28 @@
 it:
 .RS 8
 .TP
-floating \fI<on | off | toggle>\fR
+allow \fI<flags>\fR
+The set of unusual actions the client is allowed to
+perform, in the same format as the tag set.
+.RS 8
+.TP
+activate
+The client is allowed to activate
+itself – that is, focus its window and,
+as the case may require, uncollapse it
+and select a tag it resides on. This
+flag must be set on a client if you wish
+it able to activate itself from the
+system tray.
+.RS -8
+.TP
+floating \fI<on | off | always | never>\fR
 Defines whether this client is likely to float when
-attached to a new view.
+attached to a new view. Ordinarilly, the value
+changes automatically whenever the window is
+moved between the floating and managed layers.
+However, setting a value of \fIalways\fR or \fInever\fR
+overrides this behavior.
 .TP
 fullscreen \fI<on | off | toggle>\fR
 Sets the client's fullscreen state.
@@ -428,11 +447,12 @@
 .TP
 tags
 Set or read a client's tags. Tags are separated by
-\fB+\fR or \fB\-\fR. Tags beginning with \fB+\fR are
-added, while those beginning with \fB\-\fR are removed.
-If the tag string written begins with \fB+\fR or
-\fB\-\fR, the written tags are added to or removed from
-the client's set, otherwise, the set is overwritten.
+\fB+\fR, \fB\-\fR, or \fB^\fR. Tags beginning with \fB+\fR are
+added, while those beginning with \fB\-\fR are removed and
+those beginning with \fB^\fR are toggled. If the tag
+string written begins with \fB+\fR, \fB^\fR, or \fB\-\fR, the
+written tags are added to or removed from the client's
+set, otherwise the set is overwritten.
 
 
 .SS The /tag/ Hierarchy
diff -r 0b89c05b9de6 -r c3fa9a123147 man/wmii.man1
--- a/man/wmii.man1 Thu Jun 10 19:49:17 2010 -0400
+++ b/man/wmii.man1 Fri Jun 11 04:18:40 2010 -0400
@@ -332,6 +332,19 @@
         of the client. The following commands may be written to
         it:
>>
+ : allow <flags>
+ The set of unusual actions the client is allowed to
+ perform, in the same format as the tag set.
+ >>
+ : activate
+ The client is allowed to activate
+ itself – that is, focus its window and,
+ as the case may require, uncollapse it
+ and select a tag it resides on. This
+ flag must be set on a client if you wish
+ it able to activate itself from the
+ system tray.
+ <<
         : floating <on | off | always | never>
                 Defines whether this client is likely to float when
                 attached to a new view. Ordinarilly, the value
@@ -370,11 +383,12 @@
         <instance>:<class>:<label>.
 : tags
         Set or read a client's tags. Tags are separated by
- **+** or **-**. Tags beginning with **+** are
- added, while those beginning with **-** are removed.
- If the tag string written begins with **+** or
- **-**, the written tags are added to or removed from
- the client's set, otherwise, the set is overwritten.
+ **+**, **-**, or **^**. Tags beginning with **+** are
+ added, while those beginning with **-** are removed and
+ those beginning with **^** are toggled. If the tag
+ string written begins with **+**, **^**, or **-**, the
+ written tags are added to or removed from the client's
+ set, otherwise the set is overwritten.
 :
 
 == The /tag/ Hierarchy ==
diff -r 0b89c05b9de6 -r c3fa9a123147 rc/wmiirc.sh
--- a/rc/wmiirc.sh Thu Jun 10 19:49:17 2010 -0400
+++ b/rc/wmiirc.sh Fri Jun 11 04:18:40 2010 -0400
@@ -25,18 +25,19 @@
 set -- $(echo $WMII_NORMCOLORS $WMII_FOCUSCOLORS)
 export WMII_TERM="@TERMINAL@"
 
-if ! test -d "${WMII_CONFPATH%%:*}"; then
- mkdir "${WMII_CONFPATH%%:*}"
- res=$(wihack -type DIALOG xmessage -nearmouse -buttons Windows,Alt -print -fn $WMII_FONT \
- "Welcome to wmii,$wi_newline$wi_newline" \
- "Most of wmii's default key bindings make use of the$wi_newline" \
- "Windows key, or equivalent. For keyboards lacking such$wi_newline" \
- "a key, many users change this to the Alt key.$wi_newline$wi_newline" \
- "Which would you prefer?")
- [ "$res" = "Alt" ] && MODKEY=Mod1
- echo "MODKEY=$MODKEY" >"${WMII_CONFPATH%%:*}/wmiirc_local"
- chmod +x "${WMII_CONFPATH%%:*}/wmiirc_local"
-fi
+# Ask about MODKEY on first run
+ if ! test -d "${WMII_CONFPATH%%:*}"; then
+ mkdir "${WMII_CONFPATH%%:*}"
+ res=$(wihack -type DIALOG xmessage -nearmouse -buttons Windows,Alt -print -fn $WMII_FONT \
+ "Welcome to wmii,$wi_newline$wi_newline" \
+ "Most of wmii's default key bindings make use of the$wi_newline" \
+ "Windows key, or equivalent. For keyboards lacking such$wi_newline" \
+ "a key, many users change this to the Alt key.$wi_newline$wi_newline" \
+ "Which would you prefer?")
+ [ "$res" = "Alt" ] && MODKEY=Mod1
+ echo "MODKEY=$MODKEY" >"${WMII_CONFPATH%%:*}/wmiirc_local"
+ chmod +x "${WMII_CONFPATH%%:*}/wmiirc_local"
+ fi
 
 # Menu history
 hist="${WMII_CONFPATH%%:*}/history"
@@ -50,8 +51,13 @@
 
 # Tagging Rules
 wmiir write /rules <<!
+ # Apps with system tray icons like to their main windows
+ # Give them permission.
+ /^Pidgin:/ allow=+activate
+
     # MPlayer and VLC don't float by default, but should.
     /MPlayer|VLC/ floating=on
+
     # ROX puts all of its windows in the same group, so they open
     # with the same tags. Disable grouping for ROX Filer.
     /^ROX-Filer:/ group=0
Received on Fri Jun 11 2010 - 08:18:57 UTC

This archive was generated by hypermail 2.2.0 : Fri Jun 11 2010 - 08:24:04 UTC