summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R Garbe <garbeam@gmail.com>2009-09-16 15:59:54 +0100
committerAnselm R Garbe <garbeam@gmail.com>2009-09-16 15:59:54 +0100
commite7300e0f6f10900b50d15ea3ae8949049431e38b (patch)
treece34061c30753459c45631b088554ad06f118c68
parentapplied Tony Lainson's config.def.h patch (diff)
downloaddwm-e7300e0f6f10900b50d15ea3ae8949049431e38b.tar.gz
dwm-e7300e0f6f10900b50d15ea3ae8949049431e38b.zip
implemented dynamic layout symbol stuff
Diffstat (limited to '')
-rw-r--r--dwm.115
-rw-r--r--dwm.c37
2 files changed, 25 insertions, 27 deletions
diff --git a/dwm.1 b/dwm.1
index 5f3cc2c..7ed8ead 100644
--- a/dwm.1
+++ b/dwm.1
@@ -20,14 +20,13 @@ Windows are grouped by tags. Each window can be tagged with one or multiple
20tags. Selecting certain tags displays all windows with these tags. 20tags. Selecting certain tags displays all windows with these tags.
21.P 21.P
22Each screen contains a small status bar which displays all available tags, the 22Each screen contains a small status bar which displays all available tags, the
23layout, the number of visible windows, the title of the focused window, and the 23layout, the title of the focused window, and the text read from the root window
24text read from the root window name property, if the screen is focused. A 24name property, if the screen is focused. A floating window is indicated with an
25floating window is indicated with an empty square and a maximised floating 25empty square and a maximised floating window is indicated with a filled square
26window is indicated with a filled square before the windows title. The 26before the windows title. The selected tags are indicated with a different
27selected tags are indicated with a different color. The tags of the focused 27color. The tags of the focused window are indicated with a filled square in the
28window are indicated with a filled square in the top left corner. The tags 28top left corner. The tags which are applied to one or more windows are
29which are applied to one or more windows are indicated with an empty square in 29indicated with an empty square in the top left corner.
30the top left corner.
31.P 30.P
32dwm draws a small border around windows to indicate the focus state. 31dwm draws a small border around windows to indicate the focus state.
33.SH OPTIONS 32.SH OPTIONS
diff --git a/dwm.c b/dwm.c
index 7d19b07..1cb07d3 100644
--- a/dwm.c
+++ b/dwm.c
@@ -121,6 +121,7 @@ typedef struct {
121} Layout; 121} Layout;
122 122
123struct Monitor { 123struct Monitor {
124 const char *ltsymbol;
124 float mfact; 125 float mfact;
125 int num; 126 int num;
126 int by; /* bar geometry */ 127 int by; /* bar geometry */
@@ -238,7 +239,7 @@ static void zoom(const Arg *arg);
238 239
239/* variables */ 240/* variables */
240static const char broken[] = "broken"; 241static const char broken[] = "broken";
241static char stext[256], ntext[8]; 242static char stext[256];
242static int screen; 243static int screen;
243static int sw, sh; /* X display screen geometry width, height */ 244static int sw, sh; /* X display screen geometry width, height */
244static int bh, blw = 0; /* bar geometry */ 245static int bh, blw = 0; /* bar geometry */
@@ -384,6 +385,7 @@ arrange(void) {
384 showhide(m->stack); 385 showhide(m->stack);
385 focus(NULL); 386 focus(NULL);
386 for(m = mons; m; m = m->next) { 387 for(m = mons; m; m = m->next) {
388 m->ltsymbol = m->lt[m->sellt]->symbol;
387 if(m->lt[m->sellt]->arrange) 389 if(m->lt[m->sellt]->arrange)
388 m->lt[m->sellt]->arrange(m); 390 m->lt[m->sellt]->arrange(m);
389 restack(m); 391 restack(m);
@@ -649,13 +651,11 @@ dirtomon(int dir) {
649void 651void
650drawbar(Monitor *m) { 652drawbar(Monitor *m) {
651 int x; 653 int x;
652 unsigned int i, n = 0, occ = 0, urg = 0; 654 unsigned int i, occ = 0, urg = 0;
653 unsigned long *col; 655 unsigned long *col;
654 Client *c; 656 Client *c;
655 657
656 for(c = m->clients; c; c = c->next) { 658 for(c = m->clients; c; c = c->next) {
657 if(ISVISIBLE(c))
658 n++;
659 occ |= c->tags; 659 occ |= c->tags;
660 if(c->isurgent) 660 if(c->isurgent)
661 urg |= c->tags; 661 urg |= c->tags;
@@ -669,15 +669,10 @@ drawbar(Monitor *m) {
669 occ & 1 << i, urg & 1 << i, col); 669 occ & 1 << i, urg & 1 << i, col);
670 dc.x += dc.w; 670 dc.x += dc.w;
671 } 671 }
672 if(blw > 0) { 672 dc.w = blw = TEXTW(m->ltsymbol);
673 dc.w = blw; 673 drawtext(m->ltsymbol, dc.norm, False);
674 drawtext(m->lt[m->sellt]->symbol, dc.norm, False); 674 dc.x += dc.w;
675 dc.x += dc.w; 675 x = dc.x;
676 }
677 snprintf(ntext, sizeof ntext, "%u", n);
678 dc.w = TEXTW(ntext);
679 drawtext(ntext, dc.norm, False);
680 x = (dc.x += dc.w);
681 if(m == selmon) { /* status is only drawn on selected monitor */ 676 if(m == selmon) { /* status is only drawn on selected monitor */
682 dc.w = TEXTW(stext); 677 dc.w = TEXTW(stext);
683 dc.x = m->ww - dc.w; 678 dc.x = m->ww - dc.w;
@@ -1137,8 +1132,17 @@ maprequest(XEvent *e) {
1137 1132
1138void 1133void
1139monocle(Monitor *m) { 1134monocle(Monitor *m) {
1135 static char ntext[8];
1136 unsigned int n = 0;
1140 Client *c; 1137 Client *c;
1141 1138
1139 for(c = m->clients; c; c = c->next)
1140 if(ISVISIBLE(c))
1141 n++;
1142 if(n > 0) { /* override layout symbol */
1143 snprintf(ntext, sizeof ntext, "[%d]", n);
1144 m->ltsymbol = ntext;
1145 }
1142 for(c = nexttiled(m->clients); c; c = nexttiled(c->next)) 1146 for(c = nexttiled(m->clients); c; c = nexttiled(c->next))
1143 resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False); 1147 resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False);
1144} 1148}
@@ -1431,8 +1435,6 @@ setmfact(const Arg *arg) {
1431 1435
1432void 1436void
1433setup(void) { 1437setup(void) {
1434 unsigned int i;
1435 int w;
1436 XSetWindowAttributes wa; 1438 XSetWindowAttributes wa;
1437 1439
1438 /* clean up any zombies immediately */ 1440 /* clean up any zombies immediately */
@@ -1469,10 +1471,6 @@ setup(void) {
1469 if(!dc.font.set) 1471 if(!dc.font.set)
1470 XSetFont(dpy, dc.gc, dc.font.xfont->fid); 1472 XSetFont(dpy, dc.gc, dc.font.xfont->fid);
1471 /* init bars */ 1473 /* init bars */
1472 for(blw = i = 0; LENGTH(layouts) > 1 && i < LENGTH(layouts); i++) {
1473 w = TEXTW(layouts[i].symbol);
1474 blw = MAX(blw, w);
1475 }
1476 updatebars(); 1474 updatebars();
1477 updatestatus(); 1475 updatestatus();
1478 /* EWMH support per view */ 1476 /* EWMH support per view */
@@ -1752,6 +1750,7 @@ updategeom(void) {
1752 m->topbar = topbar; 1750 m->topbar = topbar;
1753 m->lt[0] = &layouts[0]; 1751 m->lt[0] = &layouts[0];
1754 m->lt[1] = &layouts[1 % LENGTH(layouts)]; 1752 m->lt[1] = &layouts[1 % LENGTH(layouts)];
1753 m->ltsymbol = layouts[0].symbol;
1755 updatebarpos(m); 1754 updatebarpos(m);
1756 } 1755 }
1757 /* reassign left over clients of disappeared monitors */ 1756 /* reassign left over clients of disappeared monitors */