diff --git a/dwm/dwm.c b/dwm/dwm.c index 4465af1bf37d03ff16ae0726c55421ebc9ec75a9..c678e908e0d02eb55ee14d44ceae1a4525594bf3 100644 --- a/dwm/dwm.c +++ b/dwm/dwm.c @@ -92,7 +92,7 @@ struct Client { int basew, baseh, incw, inch, maxw, maxh, minw, minh; int bw, oldbw; unsigned int tags; - int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; + int isfixed, isfloating, canfocus, isurgent, neverfocus, oldstate, isfullscreen; Client *next; Client *snext; Monitor *mon; @@ -138,6 +138,7 @@ typedef struct { const char *title; unsigned int tags; int isfloating; + int canfocus; int monitor; } Rule; @@ -286,6 +287,7 @@ applyrules(Client *c) /* rule matching */ c->isfloating = 0; + c->canfocus = 1; c->tags = 0; XGetClassHint(dpy, c->win, &ch); class = ch.res_class ? ch.res_class : broken; @@ -298,6 +300,7 @@ applyrules(Client *c) && (!r->instance || strstr(instance, r->instance))) { c->isfloating = r->isfloating; + c->canfocus = r->canfocus; c->tags |= r->tags; for (m = mons; m && m->num != r->monitor; m = m->next); if (m) @@ -788,6 +791,8 @@ focus(Client *c) if (selmon->sel && selmon->sel != c) unfocus(selmon->sel, 0); if (c) { + if (!c->canfocus) + return; if (c->mon != selmon) selmon = c->mon; if (c->isurgent) @@ -837,16 +842,16 @@ focusstack(const Arg *arg) if (!selmon->sel) return; if (arg->i > 0) { - for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next); + for (c = selmon->sel->next; c && (!ISVISIBLE(c) || !c->canfocus); c = c->next); if (!c) - for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next); + for (c = selmon->clients; c && (!ISVISIBLE(c) || !c->canfocus); c = c->next); } else { for (i = selmon->clients; i != selmon->sel; i = i->next) - if (ISVISIBLE(i)) + if (ISVISIBLE(i) && i->canfocus) c = i; if (!c) for (; i; i = i->next) - if (ISVISIBLE(i)) + if (ISVISIBLE(i) && i->canfocus) c = i; } if (c) {