--- dwm.c.orig 2008-09-28 11:04:51.051974392 +0200 +++ dwm.c 2008-09-29 09:00:37.980516502 +0200 @@ -83,6 +83,7 @@ typedef struct Client Client; struct Client { char name[256]; + char label; float mina, maxa; int x, y, w, h; int basew, baseh, incw, inch, maxw, maxh, minw, minh; @@ -168,6 +169,9 @@ static void maprequest(XEvent *e); static void monocle(void); static void movemouse(const Arg *arg); +static void labelset(const Arg *arg); +static void labelfocus(const Arg *arg); +static int xgetc(void); static Client *nexttiled(Client *c); static void propertynotify(XEvent *e); static void quit(const Arg *arg); @@ -985,6 +989,51 @@ XUngrabPointer(dpy, CurrentTime); } +void +labelset(const Arg *arg) +{ + if( sel ) + sel->label = xgetc(); +} + +void +labelfocus(const Arg *arg) +{ + Client *c; + char l; + + if( ! sel ) + return; + + l = xgetc(); + + for(c = clients; c; c = c->next) + if( c->label == l ) + break; + + if(c) { + focus(c); + restack(); + } +} + +int +xgetc(void) +{ + XEvent ev; + KeySym keysym; + XComposeStatus status; + char ch[2] = { 0 }; + + XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime); + XMaskEvent(dpy, KeyPressMask, &ev); + XLookupString((XKeyEvent *)&ev, ch, 1, &keysym, &status); + XUngrabKeyboard(dpy, CurrentTime); + + return *ch; +} + + Client * nexttiled(Client *c) { for(; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);