about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-01-08 17:33:24 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-01-08 17:33:24 +0100
commit1d4a24dae02cfb3a3241c3d293e96dba910317bd (patch)
tree52267e4a8de9e198fed15726c20734e7ac735197
parenta768ea93fdb3adfa33b3ea7ccc7abfe86a2bfb2a (diff)
downloaddwm-1d4a24dae02cfb3a3241c3d293e96dba910317bd.tar.gz
implemented nmaster appearance in mode label (using %u)
-rw-r--r--config.arg.h2
-rw-r--r--config.default.h2
-rw-r--r--config.mk2
-rw-r--r--draw.c2
-rw-r--r--dwm.h1
-rw-r--r--main.c5
-rw-r--r--view.c12
7 files changed, 18 insertions, 8 deletions
diff --git a/config.arg.h b/config.arg.h
index aa3c0c9..b87c9dc 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -7,7 +7,7 @@ const char *tags[] = { "home", "net", "www", "mon", "fnord", NULL };
 
 #define DEFMODE			dotile		/* dofloat */
 #define FLOATSYMBOL		"><>"
-#define TILESYMBOL		"[]="
+#define TILESYMBOL		"[%u]="
 
 #define FONT			"-*-terminus-medium-r-*-*-14-*-*-*-*-*-*-*"
 #define NORMBGCOLOR		"#111111"
diff --git a/config.default.h b/config.default.h
index 348ab61..174be3f 100644
--- a/config.default.h
+++ b/config.default.h
@@ -7,7 +7,7 @@ const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
 
 #define DEFMODE			dotile /* dofloat */
 #define FLOATSYMBOL		"><>"
-#define TILESYMBOL		"[]="
+#define TILESYMBOL		"[%u]="
 
 #define FONT			"-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
 #define NORMBGCOLOR		"#333366"
diff --git a/config.mk b/config.mk
index 1d73f2b..4a498ca 100644
--- a/config.mk
+++ b/config.mk
@@ -1,5 +1,5 @@
 # dwm version
-VERSION = 2.9
+VERSION = 3.0
 
 # Customize below to fit your system
 
diff --git a/draw.c b/draw.c
index 9a469f9..fe73867 100644
--- a/draw.c
+++ b/draw.c
@@ -120,7 +120,7 @@ drawstatus(void) {
 		dc.x += dc.w;
 	}
 	dc.w = bmw;
-	drawtext(arrange == dofloat ?  FLOATSYMBOL : TILESYMBOL, dc.status, False, False);
+	drawtext(mtext, dc.status, False, False);
 	x = dc.x + dc.w;
 	dc.w = textw(stext);
 	dc.x = bw - dc.w;
diff --git a/dwm.h b/dwm.h
index f929181..68b3e36 100644
--- a/dwm.h
+++ b/dwm.h
@@ -93,6 +93,7 @@ struct Client {
 
 extern const char *tags[];			/* all tags */
 extern char stext[1024];			/* status text */
+extern char mtext[32];				/* mode text */
 extern int bx, by, bw, bh, bmw;			/* bar geometry, bar mode label width */
 extern int screen, sx, sy, sw, sh;		/* screen geometry */
 extern int wax, way, wah, waw;			/* windowarea geometry */
diff --git a/main.c b/main.c
index da209a9..c080ada 100644
--- a/main.c
+++ b/main.c
@@ -17,7 +17,7 @@
 
 /* extern */
 
-char stext[1024];
+char stext[1024], mtext[32];
 Bool *seltag;
 int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah;
 unsigned int master, nmaster, ntags, numlockmask;
@@ -128,12 +128,13 @@ setup(void) {
 	dc.status[ColFG] = getcolor(STATUSFGCOLOR);
 	setfont(FONT);
 	/* geometry */
-	bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ?  textw(TILESYMBOL) : textw(FLOATSYMBOL);
 	sx = sy = 0;
 	sw = DisplayWidth(dpy, screen);
 	sh = DisplayHeight(dpy, screen);
 	master = MASTER;
 	nmaster = NMASTER;
+	snprintf(mtext, sizeof mtext, arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, nmaster);
+	bmw = textw(mtext);
 	/* bar */
 	bx = sx;
 	by = sy;
diff --git a/view.c b/view.c
index f2e4040..2f2d42a 100644
--- a/view.c
+++ b/view.c
@@ -2,6 +2,7 @@
  * See LICENSE file for license details.
  */
 #include "dwm.h"
+#include <stdio.h>
 
 /* static */
 
@@ -149,10 +150,15 @@ focusprev(Arg *arg) {
 
 void
 incnmaster(Arg *arg) {
-	if((nmaster + arg->i < 1) || (wah / (nmaster + arg->i) < bh))
+	if((arrange == dofloat) || (nmaster + arg->i < 1) || (wah / (nmaster + arg->i) < bh))
 		return;
 	nmaster += arg->i;
-	arrange();
+	snprintf(mtext, sizeof mtext, arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, nmaster);
+	bmw = textw(mtext);
+	if(sel)
+		arrange();
+	else
+		drawstatus();
 }
 
 Bool
@@ -218,6 +224,8 @@ togglefloat(Arg *arg) {
 void
 togglemode(Arg *arg) {
 	arrange = (arrange == dofloat) ? dotile : dofloat;
+	snprintf(mtext, sizeof mtext, arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, nmaster);
+	bmw = textw(mtext);
 	if(sel)
 		arrange();
 	else
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 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623