208 c->x = c->tx = wa->x; |
205 c->x = c->tx = wa->x; |
209 c->y = c->ty = wa->y; |
206 c->y = c->ty = wa->y; |
210 c->w = c->tw = wa->width; |
207 c->w = c->tw = wa->width; |
211 c->h = wa->height; |
208 c->h = wa->height; |
212 c->th = bh; |
209 c->th = bh; |
213 |
|
214 c->border = 0; |
210 c->border = 0; |
215 updatesize(c); |
211 updatesize(c); |
216 |
|
217 if(c->x + c->w + 2 * BORDERPX > sw) |
212 if(c->x + c->w + 2 * BORDERPX > sw) |
218 c->x = sw - c->w - 2 * BORDERPX; |
213 c->x = sw - c->w - 2 * BORDERPX; |
219 if(c->x < sx) |
214 if(c->x < sx) |
220 c->x = sx; |
215 c->x = sx; |
221 if(c->y + c->h + 2 * BORDERPX > sh) |
216 if(c->y + c->h + 2 * BORDERPX > sh) |
222 c->y = sh - c->h - 2 * BORDERPX; |
217 c->y = sh - c->h - 2 * BORDERPX; |
223 if(c->h != sh && c->y < bh) |
218 if(c->h != sh && c->y < bh) |
224 c->y = bh; |
219 c->y = bh; |
225 |
|
226 c->proto = getproto(c->win); |
220 c->proto = getproto(c->win); |
227 XSelectInput(dpy, c->win, |
221 XSelectInput(dpy, c->win, |
228 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); |
222 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); |
229 XGetTransientForHint(dpy, c->win, &trans); |
223 XGetTransientForHint(dpy, c->win, &trans); |
230 twa.override_redirect = 1; |
224 twa.override_redirect = 1; |
231 twa.background_pixmap = ParentRelative; |
225 twa.background_pixmap = ParentRelative; |
232 twa.event_mask = ExposureMask | EnterWindowMask; |
226 twa.event_mask = ExposureMask | EnterWindowMask; |
233 |
|
234 c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, |
227 c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, |
235 0, DefaultDepth(dpy, screen), CopyFromParent, |
228 0, DefaultDepth(dpy, screen), CopyFromParent, |
236 DefaultVisual(dpy, screen), |
229 DefaultVisual(dpy, screen), |
237 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); |
230 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); |
238 |
|
239 grabbuttons(c, False); |
231 grabbuttons(c, False); |
240 updatetitle(c); |
232 updatetitle(c); |
241 settags(c, getclient(trans)); |
233 settags(c, getclient(trans)); |
242 if(!c->isfloat) |
234 if(!c->isfloat) |
243 c->isfloat = trans |
235 c->isfloat = trans |
244 || (c->maxw && c->minw && |
236 || (c->maxw && c->minw && |
245 c->maxw == c->minw && c->maxh == c->minh); |
237 c->maxw == c->minw && c->maxh == c->minh); |
246 resizetitle(c); |
238 resizetitle(c); |
247 |
|
248 if(clients) |
239 if(clients) |
249 clients->prev = c; |
240 clients->prev = c; |
250 c->next = clients; |
241 c->next = clients; |
251 c->snext = stack; |
242 c->snext = stack; |
252 stack = clients = c; |
243 stack = clients = c; |
253 |
|
254 ban(c); |
244 ban(c); |
255 XMapWindow(dpy, c->win); |
245 XMapWindow(dpy, c->win); |
256 XMapWindow(dpy, c->twin); |
246 XMapWindow(dpy, c->twin); |
257 if(isvisible(c)) |
247 if(isvisible(c)) |
258 focus(c); |
248 focus(c); |
390 Client *nc; |
378 Client *nc; |
391 |
379 |
392 /* The server grab construct avoids race conditions. */ |
380 /* The server grab construct avoids race conditions. */ |
393 XGrabServer(dpy); |
381 XGrabServer(dpy); |
394 XSetErrorHandler(xerrordummy); |
382 XSetErrorHandler(xerrordummy); |
395 |
|
396 detach(c); |
383 detach(c); |
397 detachstack(c); |
384 detachstack(c); |
398 if(sel == c) { |
385 if(sel == c) { |
399 for(nc = stack; nc && !isvisible(nc); nc = nc->snext); |
386 for(nc = stack; nc && !isvisible(nc); nc = nc->snext); |
400 focus(nc); |
387 focus(nc); |
401 } |
388 } |
402 |
|
403 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
389 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
404 XDestroyWindow(dpy, c->twin); |
390 XDestroyWindow(dpy, c->twin); |
405 |
|
406 free(c->tags); |
391 free(c->tags); |
407 free(c); |
392 free(c); |
408 |
|
409 XSync(dpy, False); |
393 XSync(dpy, False); |
410 XSetErrorHandler(xerror); |
394 XSetErrorHandler(xerror); |
411 XUngrabServer(dpy); |
395 XUngrabServer(dpy); |
412 arrange(NULL); |
396 arrange(NULL); |
413 } |
397 } |