changed Client->tags and Rule->tags to be Bool (I'll also try to remove the TLast enum)
8cc7f3ba
6 file(s) · +18 −17
| 18 | 18 | c->tw = 0; |
|
| 19 | 19 | for(i = 0; i < TLast; i++) |
|
| 20 | 20 | if(c->tags[i]) |
|
| 21 | - | c->tw += textw(c->tags[i]); |
|
| 21 | + | c->tw += textw(tags[i]); |
|
| 22 | 22 | c->tw += textw(c->name); |
|
| 23 | 23 | if(c->tw > c->w) |
|
| 24 | 24 | c->tw = c->w + 2; |
| 5 | 5 | ||
| 6 | 6 | enum { Tfnord, Tdev, Tnet, Twork, Tmisc, TLast }; |
|
| 7 | 7 | #define TAGS \ |
|
| 8 | - | char *tags[TLast] = { \ |
|
| 8 | + | const char *tags[TLast] = { \ |
|
| 9 | 9 | [Tfnord] = "fnord", \ |
|
| 10 | 10 | [Tdev] = "dev", \ |
|
| 11 | 11 | [Tnet] = "net", \ |
|
| 66 | 66 | #define RULES \ |
|
| 67 | 67 | static Rule rule[] = { \ |
|
| 68 | 68 | /* class:instance tags isfloat */ \ |
|
| 69 | - | { "Firefox.*", { [Tnet] = "net" }, False }, \ |
|
| 69 | + | { "Firefox.*", { [Tnet] = True }, False }, \ |
|
| 70 | 70 | { "Gimp.*", { 0 }, True}, \ |
|
| 71 | 71 | { "MPlayer.*", { 0 }, True}, \ |
|
| 72 | 72 | { "Acroread.*", { 0 }, True}, \ |
|
| 5 | 5 | ||
| 6 | 6 | enum { Tfnord, Tdev, Tnet, Twork, Tmisc, TLast }; |
|
| 7 | 7 | #define TAGS \ |
|
| 8 | - | char *tags[TLast] = { \ |
|
| 8 | + | const char *tags[TLast] = { \ |
|
| 9 | 9 | [Tfnord] = "fnord", \ |
|
| 10 | 10 | [Tdev] = "dev", \ |
|
| 11 | 11 | [Tnet] = "net", \ |
|
| 57 | 57 | #define RULES \ |
|
| 58 | 58 | static Rule rule[] = { \ |
|
| 59 | 59 | /* class:instance tags isfloat */ \ |
|
| 60 | - | { "Firefox.*", { [Tnet] = "net" }, False }, \ |
|
| 60 | + | { "Firefox.*", { [Tnet] = True }, False }, \ |
|
| 61 | 61 | { "Gimp.*", { 0 }, True}, \ |
|
| 62 | 62 | }; |
|
| 30 | 30 | } |
|
| 31 | 31 | ||
| 32 | 32 | static unsigned int |
|
| 33 | - | textnw(char *text, unsigned int len) |
|
| 33 | + | textnw(const char *text, unsigned int len) |
|
| 34 | 34 | { |
|
| 35 | 35 | XRectangle r; |
|
| 36 | 36 | ||
| 156 | 156 | for(i = 0; i < TLast; i++) { |
|
| 157 | 157 | if(c->tags[i]) { |
|
| 158 | 158 | dc.x += dc.w; |
|
| 159 | - | dc.w = textw(c->tags[i]); |
|
| 160 | - | drawtext(c->tags[i], !istile, True); |
|
| 159 | + | dc.w = textw(tags[i]); |
|
| 160 | + | drawtext(tags[i], !istile, True); |
|
| 161 | 161 | } |
|
| 162 | 162 | } |
|
| 163 | 163 | dc.x += dc.w; |
|
| 229 | 229 | } |
|
| 230 | 230 | ||
| 231 | 231 | unsigned int |
|
| 232 | - | textw(char *text) |
|
| 232 | + | textw(const char *text) |
|
| 233 | 233 | { |
|
| 234 | 234 | return textnw(text, strlen(text)) + dc.font.height; |
|
| 235 | 235 | } |
|
| 51 | 51 | ||
| 52 | 52 | struct Client { |
|
| 53 | 53 | char name[256]; |
|
| 54 | - | char *tags[TLast]; |
|
| 55 | 54 | int proto; |
|
| 56 | 55 | int x, y, w, h; |
|
| 57 | 56 | int tx, ty, tw, th; /* title */ |
|
| 61 | 60 | unsigned int border; |
|
| 62 | 61 | Bool isfloat; |
|
| 63 | 62 | Bool ismax; |
|
| 63 | + | Bool tags[TLast]; |
|
| 64 | 64 | Client *next; |
|
| 65 | 65 | Client *prev; |
|
| 66 | 66 | Window win; |
|
| 67 | 67 | Window title; |
|
| 68 | 68 | }; |
|
| 69 | 69 | ||
| 70 | - | extern char *tags[TLast], stext[1024]; |
|
| 70 | + | extern const char *tags[TLast]; |
|
| 71 | + | extern char stext[1024]; |
|
| 71 | 72 | extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw; |
|
| 72 | 73 | extern void (*handler[LASTEvent])(XEvent *); |
|
| 73 | 74 | extern void (*arrange)(Arg *); |
|
| 104 | 105 | extern void drawtitle(Client *c); |
|
| 105 | 106 | extern unsigned long getcolor(const char *colstr); |
|
| 106 | 107 | extern void setfont(const char *fontstr); |
|
| 107 | - | extern unsigned int textw(char *text); |
|
| 108 | + | extern unsigned int textw(const char *text); |
|
| 108 | 109 | ||
| 109 | 110 | /* event.c */ |
|
| 110 | 111 | extern void grabkeys(); |
|
| 13 | 13 | ||
| 14 | 14 | typedef struct { |
|
| 15 | 15 | const char *pattern; |
|
| 16 | - | char *tags[TLast]; |
|
| 16 | + | Bool tags[TLast]; |
|
| 17 | 17 | Bool isfloat; |
|
| 18 | 18 | } Rule; |
|
| 19 | 19 | ||
| 30 | 30 | if(!sel) |
|
| 31 | 31 | return; |
|
| 32 | 32 | ||
| 33 | - | sel->tags[arg->i] = tags[arg->i]; |
|
| 33 | + | sel->tags[arg->i] = True; |
|
| 34 | 34 | arrange(NULL); |
|
| 35 | 35 | } |
|
| 36 | 36 | ||
| 146 | 146 | return; |
|
| 147 | 147 | ||
| 148 | 148 | for(i = 0; i < TLast; i++) |
|
| 149 | - | sel->tags[i] = NULL; |
|
| 149 | + | sel->tags[i] = False; |
|
| 150 | 150 | appendtag(arg); |
|
| 151 | 151 | } |
|
| 152 | 152 | ||
| 171 | 171 | for(j = 0; j < TLast; j++) { |
|
| 172 | 172 | if(rule[i].tags[j]) |
|
| 173 | 173 | matched = True; |
|
| 174 | - | c->tags[j] = rule[i].tags[j]; |
|
| 174 | + | c->tags[j] = True; |
|
| 175 | 175 | } |
|
| 176 | 176 | c->isfloat = rule[i].isfloat; |
|
| 177 | 177 | } |
|
| 184 | 184 | XFree(ch.res_name); |
|
| 185 | 185 | } |
|
| 186 | 186 | if(!matched) |
|
| 187 | - | c->tags[tsel] = tags[tsel]; |
|
| 187 | + | c->tags[tsel] = True; |
|
| 188 | 188 | } |
|
| 189 | 189 | ||
| 190 | 190 | void |
|