--- dwm/dwm.c 2012-01-15 15:29:38.925066911 +0100 +++ dwm-active-focus/dwm.c 2012-01-15 19:08:57.311520877 +0100 @@ -1109,6 +1109,7 @@ void manage(Window w, XWindowAttributes *wa) { + Arg arg; Client *c, *t = NULL; Window trans = None; XWindowChanges wc; @@ -1159,11 +1160,20 @@ attachstack(c); XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */ setclientstate(c, NormalState); - if (c->mon == selmon) - unfocus(selmon->sel, False); + XMapWindow(dpy, c->win); c->mon->sel = c; + if (c->mon == selmon) { + unfocus(selmon->sel, False); + if((selmon->tagset[selmon->seltags] & c->tags) == 0) + for(arg.ui = 0; arg.ui < LENGTH(tags); arg.ui++) + if(c->tags & (1 << arg.ui)) { + // view the first tag where c is visible on + arg.ui = (1 << arg.ui); + view(&arg); + return; + } + } arrange(c->mon); - XMapWindow(dpy, c->win); focus(NULL); }