dwm-meillo

annotate client.c @ 51:035617ee18d1

new stuff
author Anselm R. Garbe <garbeam@wmii.de>
date Thu, 13 Jul 2006 19:55:07 +0200
parents 148f25ed0ad7
children d18f6dd0cf23
rev   line source
garbeam@5 1 /*
garbeam@5 2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
garbeam@5 3 * See LICENSE file for license details.
garbeam@5 4 */
garbeam@5 5
garbeam@10 6 #include <stdlib.h>
garbeam@51 7 #include <stdio.h>
garbeam@5 8 #include <string.h>
garbeam@5 9 #include <X11/Xatom.h>
garbeam@32 10 #include <X11/Xutil.h>
garbeam@5 11
garbeam@43 12 #include "dwm.h"
garbeam@5 13
garbeam@51 14 static void (*arrange)(Arg *) = tiling;
garbeam@49 15
garbeam@51 16 static Rule rule[] = {
garbeam@51 17 { "Firefox-bin", "Gecko", { [Twww] = "www" } },
garbeam@51 18 };
garbeam@50 19
garbeam@49 20 static Client *
garbeam@49 21 next(Client *c)
garbeam@49 22 {
garbeam@50 23 for(; c && !c->tags[tsel]; c = c->next);
garbeam@49 24 return c;
garbeam@49 25 }
garbeam@49 26
garbeam@50 27 void
garbeam@50 28 zoom(Arg *arg)
garbeam@49 29 {
garbeam@51 30 Client **l, *old;
garbeam@50 31
garbeam@51 32 if(!(old = sel))
garbeam@50 33 return;
garbeam@50 34
garbeam@50 35 for(l = &clients; *l && *l != sel; l = &(*l)->next);
garbeam@50 36 *l = sel->next;
garbeam@50 37
garbeam@51 38 old->next = clients; /* pop */
garbeam@51 39 clients = old;
garbeam@51 40 sel = old;
garbeam@50 41 arrange(NULL);
garbeam@50 42 focus(sel);
garbeam@49 43 }
garbeam@31 44
garbeam@27 45 void
garbeam@49 46 max(Arg *arg)
garbeam@28 47 {
garbeam@50 48 if(!sel)
garbeam@28 49 return;
garbeam@50 50 sel->x = sx;
garbeam@50 51 sel->y = sy;
garbeam@50 52 sel->w = sw - 2 * sel->border;
garbeam@50 53 sel->h = sh - 2 * sel->border;
garbeam@50 54 craise(sel);
garbeam@50 55 resize(sel);
garbeam@29 56 discard_events(EnterWindowMask);
garbeam@28 57 }
garbeam@28 58
garbeam@46 59 void
garbeam@50 60 view(Arg *arg)
garbeam@50 61 {
garbeam@50 62 tsel = arg->i;
garbeam@50 63 arrange(NULL);
garbeam@50 64 }
garbeam@50 65
garbeam@50 66 void
garbeam@49 67 tag(Arg *arg)
garbeam@49 68 {
garbeam@50 69 int i, n;
garbeam@50 70 if(!sel)
garbeam@49 71 return;
garbeam@49 72
garbeam@50 73 if(arg->i == tsel) {
garbeam@50 74 for(n = i = 0; i < TLast; i++)
garbeam@50 75 if(sel->tags[i])
garbeam@50 76 n++;
garbeam@50 77 if(n < 2)
garbeam@50 78 return;
garbeam@50 79 }
garbeam@49 80
garbeam@50 81 if(sel->tags[arg->i])
garbeam@50 82 sel->tags[arg->i] = NULL; /* toggle tag */
garbeam@49 83 else
garbeam@50 84 sel->tags[arg->i] = tags[arg->i];
garbeam@49 85 arrange(NULL);
garbeam@49 86 }
garbeam@49 87
garbeam@50 88 static void
garbeam@50 89 ban_client(Client *c)
garbeam@50 90 {
garbeam@50 91 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
garbeam@50 92 XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty);
garbeam@50 93 }
garbeam@50 94
garbeam@49 95 void
garbeam@49 96 floating(Arg *arg)
garbeam@31 97 {
garbeam@31 98 Client *c;
garbeam@31 99
garbeam@46 100 arrange = floating;
garbeam@50 101 for(c = clients; c; c = c->next) {
garbeam@50 102 if(c->tags[tsel])
garbeam@50 103 resize(c);
garbeam@50 104 else
garbeam@50 105 ban_client(c);
garbeam@50 106 }
garbeam@50 107 if(sel && !sel->tags[tsel]) {
garbeam@50 108 if((sel = next(clients))) {
garbeam@50 109 craise(sel);
garbeam@50 110 focus(sel);
garbeam@50 111 }
garbeam@50 112 }
garbeam@31 113 discard_events(EnterWindowMask);
garbeam@31 114 }
garbeam@31 115
garbeam@46 116 void
garbeam@49 117 tiling(Arg *arg)
garbeam@27 118 {
garbeam@27 119 Client *c;
garbeam@51 120 int n, i, w, h;
garbeam@27 121
garbeam@51 122 w = sw - mw;
garbeam@46 123 arrange = tiling;
garbeam@51 124 for(n = 0, c = clients; c; c = c->next)
garbeam@51 125 if(c->tags[tsel])
garbeam@51 126 n++;
garbeam@50 127
garbeam@51 128 h = (n > 2) ? sh / (n - 2) : sh;
garbeam@27 129
garbeam@51 130 for(i = 0, c = clients; c; c = c->next) {
garbeam@50 131 if(c->tags[tsel]) {
garbeam@51 132 if(n == 1) {
garbeam@51 133 c->x = sx;
garbeam@51 134 c->y = sy;
garbeam@51 135 c->w = sw;
garbeam@51 136 c->h = sh;
garbeam@51 137 }
garbeam@51 138 else if(i == 1) {
garbeam@51 139 c->x = sx;
garbeam@51 140 c->y = sy;
garbeam@51 141 c->w = mw;
garbeam@51 142 c->h = sh;
garbeam@51 143 }
garbeam@51 144 else {
garbeam@51 145 c->x = sx + mw;
garbeam@51 146 c->y = sy + (i - 2) * h;
garbeam@51 147 c->w = w;
garbeam@51 148 c->h = h;
garbeam@51 149 }
garbeam@50 150 resize(c);
garbeam@51 151 i++;
garbeam@50 152 }
garbeam@50 153 else
garbeam@50 154 ban_client(c);
garbeam@50 155 }
garbeam@50 156 if(sel && !sel->tags[tsel]) {
garbeam@50 157 if((sel = next(clients))) {
garbeam@50 158 craise(sel);
garbeam@50 159 focus(sel);
garbeam@27 160 }
garbeam@27 161 }
garbeam@29 162 discard_events(EnterWindowMask);
garbeam@27 163 }
garbeam@27 164
garbeam@27 165 void
garbeam@49 166 prevc(Arg *arg)
garbeam@27 167 {
garbeam@49 168 Client *c;
garbeam@27 169
garbeam@50 170 if(!sel)
garbeam@27 171 return;
garbeam@49 172
garbeam@50 173 if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
garbeam@49 174 craise(c);
garbeam@49 175 focus(c);
garbeam@49 176 }
garbeam@27 177 }
garbeam@27 178
garbeam@27 179 void
garbeam@49 180 nextc(Arg *arg)
garbeam@27 181 {
garbeam@49 182 Client *c;
garbeam@49 183
garbeam@50 184 if(!sel)
garbeam@49 185 return;
garbeam@49 186
garbeam@50 187 if(!(c = next(sel->next)))
garbeam@50 188 c = next(clients);
garbeam@49 189 if(c) {
garbeam@49 190 craise(c);
garbeam@50 191 c->revert = sel;
garbeam@49 192 focus(c);
garbeam@49 193 }
garbeam@49 194 }
garbeam@49 195
garbeam@49 196 void
garbeam@49 197 ckill(Arg *arg)
garbeam@49 198 {
garbeam@50 199 if(!sel)
garbeam@27 200 return;
garbeam@50 201 if(sel->proto & WM_PROTOCOL_DELWIN)
garbeam@50 202 send_message(sel->win, wm_atom[WMProtocols], wm_atom[WMDelete]);
garbeam@27 203 else
garbeam@50 204 XKillClient(dpy, sel->win);
garbeam@27 205 }
garbeam@27 206
garbeam@26 207 static void
garbeam@26 208 resize_title(Client *c)
garbeam@26 209 {
garbeam@31 210 int i;
garbeam@31 211
garbeam@31 212 c->tw = 0;
garbeam@31 213 for(i = 0; i < TLast; i++)
garbeam@31 214 if(c->tags[i])
garbeam@43 215 c->tw += textw(c->tags[i]) + dc.font.height;
garbeam@43 216 c->tw += textw(c->name) + dc.font.height;
garbeam@26 217 if(c->tw > c->w)
garbeam@26 218 c->tw = c->w + 2;
garbeam@26 219 c->tx = c->x + c->w - c->tw + 2;
garbeam@26 220 c->ty = c->y;
garbeam@26 221 XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th);
garbeam@26 222 }
garbeam@18 223
garbeam@13 224 void
garbeam@13 225 update_name(Client *c)
garbeam@5 226 {
garbeam@5 227 XTextProperty name;
garbeam@5 228 int n;
garbeam@7 229 char **list = NULL;
garbeam@5 230
garbeam@5 231 name.nitems = 0;
garbeam@5 232 c->name[0] = 0;
garbeam@5 233 XGetTextProperty(dpy, c->win, &name, net_atom[NetWMName]);
garbeam@5 234 if(!name.nitems)
garbeam@5 235 XGetWMName(dpy, c->win, &name);
garbeam@5 236 if(!name.nitems)
garbeam@5 237 return;
garbeam@5 238 if(name.encoding == XA_STRING)
garbeam@5 239 strncpy(c->name, (char *)name.value, sizeof(c->name));
garbeam@5 240 else {
garbeam@5 241 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
garbeam@5 242 && n > 0 && *list)
garbeam@5 243 {
garbeam@5 244 strncpy(c->name, *list, sizeof(c->name));
garbeam@5 245 XFreeStringList(list);
garbeam@5 246 }
garbeam@5 247 }
garbeam@5 248 XFree(name.value);
garbeam@26 249 resize_title(c);
garbeam@5 250 }
garbeam@5 251
garbeam@10 252 void
garbeam@20 253 update_size(Client *c)
garbeam@20 254 {
garbeam@20 255 XSizeHints size;
garbeam@20 256 long msize;
garbeam@20 257 if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
garbeam@20 258 size.flags = PSize;
garbeam@20 259 c->flags = size.flags;
garbeam@21 260 if(c->flags & PBaseSize) {
garbeam@21 261 c->basew = size.base_width;
garbeam@21 262 c->baseh = size.base_height;
garbeam@21 263 }
garbeam@21 264 else
garbeam@21 265 c->basew = c->baseh = 0;
garbeam@21 266 if(c->flags & PResizeInc) {
garbeam@21 267 c->incw = size.width_inc;
garbeam@21 268 c->inch = size.height_inc;
garbeam@21 269 }
garbeam@21 270 else
garbeam@21 271 c->incw = c->inch = 0;
garbeam@21 272 if(c->flags & PMaxSize) {
garbeam@21 273 c->maxw = size.max_width;
garbeam@21 274 c->maxh = size.max_height;
garbeam@21 275 }
garbeam@21 276 else
garbeam@21 277 c->maxw = c->maxh = 0;
garbeam@21 278 if(c->flags & PMinSize) {
garbeam@21 279 c->minw = size.min_width;
garbeam@21 280 c->minh = size.min_height;
garbeam@21 281 }
garbeam@21 282 else
garbeam@21 283 c->minw = c->minh = 0;
garbeam@29 284 if(c->flags & PWinGravity)
garbeam@29 285 c->grav = size.win_gravity;
garbeam@29 286 else
garbeam@29 287 c->grav = NorthWestGravity;
garbeam@20 288 }
garbeam@20 289
garbeam@20 290 void
garbeam@32 291 craise(Client *c)
garbeam@26 292 {
garbeam@26 293 XRaiseWindow(dpy, c->win);
garbeam@26 294 XRaiseWindow(dpy, c->title);
garbeam@26 295 }
garbeam@26 296
garbeam@26 297 void
garbeam@26 298 lower(Client *c)
garbeam@26 299 {
garbeam@26 300 XLowerWindow(dpy, c->title);
garbeam@26 301 XLowerWindow(dpy, c->win);
garbeam@26 302 }
garbeam@26 303
garbeam@26 304 void
garbeam@13 305 focus(Client *c)
garbeam@13 306 {
garbeam@50 307 if(sel && sel != c) {
garbeam@50 308 XSetWindowBorder(dpy, sel->win, dc.bg);
garbeam@50 309 XMapWindow(dpy, sel->title);
garbeam@50 310 draw_client(sel);
garbeam@21 311 }
garbeam@50 312 sel = c;
garbeam@21 313 XUnmapWindow(dpy, c->title);
garbeam@43 314 XSetWindowBorder(dpy, c->win, dc.fg);
garbeam@27 315 draw_client(c);
garbeam@26 316 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
garbeam@13 317 XFlush(dpy);
garbeam@45 318 discard_events(EnterWindowMask);
garbeam@13 319 }
garbeam@13 320
garbeam@51 321 static void
garbeam@51 322 init_tags(Client *c)
garbeam@51 323 {
garbeam@51 324 XClassHint ch;
garbeam@51 325 static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0;
garbeam@51 326 unsigned int i, j;
garbeam@51 327 Bool matched = False;
garbeam@51 328
garbeam@51 329 if(!len) {
garbeam@51 330 c->tags[tsel] = tags[tsel];
garbeam@51 331 return;
garbeam@51 332 }
garbeam@51 333
garbeam@51 334 if(XGetClassHint(dpy, c->win, &ch)) {
garbeam@51 335 if(ch.res_class && ch.res_name) {
garbeam@51 336 fprintf(stderr, "%s:%s\n", ch.res_class, ch.res_name);
garbeam@51 337 for(i = 0; i < len; i++)
garbeam@51 338 if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class))
garbeam@51 339 && !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance)))
garbeam@51 340 {
garbeam@51 341 fprintf(stderr, "->>>%s:%s\n", ch.res_class, ch.res_name);
garbeam@51 342 for(j = 0; j < TLast; j++)
garbeam@51 343 c->tags[j] = rule[i].tags[j];
garbeam@51 344 matched = True;
garbeam@51 345 break;
garbeam@51 346 }
garbeam@51 347 }
garbeam@51 348 if(ch.res_class)
garbeam@51 349 XFree(ch.res_class);
garbeam@51 350 if(ch.res_name)
garbeam@51 351 XFree(ch.res_name);
garbeam@51 352 }
garbeam@51 353
garbeam@51 354 if(!matched)
garbeam@51 355 c->tags[tsel] = tags[tsel];
garbeam@51 356 }
garbeam@51 357
garbeam@13 358 void
garbeam@10 359 manage(Window w, XWindowAttributes *wa)
garbeam@5 360 {
garbeam@50 361 Client *c, **l;
garbeam@5 362 XSetWindowAttributes twa;
garbeam@5 363
garbeam@5 364 c = emallocz(sizeof(Client));
garbeam@5 365 c->win = w;
garbeam@22 366 c->tx = c->x = wa->x;
garbeam@22 367 c->ty = c->y = wa->y;
garbeam@22 368 c->tw = c->w = wa->width;
garbeam@20 369 c->h = wa->height;
garbeam@32 370 c->th = th;
garbeam@29 371 c->border = 1;
garbeam@50 372 c->proto = win_proto(c->win);
garbeam@20 373 update_size(c);
garbeam@26 374 XSelectInput(dpy, c->win,
garbeam@26 375 StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
garbeam@5 376 XGetTransientForHint(dpy, c->win, &c->trans);
garbeam@5 377 twa.override_redirect = 1;
garbeam@5 378 twa.background_pixmap = ParentRelative;
garbeam@23 379 twa.event_mask = ExposureMask;
garbeam@5 380
garbeam@22 381 c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
garbeam@20 382 0, DefaultDepth(dpy, screen), CopyFromParent,
garbeam@5 383 DefaultVisual(dpy, screen),
garbeam@5 384 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
garbeam@31 385
garbeam@21 386 update_name(c);
garbeam@51 387 init_tags(c);
garbeam@49 388
garbeam@50 389 for(l = &clients; *l; l = &(*l)->next);
garbeam@50 390 c->next = *l; /* *l == nil */
garbeam@50 391 *l = c;
garbeam@49 392
garbeam@43 393 XSetWindowBorderWidth(dpy, c->win, 1);
garbeam@26 394 XMapRaised(dpy, c->win);
garbeam@26 395 XMapRaised(dpy, c->title);
garbeam@19 396 XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask,
garbeam@19 397 GrabModeAsync, GrabModeSync, None, None);
garbeam@19 398 XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask,
garbeam@19 399 GrabModeAsync, GrabModeSync, None, None);
garbeam@19 400 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
garbeam@18 401 GrabModeAsync, GrabModeSync, None, None);
garbeam@46 402 arrange(NULL);
garbeam@51 403 if(c->tags[tsel])
garbeam@51 404 focus(c);
garbeam@51 405 else
garbeam@51 406 ban_client(c);
garbeam@5 407 }
garbeam@9 408
garbeam@18 409 void
garbeam@29 410 gravitate(Client *c, Bool invert)
garbeam@29 411 {
garbeam@29 412 int dx = 0, dy = 0;
garbeam@29 413
garbeam@29 414 switch(c->grav) {
garbeam@29 415 case StaticGravity:
garbeam@29 416 case NorthWestGravity:
garbeam@29 417 case NorthGravity:
garbeam@29 418 case NorthEastGravity:
garbeam@29 419 dy = c->border;
garbeam@29 420 break;
garbeam@29 421 case EastGravity:
garbeam@29 422 case CenterGravity:
garbeam@29 423 case WestGravity:
garbeam@29 424 dy = -(c->h / 2) + c->border;
garbeam@29 425 break;
garbeam@29 426 case SouthEastGravity:
garbeam@29 427 case SouthGravity:
garbeam@29 428 case SouthWestGravity:
garbeam@29 429 dy = -c->h;
garbeam@29 430 break;
garbeam@29 431 default:
garbeam@29 432 break;
garbeam@29 433 }
garbeam@29 434
garbeam@29 435 switch (c->grav) {
garbeam@29 436 case StaticGravity:
garbeam@29 437 case NorthWestGravity:
garbeam@29 438 case WestGravity:
garbeam@29 439 case SouthWestGravity:
garbeam@29 440 dx = c->border;
garbeam@29 441 break;
garbeam@29 442 case NorthGravity:
garbeam@29 443 case CenterGravity:
garbeam@29 444 case SouthGravity:
garbeam@29 445 dx = -(c->w / 2) + c->border;
garbeam@29 446 break;
garbeam@29 447 case NorthEastGravity:
garbeam@29 448 case EastGravity:
garbeam@29 449 case SouthEastGravity:
garbeam@29 450 dx = -(c->w + c->border);
garbeam@29 451 break;
garbeam@29 452 default:
garbeam@29 453 break;
garbeam@29 454 }
garbeam@29 455
garbeam@29 456 if(invert) {
garbeam@29 457 dx = -dx;
garbeam@29 458 dy = -dy;
garbeam@29 459 }
garbeam@29 460 c->x += dx;
garbeam@29 461 c->y += dy;
garbeam@29 462 }
garbeam@29 463
garbeam@31 464
garbeam@29 465 void
garbeam@18 466 resize(Client *c)
garbeam@18 467 {
garbeam@18 468 XConfigureEvent e;
garbeam@18 469
garbeam@31 470 if(c->incw)
garbeam@31 471 c->w -= (c->w - c->basew) % c->incw;
garbeam@31 472 if(c->inch)
garbeam@31 473 c->h -= (c->h - c->baseh) % c->inch;
garbeam@31 474 if(c->minw && c->w < c->minw)
garbeam@31 475 c->w = c->minw;
garbeam@31 476 if(c->minh && c->h < c->minh)
garbeam@31 477 c->h = c->minh;
garbeam@31 478 if(c->maxw && c->w > c->maxw)
garbeam@31 479 c->w = c->maxw;
garbeam@31 480 if(c->maxh && c->h > c->maxh)
garbeam@31 481 c->h = c->maxh;
garbeam@26 482 resize_title(c);
garbeam@20 483 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
garbeam@18 484 e.type = ConfigureNotify;
garbeam@18 485 e.event = c->win;
garbeam@18 486 e.window = c->win;
garbeam@20 487 e.x = c->x;
garbeam@20 488 e.y = c->y;
garbeam@20 489 e.width = c->w;
garbeam@20 490 e.height = c->h;
garbeam@29 491 e.border_width = c->border;
garbeam@18 492 e.above = None;
garbeam@18 493 e.override_redirect = False;
garbeam@18 494 XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e);
garbeam@18 495 XFlush(dpy);
garbeam@18 496 }
garbeam@18 497
garbeam@10 498 static int
garbeam@33 499 dummy_error_handler(Display *dsply, XErrorEvent *err)
garbeam@10 500 {
garbeam@10 501 return 0;
garbeam@10 502 }
garbeam@10 503
garbeam@10 504 void
garbeam@10 505 unmanage(Client *c)
garbeam@10 506 {
garbeam@50 507 Client **l;
garbeam@50 508
garbeam@10 509 XGrabServer(dpy);
garbeam@10 510 XSetErrorHandler(dummy_error_handler);
garbeam@10 511
garbeam@18 512 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
garbeam@10 513 XDestroyWindow(dpy, c->title);
garbeam@10 514
garbeam@50 515 for(l = &clients; *l && *l != c; l = &(*l)->next);
garbeam@50 516 *l = c->next;
garbeam@50 517 for(l = &clients; *l; l = &(*l)->next)
garbeam@50 518 if((*l)->revert == c)
garbeam@50 519 (*l)->revert = NULL;
garbeam@50 520 if(sel == c)
garbeam@50 521 sel = sel->revert ? sel->revert : clients;
garbeam@49 522
garbeam@10 523 free(c);
garbeam@10 524
garbeam@10 525 XFlush(dpy);
garbeam@10 526 XSetErrorHandler(error_handler);
garbeam@10 527 XUngrabServer(dpy);
garbeam@46 528 arrange(NULL);
garbeam@50 529 if(sel)
garbeam@50 530 focus(sel);
garbeam@10 531 }
garbeam@10 532
garbeam@23 533 Client *
garbeam@23 534 gettitle(Window w)
garbeam@23 535 {
garbeam@23 536 Client *c;
garbeam@50 537 for(c = clients; c; c = c->next)
garbeam@23 538 if(c->title == w)
garbeam@23 539 return c;
garbeam@23 540 return NULL;
garbeam@23 541 }
garbeam@10 542
garbeam@9 543 Client *
garbeam@9 544 getclient(Window w)
garbeam@9 545 {
garbeam@9 546 Client *c;
garbeam@50 547 for(c = clients; c; c = c->next)
garbeam@9 548 if(c->win == w)
garbeam@9 549 return c;
garbeam@9 550 return NULL;
garbeam@9 551 }
garbeam@13 552
garbeam@14 553 void
garbeam@14 554 draw_client(Client *c)
garbeam@14 555 {
garbeam@31 556 int i;
garbeam@50 557 if(c == sel)
garbeam@26 558 return;
garbeam@14 559
garbeam@34 560 dc.x = dc.y = 0;
garbeam@34 561 dc.h = c->th;
garbeam@14 562
garbeam@34 563 dc.w = 0;
garbeam@31 564 for(i = 0; i < TLast; i++) {
garbeam@31 565 if(c->tags[i]) {
garbeam@34 566 dc.x += dc.w;
garbeam@43 567 dc.w = textw(c->tags[i]) + dc.font.height;
garbeam@34 568 draw(True, c->tags[i]);
garbeam@31 569 }
garbeam@31 570 }
garbeam@34 571 dc.x += dc.w;
garbeam@43 572 dc.w = textw(c->name) + dc.font.height;
garbeam@34 573 draw(True, c->name);
garbeam@34 574 XCopyArea(dpy, dc.drawable, c->title, dc.gc,
garbeam@22 575 0, 0, c->tw, c->th, 0, 0);
garbeam@21 576 XFlush(dpy);
garbeam@14 577 }