dwm-meillo

annotate client.c @ 52:d18f6dd0cf23

fixed several things, nearly feature complete
author Anselm R. Garbe <garbeam@wmii.de>
date Thu, 13 Jul 2006 20:28:19 +0200
parents 035617ee18d1
children 529901e6a227
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@52 55 resize(sel, False);
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@52 103 resize(c, True);
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@52 128 h = (n > 1) ? sh / (n - 1) : 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@52 135 c->w = sw - 2 * c->border;
garbeam@52 136 c->h = sh - 2 * c->border;
garbeam@51 137 }
garbeam@52 138 else if(i == 0) {
garbeam@51 139 c->x = sx;
garbeam@51 140 c->y = sy;
garbeam@52 141 c->w = mw - 2 * c->border;
garbeam@52 142 c->h = sh - 2 * c->border;
garbeam@51 143 }
garbeam@51 144 else {
garbeam@51 145 c->x = sx + mw;
garbeam@52 146 c->y = sy + (i - 1) * h;
garbeam@52 147 c->w = w - 2 * c->border;
garbeam@52 148 c->h = h - 2 * c->border;
garbeam@51 149 }
garbeam@52 150 resize(c, False);
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@52 307 Client *old = sel;
garbeam@52 308
garbeam@50 309 sel = c;
garbeam@52 310 if(old && old != c)
garbeam@52 311 draw_client(old);
garbeam@27 312 draw_client(c);
garbeam@26 313 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
garbeam@13 314 XFlush(dpy);
garbeam@45 315 discard_events(EnterWindowMask);
garbeam@13 316 }
garbeam@13 317
garbeam@51 318 static void
garbeam@51 319 init_tags(Client *c)
garbeam@51 320 {
garbeam@51 321 XClassHint ch;
garbeam@51 322 static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0;
garbeam@51 323 unsigned int i, j;
garbeam@51 324 Bool matched = False;
garbeam@51 325
garbeam@51 326 if(!len) {
garbeam@51 327 c->tags[tsel] = tags[tsel];
garbeam@51 328 return;
garbeam@51 329 }
garbeam@51 330
garbeam@51 331 if(XGetClassHint(dpy, c->win, &ch)) {
garbeam@51 332 if(ch.res_class && ch.res_name) {
garbeam@51 333 fprintf(stderr, "%s:%s\n", ch.res_class, ch.res_name);
garbeam@51 334 for(i = 0; i < len; i++)
garbeam@51 335 if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class))
garbeam@51 336 && !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance)))
garbeam@51 337 {
garbeam@51 338 fprintf(stderr, "->>>%s:%s\n", ch.res_class, ch.res_name);
garbeam@51 339 for(j = 0; j < TLast; j++)
garbeam@51 340 c->tags[j] = rule[i].tags[j];
garbeam@51 341 matched = True;
garbeam@51 342 break;
garbeam@51 343 }
garbeam@51 344 }
garbeam@51 345 if(ch.res_class)
garbeam@51 346 XFree(ch.res_class);
garbeam@51 347 if(ch.res_name)
garbeam@51 348 XFree(ch.res_name);
garbeam@51 349 }
garbeam@51 350
garbeam@51 351 if(!matched)
garbeam@51 352 c->tags[tsel] = tags[tsel];
garbeam@51 353 }
garbeam@51 354
garbeam@13 355 void
garbeam@10 356 manage(Window w, XWindowAttributes *wa)
garbeam@5 357 {
garbeam@50 358 Client *c, **l;
garbeam@5 359 XSetWindowAttributes twa;
garbeam@5 360
garbeam@5 361 c = emallocz(sizeof(Client));
garbeam@5 362 c->win = w;
garbeam@22 363 c->tx = c->x = wa->x;
garbeam@22 364 c->ty = c->y = wa->y;
garbeam@22 365 c->tw = c->w = wa->width;
garbeam@20 366 c->h = wa->height;
garbeam@32 367 c->th = th;
garbeam@29 368 c->border = 1;
garbeam@50 369 c->proto = win_proto(c->win);
garbeam@20 370 update_size(c);
garbeam@26 371 XSelectInput(dpy, c->win,
garbeam@26 372 StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
garbeam@5 373 XGetTransientForHint(dpy, c->win, &c->trans);
garbeam@5 374 twa.override_redirect = 1;
garbeam@5 375 twa.background_pixmap = ParentRelative;
garbeam@23 376 twa.event_mask = ExposureMask;
garbeam@5 377
garbeam@22 378 c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
garbeam@20 379 0, DefaultDepth(dpy, screen), CopyFromParent,
garbeam@5 380 DefaultVisual(dpy, screen),
garbeam@5 381 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
garbeam@31 382
garbeam@21 383 update_name(c);
garbeam@51 384 init_tags(c);
garbeam@49 385
garbeam@50 386 for(l = &clients; *l; l = &(*l)->next);
garbeam@50 387 c->next = *l; /* *l == nil */
garbeam@50 388 *l = c;
garbeam@49 389
garbeam@43 390 XSetWindowBorderWidth(dpy, c->win, 1);
garbeam@26 391 XMapRaised(dpy, c->win);
garbeam@26 392 XMapRaised(dpy, c->title);
garbeam@19 393 XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask,
garbeam@19 394 GrabModeAsync, GrabModeSync, None, None);
garbeam@19 395 XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask,
garbeam@19 396 GrabModeAsync, GrabModeSync, None, None);
garbeam@19 397 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
garbeam@18 398 GrabModeAsync, GrabModeSync, None, None);
garbeam@46 399 arrange(NULL);
garbeam@51 400 if(c->tags[tsel])
garbeam@51 401 focus(c);
garbeam@51 402 else
garbeam@51 403 ban_client(c);
garbeam@5 404 }
garbeam@9 405
garbeam@18 406 void
garbeam@29 407 gravitate(Client *c, Bool invert)
garbeam@29 408 {
garbeam@29 409 int dx = 0, dy = 0;
garbeam@29 410
garbeam@29 411 switch(c->grav) {
garbeam@29 412 case StaticGravity:
garbeam@29 413 case NorthWestGravity:
garbeam@29 414 case NorthGravity:
garbeam@29 415 case NorthEastGravity:
garbeam@29 416 dy = c->border;
garbeam@29 417 break;
garbeam@29 418 case EastGravity:
garbeam@29 419 case CenterGravity:
garbeam@29 420 case WestGravity:
garbeam@29 421 dy = -(c->h / 2) + c->border;
garbeam@29 422 break;
garbeam@29 423 case SouthEastGravity:
garbeam@29 424 case SouthGravity:
garbeam@29 425 case SouthWestGravity:
garbeam@29 426 dy = -c->h;
garbeam@29 427 break;
garbeam@29 428 default:
garbeam@29 429 break;
garbeam@29 430 }
garbeam@29 431
garbeam@29 432 switch (c->grav) {
garbeam@29 433 case StaticGravity:
garbeam@29 434 case NorthWestGravity:
garbeam@29 435 case WestGravity:
garbeam@29 436 case SouthWestGravity:
garbeam@29 437 dx = c->border;
garbeam@29 438 break;
garbeam@29 439 case NorthGravity:
garbeam@29 440 case CenterGravity:
garbeam@29 441 case SouthGravity:
garbeam@29 442 dx = -(c->w / 2) + c->border;
garbeam@29 443 break;
garbeam@29 444 case NorthEastGravity:
garbeam@29 445 case EastGravity:
garbeam@29 446 case SouthEastGravity:
garbeam@29 447 dx = -(c->w + c->border);
garbeam@29 448 break;
garbeam@29 449 default:
garbeam@29 450 break;
garbeam@29 451 }
garbeam@29 452
garbeam@29 453 if(invert) {
garbeam@29 454 dx = -dx;
garbeam@29 455 dy = -dy;
garbeam@29 456 }
garbeam@29 457 c->x += dx;
garbeam@29 458 c->y += dy;
garbeam@29 459 }
garbeam@29 460
garbeam@31 461
garbeam@29 462 void
garbeam@52 463 resize(Client *c, Bool inc)
garbeam@18 464 {
garbeam@18 465 XConfigureEvent e;
garbeam@18 466
garbeam@52 467 if(inc) {
garbeam@52 468 if(c->incw)
garbeam@52 469 c->w -= (c->w - c->basew) % c->incw;
garbeam@52 470 if(c->inch)
garbeam@52 471 c->h -= (c->h - c->baseh) % c->inch;
garbeam@52 472 }
garbeam@31 473 if(c->minw && c->w < c->minw)
garbeam@31 474 c->w = c->minw;
garbeam@31 475 if(c->minh && c->h < c->minh)
garbeam@31 476 c->h = c->minh;
garbeam@31 477 if(c->maxw && c->w > c->maxw)
garbeam@31 478 c->w = c->maxw;
garbeam@31 479 if(c->maxh && c->h > c->maxh)
garbeam@31 480 c->h = c->maxh;
garbeam@26 481 resize_title(c);
garbeam@20 482 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
garbeam@18 483 e.type = ConfigureNotify;
garbeam@18 484 e.event = c->win;
garbeam@18 485 e.window = c->win;
garbeam@20 486 e.x = c->x;
garbeam@20 487 e.y = c->y;
garbeam@20 488 e.width = c->w;
garbeam@20 489 e.height = c->h;
garbeam@29 490 e.border_width = c->border;
garbeam@18 491 e.above = None;
garbeam@18 492 e.override_redirect = False;
garbeam@18 493 XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e);
garbeam@18 494 XFlush(dpy);
garbeam@18 495 }
garbeam@18 496
garbeam@10 497 static int
garbeam@33 498 dummy_error_handler(Display *dsply, XErrorEvent *err)
garbeam@10 499 {
garbeam@10 500 return 0;
garbeam@10 501 }
garbeam@10 502
garbeam@10 503 void
garbeam@10 504 unmanage(Client *c)
garbeam@10 505 {
garbeam@50 506 Client **l;
garbeam@50 507
garbeam@10 508 XGrabServer(dpy);
garbeam@10 509 XSetErrorHandler(dummy_error_handler);
garbeam@10 510
garbeam@18 511 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
garbeam@10 512 XDestroyWindow(dpy, c->title);
garbeam@10 513
garbeam@50 514 for(l = &clients; *l && *l != c; l = &(*l)->next);
garbeam@50 515 *l = c->next;
garbeam@50 516 for(l = &clients; *l; l = &(*l)->next)
garbeam@50 517 if((*l)->revert == c)
garbeam@50 518 (*l)->revert = NULL;
garbeam@50 519 if(sel == c)
garbeam@50 520 sel = sel->revert ? sel->revert : clients;
garbeam@49 521
garbeam@10 522 free(c);
garbeam@10 523
garbeam@10 524 XFlush(dpy);
garbeam@10 525 XSetErrorHandler(error_handler);
garbeam@10 526 XUngrabServer(dpy);
garbeam@46 527 arrange(NULL);
garbeam@50 528 if(sel)
garbeam@50 529 focus(sel);
garbeam@10 530 }
garbeam@10 531
garbeam@23 532 Client *
garbeam@23 533 gettitle(Window w)
garbeam@23 534 {
garbeam@23 535 Client *c;
garbeam@50 536 for(c = clients; c; c = c->next)
garbeam@23 537 if(c->title == w)
garbeam@23 538 return c;
garbeam@23 539 return NULL;
garbeam@23 540 }
garbeam@10 541
garbeam@9 542 Client *
garbeam@9 543 getclient(Window w)
garbeam@9 544 {
garbeam@9 545 Client *c;
garbeam@50 546 for(c = clients; c; c = c->next)
garbeam@9 547 if(c->win == w)
garbeam@9 548 return c;
garbeam@9 549 return NULL;
garbeam@9 550 }
garbeam@13 551
garbeam@14 552 void
garbeam@14 553 draw_client(Client *c)
garbeam@14 554 {
garbeam@31 555 int i;
garbeam@52 556 if(c == sel) {
garbeam@52 557 XUnmapWindow(dpy, c->title);
garbeam@52 558 XSetWindowBorder(dpy, c->win, dc.fg);
garbeam@26 559 return;
garbeam@52 560 }
garbeam@52 561
garbeam@52 562 XSetWindowBorder(dpy, c->win, dc.bg);
garbeam@52 563 XMapWindow(dpy, c->title);
garbeam@14 564
garbeam@34 565 dc.x = dc.y = 0;
garbeam@34 566 dc.h = c->th;
garbeam@14 567
garbeam@34 568 dc.w = 0;
garbeam@31 569 for(i = 0; i < TLast; i++) {
garbeam@31 570 if(c->tags[i]) {
garbeam@34 571 dc.x += dc.w;
garbeam@43 572 dc.w = textw(c->tags[i]) + dc.font.height;
garbeam@34 573 draw(True, c->tags[i]);
garbeam@31 574 }
garbeam@31 575 }
garbeam@34 576 dc.x += dc.w;
garbeam@43 577 dc.w = textw(c->name) + dc.font.height;
garbeam@34 578 draw(True, c->name);
garbeam@34 579 XCopyArea(dpy, dc.drawable, c->title, dc.gc,
garbeam@22 580 0, 0, c->tw, c->th, 0, 0);
garbeam@21 581 XFlush(dpy);
garbeam@14 582 }