+ if(c->x + c->w + 2 > sw)
+ c->x = sw - c->w - 2;
+ if(c->x < 0)
+ c->x = 0;
+ if(c->y + c->h + 2 > sh)
+ c->y = sh - c->h - 2;
+ if(c->h != sh && c->y < bh)
+ c->y = bh;
+
+ c->proto = getproto(c->win);
+ XSelectInput(dpy, c->win,
+ StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
+ XGetTransientForHint(dpy, c->win, &trans);
+ twa.override_redirect = 1;
+ twa.background_pixmap = ParentRelative;
+ twa.event_mask = ExposureMask | EnterWindowMask;
+
+ c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
+ 0, DefaultDepth(dpy, screen), CopyFromParent,
+ DefaultVisual(dpy, screen),
+ CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
+
+ if(clients)
+ clients->prev = c;
+ c->next = clients;
+ clients = c;
+
+ grabbutton(c, Button1, MODKEY);
+ grabbutton(c, Button2, MODKEY);
+ grabbutton(c, Button3, MODKEY);
+
+ if((tc = getclient(trans))) /* inherit tags */
+ for(i = 0; i < ntags; i++)
+ c->tags[i] = tc->tags[i];
+ else
+ settags(c);
+ if(!c->isfloat)
+ c->isfloat = trans
+ || (c->maxw && c->minw &&
+ c->maxw == c->minw && c->maxh == c->minh);
+ settitle(c);
+ if(isvisible(c))
+ sel = c;
+ arrange(NULL);
+ XMapWindow(dpy, c->win);
+ XMapWindow(dpy, c->twin);
+ if(isvisible(c))
+ focus(c);