112 int i; |
112 int i; |
113 |
113 |
114 c->tw = 0; |
114 c->tw = 0; |
115 for(i = 0; i < TLast; i++) |
115 for(i = 0; i < TLast; i++) |
116 if(c->tags[i]) |
116 if(c->tags[i]) |
117 c->tw += textw(&brush.font, c->tags[i]) + bh; |
117 c->tw += textw(&brush.font, c->tags[i]) + brush.font.height; |
118 c->tw += textw(&brush.font, c->name) + bh; |
118 c->tw += textw(&brush.font, c->name) + brush.font.height; |
119 if(c->tw > c->w) |
119 if(c->tw > c->w) |
120 c->tw = c->w + 2; |
120 c->tw = c->w + 2; |
121 c->tx = c->x + c->w - c->tw + 2; |
121 c->tx = c->x + c->w - c->tw + 2; |
122 c->ty = c->y; |
122 c->ty = c->y; |
123 XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th); |
123 XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th); |
232 |
232 |
233 c = emallocz(sizeof(Client)); |
233 c = emallocz(sizeof(Client)); |
234 c->win = w; |
234 c->win = w; |
235 c->tx = c->x = wa->x; |
235 c->tx = c->x = wa->x; |
236 c->ty = c->y = wa->y; |
236 c->ty = c->y = wa->y; |
237 if(c->y < bh) |
|
238 c->ty = c->y += bh; |
|
239 c->tw = c->w = wa->width; |
237 c->tw = c->w = wa->width; |
240 c->h = wa->height; |
238 c->h = wa->height; |
241 c->th = bh; |
239 c->th = th; |
242 c->border = 1; |
240 c->border = 1; |
243 update_size(c); |
241 update_size(c); |
244 XSetWindowBorderWidth(dpy, c->win, 1); |
242 XSetWindowBorderWidth(dpy, c->win, 1); |
245 XSetWindowBorder(dpy, c->win, brush.border); |
243 XSetWindowBorder(dpy, c->win, brush.border); |
246 XSelectInput(dpy, c->win, |
244 XSelectInput(dpy, c->win, |
377 |
375 |
378 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
376 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
379 XDestroyWindow(dpy, c->title); |
377 XDestroyWindow(dpy, c->title); |
380 |
378 |
381 for(l=&clients; *l && *l != c; l=&(*l)->next); |
379 for(l=&clients; *l && *l != c; l=&(*l)->next); |
382 eassert(*l == c); |
|
383 *l = c->next; |
380 *l = c->next; |
384 for(l=&stack; *l && *l != c; l=&(*l)->snext); |
381 for(l=&stack; *l && *l != c; l=&(*l)->snext); |
385 eassert(*l == c); |
|
386 *l = c->snext; |
382 *l = c->snext; |
387 free(c); |
383 free(c); |
388 |
384 |
389 XFlush(dpy); |
385 XFlush(dpy); |
390 XSetErrorHandler(error_handler); |
386 XSetErrorHandler(error_handler); |
416 |
412 |
417 void |
413 void |
418 draw_client(Client *c) |
414 draw_client(Client *c) |
419 { |
415 { |
420 int i; |
416 int i; |
421 if(c == stack) { |
417 if(c == stack) |
422 draw_bar(); |
418 return; |
423 return; |
|
424 } |
|
425 |
419 |
426 brush.x = brush.y = 0; |
420 brush.x = brush.y = 0; |
427 brush.h = c->th; |
421 brush.h = c->th; |
428 |
422 |
429 brush.w = 0; |
423 brush.w = 0; |
430 for(i = 0; i < TLast; i++) { |
424 for(i = 0; i < TLast; i++) { |
431 if(c->tags[i]) { |
425 if(c->tags[i]) { |
432 brush.x += brush.w; |
426 brush.x += brush.w; |
433 brush.w = textw(&brush.font, c->tags[i]) + bh; |
427 brush.w = textw(&brush.font, c->tags[i]) + brush.font.height; |
434 draw(dpy, &brush, True, c->tags[i]); |
428 draw(dpy, &brush, True, c->tags[i]); |
435 } |
429 } |
436 } |
430 } |
437 brush.x += brush.w; |
431 brush.x += brush.w; |
438 brush.w = textw(&brush.font, c->name) + bh; |
432 brush.w = textw(&brush.font, c->name) + brush.font.height; |
439 draw(dpy, &brush, True, c->name); |
433 draw(dpy, &brush, True, c->name); |
440 XCopyArea(dpy, brush.drawable, c->title, brush.gc, |
434 XCopyArea(dpy, brush.drawable, c->title, brush.gc, |
441 0, 0, c->tw, c->th, 0, 0); |
435 0, 0, c->tw, c->th, 0, 0); |
442 XFlush(dpy); |
436 XFlush(dpy); |
443 } |
437 } |