diff options
| author | Anselm R Garbe <garbeam@gmail.com> | 2009-09-16 15:59:54 +0100 |
|---|---|---|
| committer | Anselm R Garbe <garbeam@gmail.com> | 2009-09-16 15:59:54 +0100 |
| commit | e7300e0f6f10900b50d15ea3ae8949049431e38b (patch) | |
| tree | ce34061c30753459c45631b088554ad06f118c68 /dwm.c | |
| parent | applied Tony Lainson's config.def.h patch (diff) | |
| download | dwm-e7300e0f6f10900b50d15ea3ae8949049431e38b.tar.gz dwm-e7300e0f6f10900b50d15ea3ae8949049431e38b.zip | |
implemented dynamic layout symbol stuff
Diffstat (limited to '')
| -rw-r--r-- | dwm.c | 37 |
1 files changed, 18 insertions, 19 deletions
| @@ -121,6 +121,7 @@ typedef struct { | |||
| 121 | } Layout; | 121 | } Layout; |
| 122 | 122 | ||
| 123 | struct Monitor { | 123 | struct 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 */ |
| 240 | static const char broken[] = "broken"; | 241 | static const char broken[] = "broken"; |
| 241 | static char stext[256], ntext[8]; | 242 | static char stext[256]; |
| 242 | static int screen; | 243 | static int screen; |
| 243 | static int sw, sh; /* X display screen geometry width, height */ | 244 | static int sw, sh; /* X display screen geometry width, height */ |
| 244 | static int bh, blw = 0; /* bar geometry */ | 245 | static 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) { | |||
| 649 | void | 651 | void |
| 650 | drawbar(Monitor *m) { | 652 | drawbar(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 | ||
| 1138 | void | 1133 | void |
| 1139 | monocle(Monitor *m) { | 1134 | monocle(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 | ||
| 1432 | void | 1436 | void |
| 1433 | setup(void) { | 1437 | setup(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 */ |
