diff --git a/dwm/config.def.h b/dwm/config.def.h index 09a04f143050f5718944f39eb612e252f85de19c..c7294f880b099d94f8880074f6717befc1491f81 100644 --- a/dwm/config.def.h +++ b/dwm/config.def.h @@ -26,10 +26,11 @@ static const Rule rules[] = { * WM_CLASS(STRING) = instance, class * WM_NAME(STRING) = title */ - /* class instance title tags mask isfloating monitor */ - { "Gimp", NULL, NULL, 0, 1, -1 }, - { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, - { "Avizo-service", NULL, NULL, 0, 1, -1 } + /* class instance title tags mask iscentered isfloating canfocus monitor */ + { "Gimp", NULL, NULL, 0, 1, 1, 1, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 1, 0, 1, -1 }, + { "Avizo-service", NULL, NULL, 0, 1, 1, 0, -1 }, + { "jetbrains-pycharm", NULL, NULL, 0, 1, 1, 1, -1 } }; /* layout(s) */ diff --git a/dwm/dwm.c b/dwm/dwm.c index 5a562a53a15c8e6605e67ab10f0231e84f3ea4d8..ee41c162c19068bc4dfc9d2feecb1ae5a3b60b1e 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, iscentered, canfocus, isfloating, isurgent, neverfocus, oldstate, isfullscreen; Client *next; Client *snext; Monitor *mon; @@ -137,7 +137,9 @@ typedef struct { const char *instance; const char *title; unsigned int tags; + int iscentered; int isfloating; + int canfocus; int monitor; } Rule; @@ -287,7 +289,9 @@ applyrules(Client *c) XClassHint ch = { NULL, NULL }; /* rule matching */ + c->iscentered = 0; c->isfloating = 0; + c->canfocus = 1; c->tags = 0; XGetClassHint(dpy, c->win, &ch); class = ch.res_class ? ch.res_class : broken; @@ -299,7 +303,9 @@ applyrules(Client *c) && (!r->class || strstr(class, r->class)) && (!r->instance || strstr(instance, r->instance))) { + c->iscentered = r->iscentered; 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) @@ -790,6 +796,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) @@ -797,7 +805,9 @@ focus(Client *c) detachstack(c); attachstack(c); grabbuttons(c, 1); - XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); + if (!c->iscentered){ + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); + } setfocus(c); } else { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); @@ -839,16 +849,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) { @@ -1053,11 +1063,17 @@ manage(Window w, XWindowAttributes *wa) wc.border_width = c->bw; XConfigureWindow(dpy, w, CWBorderWidth, &wc); - XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); + if (!c->iscentered){ + XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); + } configure(c); /* propagates border_width, if size doesn't change */ updatewindowtype(c); updatesizehints(c); updatewmhints(c); + if (c->iscentered) { + c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2; + c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2; + } XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); grabbuttons(c, 0); if (!c->isfloating) @@ -1754,7 +1770,9 @@ unfocus(Client *c, int setfocus) if (!c) return; grabbuttons(c, 0); - XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel); + if (!c->iscentered){ + XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel); + } if (setfocus) { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XDeleteProperty(dpy, root, netatom[NetActiveWindow]); @@ -2011,8 +2029,10 @@ updatewindowtype(Client *c) if (state == netatom[NetWMFullscreen]) setfullscreen(c, 1); - if (wtype == netatom[NetWMWindowTypeDialog]) + if (wtype == netatom[NetWMWindowTypeDialog]) { + c->iscentered = 1; c->isfloating = 1; + } } void