diff --git a/dwm/config.def.h b/dwm/config.def.h index 6ba495703e7b02b31d60beb313637ca1d45ad658..f139661f178d129e41756dbd4b58e016b2f14fd3 100644 --- a/dwm/config.def.h +++ b/dwm/config.def.h @@ -26,10 +26,10 @@ 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 } }; /* layout(s) */ diff --git a/dwm/dwm.c b/dwm/dwm.c index c678e908e0d02eb55ee14d44ceae1a4525594bf3..ba0efb4d1bffb57ed3b5e3b89edac254c611f711 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, canfocus, isurgent, neverfocus, oldstate, isfullscreen; + int isfixed, iscentered, canfocus, isfloating, isurgent, neverfocus, oldstate, isfullscreen; Client *next; Client *snext; Monitor *mon; @@ -137,8 +137,9 @@ typedef struct { const char *instance; const char *title; unsigned int tags; + int iscentered; int isfloating; - int canfocus; + int canfocus; int monitor; } Rule; @@ -286,6 +287,7 @@ applyrules(Client *c) XClassHint ch = { NULL, NULL }; /* rule matching */ + c->iscentered = 0; c->isfloating = 0; c->canfocus = 1; c->tags = 0; @@ -299,6 +301,7 @@ 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; @@ -800,7 +803,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); @@ -1056,11 +1061,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) @@ -1757,7 +1768,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]); @@ -2014,8 +2027,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