- c->border = (ev->value_mask & CWBorderWidth) ? ev->border_width : c->border;
- if((!c->isfloat && (arrange != dofloat))
- || ((ev->value_mask & (CWX | CWY)) && !(ev->value_mask & (CWWidth | CWHeight))))
- configure(c);
- else {
- c->x = (ev->value_mask & CWX) ? ev->x : c->x;
- c->y = (ev->value_mask & CWY) ? ev->y : c->y;
- c->w = (ev->value_mask & CWWidth) ? ev->width : c->w;
- c->h = (ev->value_mask & CWHeight) ? ev->height : c->h;
- resize(c, False);
- if(!isvisible(c))
- XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
+ if(ev->value_mask & CWBorderWidth)
+ c->border = ev->border_width;
+ if(c->isfixed || c->isfloating || isfloating()) {
+ if(ev->value_mask & CWX)
+ c->x = ev->x;
+ if(ev->value_mask & CWY)
+ c->y = ev->y;
+ if(ev->value_mask & CWWidth)
+ c->w = ev->width;
+ if(ev->value_mask & CWHeight)
+ c->h = ev->height;
+ if((c->x + c->w) > sw && c->isfloating)
+ c->x = sw / 2 - c->w / 2; /* center in x direction */
+ if((c->y + c->h) > sh && c->isfloating)
+ c->y = sh / 2 - c->h / 2; /* center in y direction */
+ if((ev->value_mask & (CWX | CWY))
+ && !(ev->value_mask & (CWWidth | CWHeight)))
+ configure(c);
+ if(isvisible(c))
+ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);