diff --git a/config.def.h b/config.def.h index bb60471..38f765a 100644 --- a/config.def.h +++ b/config.def.h @@ -20,9 +20,9 @@ static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", static unsigned int tagset[] = {1, 1}; /* after start, first tag is selected */ static Rule rules[] = { - /* class instance title tags mask isfloating */ - { "Gimp", NULL, NULL, 0, True }, - { "Firefox", NULL, NULL, 1 << 8, True }, + /* class instance title tags mask flags */ + { "Gimp", NULL, NULL, 0, Floating }, + { "Firefox", NULL, NULL, 1 << 8, Floating }, }; /* layout(s) */ diff --git a/dwm.c b/dwm.c index 77a91ac..fbdae45 100644 --- a/dwm.c +++ b/dwm.c @@ -45,6 +45,7 @@ #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) #define ISVISIBLE(x) (x->tags & tagset[seltags]) +#define ISFOCUSABLE(x) (ISVISIBLE(x) && !(x)->nofocus) #define LENGTH(x) (sizeof x / sizeof x[0]) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -62,6 +63,7 @@ enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */ enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ +enum { Normal, Floating, NoFocus }; /* flags */ typedef union { int i; @@ -86,7 +88,7 @@ struct Client { int basew, baseh, incw, inch, maxw, maxh, minw, minh; int bw, oldbw; unsigned int tags; - Bool isfixed, isfloating, isurgent; + Bool isfixed, isfloating, isurgent, nofocus; Client *next; Client *snext; Window win; @@ -124,7 +126,7 @@ typedef struct { const char *instance; const char *title; unsigned int tags; - Bool isfloating; + unsigned int flags; } Rule; /* function declarations */ @@ -268,7 +270,8 @@ applyrules(Client *c) { if((!r->title || strstr(c->name, r->title)) && (!r->class || (ch.res_class && strstr(ch.res_class, r->class))) && (!r->instance || (ch.res_name && strstr(ch.res_name, r->instance)))) { - c->isfloating = r->isfloating; + c->isfloating = r->flags & Floating; + c->nofocus = r->flags & NoFocus; c->tags |= r->tags & TAGMASK ? r->tags & TAGMASK : tagset[seltags]; } } @@ -614,8 +617,8 @@ expose(XEvent *e) { void focus(Client *c) { - if(!c || !ISVISIBLE(c)) - for(c = stack; c && !ISVISIBLE(c); c = c->snext); + if(!c || !ISFOCUSABLE(c)) + for(c = stack; c && !ISFOCUSABLE(c); c = c->snext); if(sel && sel != c) { grabbuttons(sel, False); XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]); @@ -650,17 +653,17 @@ focusstack(const Arg *arg) { if(!sel) return; if (arg->i > 0) { - for(c = sel->next; c && !ISVISIBLE(c); c = c->next); + for(c = sel->next; c && !ISFOCUSABLE(c); c = c->next); if(!c) - for(c = clients; c && !ISVISIBLE(c); c = c->next); + for(c = clients; c && !ISFOCUSABLE(c); c = c->next); } else { for(i = clients; i != sel; i = i->next) - if(ISVISIBLE(i)) + if(ISFOCUSABLE(i)) c = i; if(!c) for(; i; i = i->next) - if(ISVISIBLE(i)) + if(ISFOCUSABLE(i)) c = i; } if(c) {