--- a/dwm.c 2012-01-20 23:32:23.717226400 +0200 +++ b/dwm.c 2012-01-20 23:32:23.720226400 +0200 @@ -90,7 +90,7 @@ struct Client { int basew, baseh, incw, inch, maxw, maxh, minw, minh; int bw, oldbw; unsigned int tags; - Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; + Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, iscentred; Client *next; Client *snext; Monitor *mon; @@ -161,6 +161,7 @@ typedef struct { const char *title; unsigned int tags; Bool isfloating; + Bool iscentred; int monitor; } Rule; @@ -325,6 +326,7 @@ applyrules(Client *c) { /* rule matching */ c->isfloating = c->tags = 0; + c->iscentred = 1; XGetClassHint(dpy, c->win, &ch); class = ch.res_class ? ch.res_class : broken; instance = ch.res_name ? ch.res_name : broken; @@ -336,6 +338,7 @@ applyrules(Client *c) { && (!r->instance || strstr(instance, r->instance))) { c->isfloating = r->isfloating; + c->iscentred = r->iscentred; c->tags |= r->tags; for(m = mons; m && m->num != r->monitor; m = m->next); if(m) @@ -1190,8 +1193,14 @@ manage(Window w, XWindowAttributes *wa) } } /* geometry */ - c->x = c->oldx = wa->x; - c->y = c->oldy = wa->y; + if((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && c->iscentred) { + c->x = c->oldx = c->mon->wx + (c->mon->ww / 2 - wa->width / 2); + c->y = c->oldy = c->mon->wy + (c->mon->wh / 2 - wa->height / 2); + } + else { + c->x = c->oldx = wa->x; + c->y = c->oldy = wa->y; + } c->w = c->oldw = wa->width; c->h = c->oldh = wa->height; c->oldbw = wa->border_width;