Mercurial > aewl
comparison aewl.c @ 762:3f0b245732fc
changed terminology: "tag" is now "group"
author | meillo@marmaro.de |
---|---|
date | Fri, 05 Dec 2008 16:03:45 +0100 |
parents | 59ce221b9a37 |
children | 17428bca4a12 |
comparison
equal
deleted
inserted
replaced
761:59ce221b9a37 | 762:3f0b245732fc |
---|---|
84 int basew, baseh, incw, inch, maxw, maxh, minw, minh; | 84 int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
85 int minax, minay, maxax, maxay; | 85 int minax, minay, maxax, maxay; |
86 long flags; | 86 long flags; |
87 unsigned int border; | 87 unsigned int border; |
88 Bool isfixed, isfloat, ismax; | 88 Bool isfixed, isfloat, ismax; |
89 Bool tag; | 89 Bool group; |
90 Client *next; | 90 Client *next; |
91 Client *prev; | 91 Client *prev; |
92 Client *snext; | 92 Client *snext; |
93 Window win; | 93 Window win; |
94 }; | 94 }; |
95 | 95 |
96 typedef struct { | 96 typedef struct { |
97 const char *clpattern; | 97 const char *clpattern; |
98 int tag; | 98 int group; |
99 Bool isfloat; | 99 Bool isfloat; |
100 } Rule; | 100 } Rule; |
101 | 101 |
102 typedef struct { | 102 typedef struct { |
103 regex_t *clregex; | 103 regex_t *clregex; |
124 unsigned int nmaster; /* number of master clients */ | 124 unsigned int nmaster; /* number of master clients */ |
125 unsigned int numlockmask; /* dynamic lock mask */ | 125 unsigned int numlockmask; /* dynamic lock mask */ |
126 void (*handler[LASTEvent])(XEvent *); /* event handler */ | 126 void (*handler[LASTEvent])(XEvent *); /* event handler */ |
127 void (*arrange)(void); /* arrange function, indicates mode */ | 127 void (*arrange)(void); /* arrange function, indicates mode */ |
128 Atom wmatom[WMLast], netatom[NetLast]; | 128 Atom wmatom[WMLast], netatom[NetLast]; |
129 Bool running, selscreen, seltag; | 129 Bool running, selscreen, selgroup; |
130 Client *clients, *sel, *stack; /* global client list and stack */ | 130 Client *clients, *sel, *stack; /* global client list and stack */ |
131 Cursor cursor[CurLast]; | 131 Cursor cursor[CurLast]; |
132 DC dc; /* global draw context */ | 132 DC dc; /* global draw context */ |
133 Display *dpy; | 133 Display *dpy; |
134 Window root, barwin; | 134 Window root, barwin; |
175 int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ | 175 int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ |
176 | 176 |
177 /* tag.c */ | 177 /* tag.c */ |
178 void initrregs(void); /* initialize regexps of rules defined in config.h */ | 178 void initrregs(void); /* initialize regexps of rules defined in config.h */ |
179 Client *getnext(Client *c); /* returns next visible client */ | 179 Client *getnext(Client *c); /* returns next visible client */ |
180 void settags(Client *c, Client *trans); /* sets tags of c */ | 180 void setgroup(Client *c, Client *trans); /* sets group of c */ |
181 | 181 |
182 /* util.c */ | 182 /* util.c */ |
183 void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ | 183 void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ |
184 void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */ | 184 void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */ |
185 | 185 |
189 void domax(void); /* arranges all windows fullscreen */ | 189 void domax(void); /* arranges all windows fullscreen */ |
190 Bool isvisible(Client *c); /* returns True if client is visible */ | 190 Bool isvisible(Client *c); /* returns True if client is visible */ |
191 void restack(void); /* restores z layers of all clients */ | 191 void restack(void); /* restores z layers of all clients */ |
192 | 192 |
193 | 193 |
194 void toggleview(void); /* toggle the viewed tag */ | 194 void toggleview(void); /* toggle the viewed group */ |
195 void focusnext(void); /* focuses next visible client */ | 195 void focusnext(void); /* focuses next visible client */ |
196 void zoom(void); /* zooms the focused client to master area */ | 196 void zoom(void); /* zooms the focused client to master area */ |
197 void killclient(void); /* kill c nicely */ | 197 void killclient(void); /* kill c nicely */ |
198 void quit(void); /* quit dwm nicely */ | 198 void quit(void); /* quit dwm nicely */ |
199 void togglemode(void); /* toggles global arrange function (dotile/domax) */ | 199 void togglemode(void); /* toggles global arrange function (dotile/domax) */ |
200 void togglefloat(void); /* toggles focusesd client between floating/non-floating state */ | 200 void togglefloat(void); /* toggles focusesd client between floating/non-floating state */ |
201 void incnmaster(void); /* increments nmaster */ | 201 void incnmaster(void); /* increments nmaster */ |
202 void decnmaster(void); /* decrements nmaster */ | 202 void decnmaster(void); /* decrements nmaster */ |
203 void toggletag(void); /* toggles c tag */ | 203 void togglegroup(void); /* toggles c group */ |
204 void spawn(const char* cmd); /* forks a new subprocess with cmd */ | 204 void spawn(const char* cmd); /* forks a new subprocess with cmd */ |
205 | 205 |
206 | 206 |
207 | 207 |
208 | 208 |
386 drawstatus(); | 386 drawstatus(); |
387 } | 387 } |
388 | 388 |
389 Bool | 389 Bool |
390 isvisible(Client *c) { | 390 isvisible(Client *c) { |
391 if(c->tag == seltag) { | 391 return (c->group == selgroup); |
392 return True; | |
393 } | |
394 return False; | |
395 } | 392 } |
396 | 393 |
397 void | 394 void |
398 restack(void) { | 395 restack(void) { |
399 Client *c; | 396 Client *c; |
445 drawstatus(); | 442 drawstatus(); |
446 } | 443 } |
447 | 444 |
448 void | 445 void |
449 toggleview() { | 446 toggleview() { |
450 seltag = !seltag; | 447 selgroup = !selgroup; |
451 arrange(); | 448 arrange(); |
452 } | 449 } |
453 | 450 |
454 void | 451 void |
455 zoom() { | 452 zoom() { |
579 } | 576 } |
580 } | 577 } |
581 } | 578 } |
582 | 579 |
583 void | 580 void |
584 settags(Client *c, Client *trans) { | 581 setgroup(Client *c, Client *trans) { |
585 char prop[512]; | 582 char prop[512]; |
586 unsigned int i; | 583 unsigned int i; |
587 regmatch_t tmp; | 584 regmatch_t tmp; |
588 Bool matched = trans != NULL; | 585 Bool matched = (trans != NULL); |
589 XClassHint ch = { 0 }; | 586 XClassHint ch = { 0 }; |
590 | 587 |
591 if(matched) { | 588 if(matched) { |
592 c->tag = trans->tag; | 589 c->group = trans->group; |
593 } else { | 590 } else { |
594 XGetClassHint(dpy, c->win, &ch); | 591 XGetClassHint(dpy, c->win, &ch); |
595 snprintf(prop, sizeof prop, "%s:%s:%s", | 592 snprintf(prop, sizeof prop, "%s:%s:%s", |
596 ch.res_class ? ch.res_class : "", | 593 ch.res_class ? ch.res_class : "", |
597 ch.res_name ? ch.res_name : "", c->name); | 594 ch.res_name ? ch.res_name : "", c->name); |
598 for(i = 0; i < len; i++) | 595 for(i = 0; i < len; i++) |
599 if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) { | 596 if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) { |
600 c->isfloat = rule[i].isfloat; | 597 c->isfloat = rule[i].isfloat; |
601 if (rule[i].tag < 0) { | 598 if (rule[i].group < 0) { |
602 c->tag = seltag; | 599 c->group = selgroup; |
603 } else if (rule[i].tag == 0) { | 600 } else if (rule[i].group == 0) { |
604 c->tag = True; | 601 c->group = True; |
605 } else { | 602 } else { |
606 c->tag = False; | 603 c->group = False; |
607 } | 604 } |
608 matched = True; | 605 matched = True; |
609 break; /* perform only the first rule matching */ | 606 break; /* perform only the first rule matching */ |
610 } | 607 } |
611 if(ch.res_class) | 608 if(ch.res_class) |
612 XFree(ch.res_class); | 609 XFree(ch.res_class); |
613 if(ch.res_name) | 610 if(ch.res_name) |
614 XFree(ch.res_name); | 611 XFree(ch.res_name); |
615 } | 612 } |
616 if(!matched) { | 613 if(!matched) { |
617 c->tag = seltag; | 614 c->group = selgroup; |
618 } | 615 } |
619 } | 616 } |
620 | 617 |
621 void | 618 void |
622 toggletag() { | 619 togglegroup() { |
623 if(!sel) | 620 if(!sel) |
624 return; | 621 return; |
625 sel->tag = !sel->tag; | 622 sel->group = !sel->group; |
626 toggleview(); | 623 toggleview(); |
627 } | 624 } |
628 | 625 |
629 | 626 |
630 | 627 |
1052 drawstatus(void) { | 1049 drawstatus(void) { |
1053 int x; | 1050 int x; |
1054 | 1051 |
1055 dc.x = dc.y = 0; | 1052 dc.x = dc.y = 0; |
1056 dc.w = textw(NAMESEL); | 1053 dc.w = textw(NAMESEL); |
1057 drawtext(NAMESEL, ( seltag ? dc.sel : dc.norm )); | 1054 drawtext(NAMESEL, ( selgroup ? dc.sel : dc.norm )); |
1058 dc.x += dc.w + 1; | 1055 dc.x += dc.w + 1; |
1059 dc.w = textw(NAMENSEL); | 1056 dc.w = textw(NAMENSEL); |
1060 drawtext(NAMENSEL, ( seltag ? dc.norm : dc.sel )); | 1057 drawtext(NAMENSEL, ( selgroup ? dc.norm : dc.sel )); |
1061 dc.x += dc.w + 1; | 1058 dc.x += dc.w + 1; |
1062 dc.w = bmw; | 1059 dc.w = bmw; |
1063 drawtext("", dc.norm); | 1060 drawtext("", dc.norm); |
1064 x = dc.x + dc.w; | 1061 x = dc.x + dc.w; |
1065 dc.w = textw(stext); | 1062 dc.w = textw(stext); |
1287 manage(Window w, XWindowAttributes *wa) { | 1284 manage(Window w, XWindowAttributes *wa) { |
1288 Client *c; | 1285 Client *c; |
1289 Window trans; | 1286 Window trans; |
1290 | 1287 |
1291 c = emallocz(sizeof(Client)); | 1288 c = emallocz(sizeof(Client)); |
1292 c->tag = True; | 1289 c->group = True; |
1293 c->win = w; | 1290 c->win = w; |
1294 c->x = wa->x; | 1291 c->x = wa->x; |
1295 c->y = wa->y; | 1292 c->y = wa->y; |
1296 c->w = wa->width; | 1293 c->w = wa->width; |
1297 c->h = wa->height; | 1294 c->h = wa->height; |
1315 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); | 1312 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); |
1316 XGetTransientForHint(dpy, c->win, &trans); | 1313 XGetTransientForHint(dpy, c->win, &trans); |
1317 grabbuttons(c, False); | 1314 grabbuttons(c, False); |
1318 XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]); | 1315 XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]); |
1319 updatetitle(c); | 1316 updatetitle(c); |
1320 settags(c, getclient(trans)); | 1317 setgroup(c, getclient(trans)); |
1321 if(!c->isfloat) | 1318 if(!c->isfloat) |
1322 c->isfloat = trans || c->isfixed; | 1319 c->isfloat = trans || c->isfixed; |
1323 if(clients) | 1320 if(clients) |
1324 clients->prev = c; | 1321 clients->prev = c; |
1325 c->next = clients; | 1322 c->next = clients; |
1588 | EnterWindowMask | LeaveWindowMask; | 1585 | EnterWindowMask | LeaveWindowMask; |
1589 wa.cursor = cursor[CurNormal]; | 1586 wa.cursor = cursor[CurNormal]; |
1590 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); | 1587 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); |
1591 grabkeys(); | 1588 grabkeys(); |
1592 initrregs(); | 1589 initrregs(); |
1593 seltag = True; | 1590 selgroup = True; |
1594 /* style */ | 1591 /* style */ |
1595 dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR); | 1592 dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR); |
1596 dc.norm[ColBG] = getcolor(NORMBGCOLOR); | 1593 dc.norm[ColBG] = getcolor(NORMBGCOLOR); |
1597 dc.norm[ColFG] = getcolor(NORMFGCOLOR); | 1594 dc.norm[ColFG] = getcolor(NORMFGCOLOR); |
1598 dc.sel[ColBorder] = getcolor(SELBORDERCOLOR); | 1595 dc.sel[ColBorder] = getcolor(SELBORDERCOLOR); |