about summary refs log tree commit diff stats
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'client.c')
-rw-r--r--client.c64
1 files changed, 49 insertions, 15 deletions
diff --git a/client.c b/client.c
index b1b1417..b7c9455 100644
--- a/client.c
+++ b/client.c
@@ -37,10 +37,6 @@ update_name(Client *c)
 		}
 	}
 	XFree(name.value);
-	if(c == stack)
-		draw_bar();
-	else
-		draw_client(c);
 }
 
 void
@@ -51,27 +47,52 @@ update_size(Client *c)
 	if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
 		size.flags = PSize;
 	c->flags = size.flags;
-	c->basew = size.base_width;
-	c->baseh = size.base_height;
-	c->incw = size.width_inc;
-	c->inch = size.height_inc;
-	c->maxw = size.max_width;
-	c->maxh = size.max_height;
-	c->minw = size.min_width;
-	c->minh = size.min_height;
+	if(c->flags & PBaseSize) {
+		c->basew = size.base_width;
+		c->baseh = size.base_height;
+	}
+	else
+		c->basew = c->baseh = 0;
+	if(c->flags & PResizeInc) {
+		c->incw = size.width_inc;
+		c->inch = size.height_inc;
+	}
+	else
+		c->incw = c->inch = 0;
+	if(c->flags & PMaxSize) {
+		c->maxw = size.max_width;
+		c->maxh = size.max_height;
+	}
+	else
+		c->maxw = c->maxh = 0;
+	if(c->flags & PMinSize) {
+		c->minw = size.min_width;
+		c->minh = size.min_height;
+	}
+	else
+		c->minw = c->minh = 0;
 }
 
 void
 focus(Client *c)
 {
-	Client **l;
+	Client **l, *old;
+
+	old = stack;
 	for(l=&stack; *l && *l != c; l=&(*l)->snext);
 	eassert(*l == c);
 	*l = c->snext;
 	c->snext = stack;
 	stack = c;
 	XRaiseWindow(dpy, c->win);
+	XRaiseWindow(dpy, c->title);
 	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+	if(old && old != c) {
+		XMapWindow(dpy, old->title);
+		draw_client(old);
+	}
+	XUnmapWindow(dpy, c->title);
+	draw_bar();
 	XFlush(dpy);
 }
 
@@ -91,7 +112,6 @@ manage(Window w, XWindowAttributes *wa)
 	XSetWindowBorderWidth(dpy, c->win, 1);
 	XSelectInput(dpy, c->win, CLIENT_MASK);
 	XGetTransientForHint(dpy, c->win, &c->trans);
-	update_name(c);
 	twa.override_redirect = 1;
 	twa.background_pixmap = ParentRelative;
 	twa.event_mask = ExposureMask;
@@ -100,6 +120,7 @@ manage(Window w, XWindowAttributes *wa)
 			0, DefaultDepth(dpy, screen), CopyFromParent,
 			DefaultVisual(dpy, screen),
 			CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
+	update_name(c);
 
 	for(l=&clients; *l; l=&(*l)->next);
 	c->next = *l; /* *l == nil */
@@ -107,12 +128,14 @@ manage(Window w, XWindowAttributes *wa)
 	c->snext = stack;
 	stack = c;
 	XMapWindow(dpy, c->win);
+	XMapWindow(dpy, c->title);
 	XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask,
 			GrabModeAsync, GrabModeSync, None, None);
 	XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask,
 			GrabModeAsync, GrabModeSync, None, None);
 	XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
 			GrabModeAsync, GrabModeSync, None, None);
+	resize(c);
 	focus(c);
 }
 
@@ -122,6 +145,7 @@ resize(Client *c)
 	XConfigureEvent e;
 
 	XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
+	XMoveResizeWindow(dpy, c->title, c->x + c->w / 3, c->y, 2 * c->w / 3, barrect.height);
 	e.type = ConfigureNotify;
 	e.event = c->win;
 	e.window = c->win;
@@ -186,7 +210,17 @@ getclient(Window w)
 void
 draw_client(Client *c)
 {
-	
+	if(!c)
+		return;
+	if(c == stack)
+		draw_bar();
 
+	brush.rect.x = brush.rect.y = 0;
+	brush.rect.width = 2 * c->w / 3;
+	brush.rect.height = barrect.height;
 
+	draw(dpy, &brush, True, c->name);
+	XCopyArea(dpy, brush.drawable, c->title, brush.gc, 0, 0,
+			brush.rect.width, brush.rect.height, 0, 0);
+	XFlush(dpy);
 }
='#n304'>304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519