implemented dynamic layout symbol stuff
e7300e0f
2 file(s) · +25 −27
| 20 | 20 | tags. Selecting certain tags displays all windows with these tags. |
|
| 21 | 21 | .P |
|
| 22 | 22 | Each screen contains a small status bar which displays all available tags, the |
|
| 23 | - | layout, the number of visible windows, the title of the focused window, and the |
|
| 24 | - | text read from the root window name property, if the screen is focused. A |
|
| 25 | - | floating window is indicated with an empty square and a maximised floating |
|
| 26 | - | window is indicated with a filled square before the windows title. The |
|
| 27 | - | selected tags are indicated with a different color. The tags of the focused |
|
| 28 | - | window are indicated with a filled square in the top left corner. The tags |
|
| 29 | - | which are applied to one or more windows are indicated with an empty square in |
|
| 30 | - | the top left corner. |
|
| 23 | + | layout, the title of the focused window, and the text read from the root window |
|
| 24 | + | name property, if the screen is focused. A floating window is indicated with an |
|
| 25 | + | empty square and a maximised floating window is indicated with a filled square |
|
| 26 | + | before the windows title. The selected tags are indicated with a different |
|
| 27 | + | color. The tags of the focused window are indicated with a filled square in the |
|
| 28 | + | top left corner. The tags which are applied to one or more windows are |
|
| 29 | + | indicated with an empty square in the top left corner. |
|
| 31 | 30 | .P |
|
| 32 | 31 | dwm draws a small border around windows to indicate the focus state. |
|
| 33 | 32 | .SH OPTIONS |
| 121 | 121 | } Layout; |
|
| 122 | 122 | ||
| 123 | 123 | struct Monitor { |
|
| 124 | + | const char *ltsymbol; |
|
| 124 | 125 | float mfact; |
|
| 125 | 126 | int num; |
|
| 126 | 127 | int by; /* bar geometry */ |
|
| 238 | 239 | ||
| 239 | 240 | /* variables */ |
|
| 240 | 241 | static const char broken[] = "broken"; |
|
| 241 | - | static char stext[256], ntext[8]; |
|
| 242 | + | static char stext[256]; |
|
| 242 | 243 | static int screen; |
|
| 243 | 244 | static int sw, sh; /* X display screen geometry width, height */ |
|
| 244 | 245 | static int bh, blw = 0; /* bar geometry */ |
|
| 384 | 385 | showhide(m->stack); |
|
| 385 | 386 | focus(NULL); |
|
| 386 | 387 | for(m = mons; m; m = m->next) { |
|
| 388 | + | m->ltsymbol = m->lt[m->sellt]->symbol; |
|
| 387 | 389 | if(m->lt[m->sellt]->arrange) |
|
| 388 | 390 | m->lt[m->sellt]->arrange(m); |
|
| 389 | 391 | restack(m); |
|
| 649 | 651 | void |
|
| 650 | 652 | drawbar(Monitor *m) { |
|
| 651 | 653 | int x; |
|
| 652 | - | unsigned int i, n = 0, occ = 0, urg = 0; |
|
| 654 | + | unsigned int i, occ = 0, urg = 0; |
|
| 653 | 655 | unsigned long *col; |
|
| 654 | 656 | Client *c; |
|
| 655 | 657 | ||
| 656 | 658 | for(c = m->clients; c; c = c->next) { |
|
| 657 | - | if(ISVISIBLE(c)) |
|
| 658 | - | n++; |
|
| 659 | 659 | occ |= c->tags; |
|
| 660 | 660 | if(c->isurgent) |
|
| 661 | 661 | urg |= c->tags; |
|
| 669 | 669 | occ & 1 << i, urg & 1 << i, col); |
|
| 670 | 670 | dc.x += dc.w; |
|
| 671 | 671 | } |
|
| 672 | - | if(blw > 0) { |
|
| 673 | - | dc.w = blw; |
|
| 674 | - | drawtext(m->lt[m->sellt]->symbol, dc.norm, False); |
|
| 675 | - | dc.x += dc.w; |
|
| 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); |
|
| 672 | + | dc.w = blw = TEXTW(m->ltsymbol); |
|
| 673 | + | drawtext(m->ltsymbol, dc.norm, False); |
|
| 674 | + | dc.x += dc.w; |
|
| 675 | + | x = dc.x; |
|
| 681 | 676 | if(m == selmon) { /* status is only drawn on selected monitor */ |
|
| 682 | 677 | dc.w = TEXTW(stext); |
|
| 683 | 678 | dc.x = m->ww - dc.w; |
|
| 1137 | 1132 | ||
| 1138 | 1133 | void |
|
| 1139 | 1134 | monocle(Monitor *m) { |
|
| 1135 | + | static char ntext[8]; |
|
| 1136 | + | unsigned int n = 0; |
|
| 1140 | 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 | 1146 | for(c = nexttiled(m->clients); c; c = nexttiled(c->next)) |
|
| 1143 | 1147 | resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False); |
|
| 1144 | 1148 | } |
|
| 1431 | 1435 | ||
| 1432 | 1436 | void |
|
| 1433 | 1437 | setup(void) { |
|
| 1434 | - | unsigned int i; |
|
| 1435 | - | int w; |
|
| 1436 | 1438 | XSetWindowAttributes wa; |
|
| 1437 | 1439 | ||
| 1438 | 1440 | /* clean up any zombies immediately */ |
|
| 1469 | 1471 | if(!dc.font.set) |
|
| 1470 | 1472 | XSetFont(dpy, dc.gc, dc.font.xfont->fid); |
|
| 1471 | 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 | 1474 | updatebars(); |
|
| 1477 | 1475 | updatestatus(); |
|
| 1478 | 1476 | /* EWMH support per view */ |
|
| 1752 | 1750 | m->topbar = topbar; |
|
| 1753 | 1751 | m->lt[0] = &layouts[0]; |
|
| 1754 | 1752 | m->lt[1] = &layouts[1 % LENGTH(layouts)]; |
|
| 1753 | + | m->ltsymbol = layouts[0].symbol; |
|
| 1755 | 1754 | updatebarpos(m); |
|
| 1756 | 1755 | } |
|
| 1757 | 1756 | /* reassign left over clients of disappeared monitors */ |
|