Mercurial > aewl
comparison aewl.c @ 766:3f7c68a720b5
undone naming change: "group" is "tag" again (but without plural)
author | meillo@marmaro.de |
---|---|
date | Fri, 05 Dec 2008 19:43:56 +0100 |
parents | 15660880e23d |
children | 706991d15451 |
comparison
equal
deleted
inserted
replaced
765:f1d4bc4afcd9 | 766:3f7c68a720b5 |
---|---|
16 * event dispatching in O(1) time. | 16 * event dispatching in O(1) time. |
17 * | 17 * |
18 * Each child of the root window is called a client, except windows which have | 18 * Each child of the root window is called a client, except windows which have |
19 * set the override_redirect flag. Clients are organized in a global | 19 * set the override_redirect flag. Clients are organized in a global |
20 * doubly-linked client list, the focus history is remembered through a global | 20 * doubly-linked client list, the focus history is remembered through a global |
21 * stack list. Each client contains an array of Bools of the same size as the | 21 * stack list. [...] |
22 * global tags array to indicate the tags of a client. For each client dwm | |
23 * creates a small title window, which is resized whenever the (_NET_)WM_NAME | |
24 * properties are updated or the client is moved/resized. | |
25 * | 22 * |
26 * Keys and tagging rules are organized as arrays and defined in the config.h | 23 * Keys and tagging rules are organized as arrays and defined in the config.h |
27 * file. These arrays are kept static in event.o and tag.o respectively, | 24 * file. These arrays are kept static in event.o and tag.o respectively, |
28 * because no other part of dwm needs access to them. The current mode is | 25 * because no other part of dwm needs access to them. The current mode is |
29 * represented by the arrange() function pointer, which wether points to | 26 * represented by the arrange() function pointer, which wether points to |
30 * domax() or dotile(). | 27 * domax() or dotile(). |
31 * | 28 * |
32 * To understand everything else, start reading main.c:main(). | 29 * To understand everything else, start reading main.c:main(). |
30 * | |
31 * -- and now about aewl -- | |
32 * | |
33 * aewl is a stripped down dwm. It stated as a patchset, but finally forked off | |
34 * completely. The reason for this was the increasing gap between my wish to | |
35 * stay where dwm was, and dwm direction to go further. Further more did I | |
36 * always use only a small subset of dwm's features, so condencing dwm had been | |
37 * my wish for a long time. | |
38 * | |
39 * In aewl clients are either tagged or not (only one tag). Visible are either | |
40 * all tagged clients or all without the tag. | |
33 */ | 41 */ |
42 | |
34 | 43 |
35 #include "config.h" | 44 #include "config.h" |
36 #include <errno.h> | 45 #include <errno.h> |
37 #include <locale.h> | 46 #include <locale.h> |
38 #include <regex.h> | 47 #include <regex.h> |
84 int basew, baseh, incw, inch, maxw, maxh, minw, minh; | 93 int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
85 int minax, minay, maxax, maxay; | 94 int minax, minay, maxax, maxay; |
86 long flags; | 95 long flags; |
87 unsigned int border; | 96 unsigned int border; |
88 Bool isfixed, isfloat, ismax; | 97 Bool isfixed, isfloat, ismax; |
89 Bool group; | 98 Bool tag; |
90 Client *next; | 99 Client *next; |
91 Client *prev; | 100 Client *prev; |
92 Client *snext; | 101 Client *snext; |
93 Window win; | 102 Window win; |
94 }; | 103 }; |
95 | 104 |
96 typedef struct { | 105 typedef struct { |
97 const char *clpattern; | 106 const char *clpattern; |
98 int group; | 107 int tag; |
99 Bool isfloat; | 108 Bool isfloat; |
100 } Rule; | 109 } Rule; |
101 | 110 |
102 typedef struct { | 111 typedef struct { |
103 regex_t *clregex; | 112 regex_t *clregex; |
124 unsigned int nmaster; /* number of master clients */ | 133 unsigned int nmaster; /* number of master clients */ |
125 unsigned int numlockmask; /* dynamic lock mask */ | 134 unsigned int numlockmask; /* dynamic lock mask */ |
126 void (*handler[LASTEvent])(XEvent *); /* event handler */ | 135 void (*handler[LASTEvent])(XEvent *); /* event handler */ |
127 void (*arrange)(void); /* arrange function, indicates mode */ | 136 void (*arrange)(void); /* arrange function, indicates mode */ |
128 Atom wmatom[WMLast], netatom[NetLast]; | 137 Atom wmatom[WMLast], netatom[NetLast]; |
129 Bool running, selscreen, selgroup; | 138 Bool running, selscreen, seltag; |
130 Client *clients, *sel, *stack; /* global client list and stack */ | 139 Client *clients, *sel, *stack; /* global client list and stack */ |
131 Cursor cursor[CurLast]; | 140 Cursor cursor[CurLast]; |
132 DC dc; /* global draw context */ | 141 DC dc; /* global draw context */ |
133 Display *dpy; | 142 Display *dpy; |
134 Window root, barwin; | 143 Window root, barwin; |
175 int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ | 184 int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ |
176 | 185 |
177 /* tag.c */ | 186 /* tag.c */ |
178 void initrregs(void); /* initialize regexps of rules defined in config.h */ | 187 void initrregs(void); /* initialize regexps of rules defined in config.h */ |
179 Client *getnext(Client *c); /* returns next visible client */ | 188 Client *getnext(Client *c); /* returns next visible client */ |
180 void setgroup(Client *c, Client *trans); /* sets group of c */ | 189 void settag(Client *c, Client *trans); /* sets tag of c */ |
181 | 190 |
182 /* util.c */ | 191 /* util.c */ |
183 void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ | 192 void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ |
184 void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */ | 193 void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */ |
185 | 194 |
189 void domax(void); /* arranges all windows fullscreen */ | 198 void domax(void); /* arranges all windows fullscreen */ |
190 Bool isvisible(Client *c); /* returns True if client is visible */ | 199 Bool isvisible(Client *c); /* returns True if client is visible */ |
191 void restack(void); /* restores z layers of all clients */ | 200 void restack(void); /* restores z layers of all clients */ |
192 | 201 |
193 | 202 |
194 void toggleview(void); /* toggle the viewed group */ | 203 void toggleview(void); /* toggle the view */ |
195 void focusnext(void); /* focuses next visible client */ | 204 void focusnext(void); /* focuses next visible client */ |
196 void zoom(void); /* zooms the focused client to master area */ | 205 void zoom(void); /* zooms the focused client to master area */ |
197 void killclient(void); /* kill c nicely */ | 206 void killclient(void); /* kill c nicely */ |
198 void quit(void); /* quit dwm nicely */ | 207 void quit(void); /* quit dwm nicely */ |
199 void togglemode(void); /* toggles global arrange function (dotile/domax) */ | 208 void togglemode(void); /* toggles global arrange function (dotile/domax) */ |
200 void togglefloat(void); /* toggles focusesd client between floating/non-floating state */ | 209 void togglefloat(void); /* toggles focusesd client between floating/non-floating state */ |
201 void incnmaster(void); /* increments nmaster */ | 210 void incnmaster(void); /* increments nmaster */ |
202 void decnmaster(void); /* decrements nmaster */ | 211 void decnmaster(void); /* decrements nmaster */ |
203 void togglegroup(void); /* toggles c group */ | 212 void toggletag(void); /* toggles tag of c */ |
204 void spawn(const char* cmd); /* forks a new subprocess with cmd */ | 213 void spawn(const char* cmd); /* forks a new subprocess with cmd */ |
205 | 214 |
206 | 215 |
207 | 216 |
208 | 217 |
386 drawstatus(); | 395 drawstatus(); |
387 } | 396 } |
388 | 397 |
389 Bool | 398 Bool |
390 isvisible(Client *c) { | 399 isvisible(Client *c) { |
391 return (c->group == selgroup); | 400 return (c->tag == seltag); |
392 } | 401 } |
393 | 402 |
394 void | 403 void |
395 restack(void) { | 404 restack(void) { |
396 Client *c; | 405 Client *c; |
442 drawstatus(); | 451 drawstatus(); |
443 } | 452 } |
444 | 453 |
445 void | 454 void |
446 toggleview() { | 455 toggleview() { |
447 selgroup = !selgroup; | 456 seltag = !seltag; |
448 arrange(); | 457 arrange(); |
449 } | 458 } |
450 | 459 |
451 void | 460 void |
452 zoom() { | 461 zoom() { |
576 } | 585 } |
577 } | 586 } |
578 } | 587 } |
579 | 588 |
580 void | 589 void |
581 setgroup(Client *c, Client *trans) { | 590 settag(Client *c, Client *trans) { |
582 char prop[512]; | 591 char prop[512]; |
583 unsigned int i; | 592 unsigned int i; |
584 regmatch_t tmp; | 593 regmatch_t tmp; |
585 Bool matched = (trans != NULL); | 594 Bool matched = (trans != NULL); |
586 XClassHint ch = { 0 }; | 595 XClassHint ch = { 0 }; |
587 | 596 |
588 if(matched) { | 597 if(matched) { |
589 c->group = trans->group; | 598 c->tag = trans->tag; |
590 } else { | 599 } else { |
591 XGetClassHint(dpy, c->win, &ch); | 600 XGetClassHint(dpy, c->win, &ch); |
592 snprintf(prop, sizeof prop, "%s:%s:%s", | 601 snprintf(prop, sizeof prop, "%s:%s:%s", |
593 ch.res_class ? ch.res_class : "", | 602 ch.res_class ? ch.res_class : "", |
594 ch.res_name ? ch.res_name : "", c->name); | 603 ch.res_name ? ch.res_name : "", c->name); |
595 for(i = 0; i < len && !matched; i++) | 604 for(i = 0; i < len && !matched; i++) |
596 if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) { | 605 if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) { |
597 c->isfloat = rule[i].isfloat; | 606 c->isfloat = rule[i].isfloat; |
598 if (rule[i].group < 0) { | 607 if (rule[i].tag < 0) { |
599 c->group = selgroup; | 608 c->tag = seltag; |
600 } else if (rule[i].group == 0) { | 609 } else if (rule[i].tag) { |
601 c->group = True; | 610 c->tag = True; |
602 } else { | 611 } else { |
603 c->group = False; | 612 c->tag = False; |
604 } | 613 } |
605 matched = True; | 614 matched = True; |
606 } | 615 } |
607 if(ch.res_class) | 616 if(ch.res_class) |
608 XFree(ch.res_class); | 617 XFree(ch.res_class); |
609 if(ch.res_name) | 618 if(ch.res_name) |
610 XFree(ch.res_name); | 619 XFree(ch.res_name); |
611 } | 620 } |
612 if(!matched) { | 621 if(!matched) { |
613 c->group = selgroup; | 622 c->tag = seltag; |
614 } | 623 } |
615 } | 624 } |
616 | 625 |
617 void | 626 void |
618 togglegroup() { | 627 toggletag() { |
619 if(!sel) | 628 if(!sel) |
620 return; | 629 return; |
621 sel->group = !sel->group; | 630 sel->tag = !sel->tag; |
622 toggleview(); | 631 toggleview(); |
623 } | 632 } |
624 | 633 |
625 | 634 |
626 | 635 |
1045 void | 1054 void |
1046 drawstatus(void) { | 1055 drawstatus(void) { |
1047 int x; | 1056 int x; |
1048 | 1057 |
1049 dc.x = dc.y = 0; | 1058 dc.x = dc.y = 0; |
1050 dc.w = textw(NAMESEL); | 1059 dc.w = textw(NAMETAGGED); |
1051 drawtext(NAMESEL, ( selgroup ? dc.sel : dc.norm )); | 1060 drawtext(NAMETAGGED, ( seltag ? dc.sel : dc.norm )); |
1052 dc.x += dc.w + 1; | 1061 dc.x += dc.w + 1; |
1053 dc.w = textw(NAMENSEL); | 1062 dc.w = textw(NAMEUNTAGGED); |
1054 drawtext(NAMENSEL, ( selgroup ? dc.norm : dc.sel )); | 1063 drawtext(NAMEUNTAGGED, ( seltag ? dc.norm : dc.sel )); |
1055 dc.x += dc.w + 1; | 1064 dc.x += dc.w + 1; |
1056 dc.w = bmw; | 1065 dc.w = bmw; |
1057 drawtext("", dc.norm); | 1066 drawtext("", dc.norm); |
1058 x = dc.x + dc.w; | 1067 x = dc.x + dc.w; |
1059 dc.w = textw(stext); | 1068 dc.w = textw(stext); |
1281 manage(Window w, XWindowAttributes *wa) { | 1290 manage(Window w, XWindowAttributes *wa) { |
1282 Client *c; | 1291 Client *c; |
1283 Window trans; | 1292 Window trans; |
1284 | 1293 |
1285 c = emallocz(sizeof(Client)); | 1294 c = emallocz(sizeof(Client)); |
1286 c->group = True; | 1295 c->tag = True; |
1287 c->win = w; | 1296 c->win = w; |
1288 c->x = wa->x; | 1297 c->x = wa->x; |
1289 c->y = wa->y; | 1298 c->y = wa->y; |
1290 c->w = wa->width; | 1299 c->w = wa->width; |
1291 c->h = wa->height; | 1300 c->h = wa->height; |
1309 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); | 1318 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); |
1310 XGetTransientForHint(dpy, c->win, &trans); | 1319 XGetTransientForHint(dpy, c->win, &trans); |
1311 grabbuttons(c, False); | 1320 grabbuttons(c, False); |
1312 XSetWindowBorder(dpy, c->win, dc.norm[ColBG]); | 1321 XSetWindowBorder(dpy, c->win, dc.norm[ColBG]); |
1313 updatetitle(c); | 1322 updatetitle(c); |
1314 setgroup(c, getclient(trans)); | 1323 settag(c, getclient(trans)); |
1315 if(!c->isfloat) | 1324 if(!c->isfloat) |
1316 c->isfloat = trans || c->isfixed; | 1325 c->isfloat = trans || c->isfixed; |
1317 if(clients) | 1326 if(clients) |
1318 clients->prev = c; | 1327 clients->prev = c; |
1319 c->next = clients; | 1328 c->next = clients; |
1582 | EnterWindowMask | LeaveWindowMask; | 1591 | EnterWindowMask | LeaveWindowMask; |
1583 wa.cursor = cursor[CurNormal]; | 1592 wa.cursor = cursor[CurNormal]; |
1584 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); | 1593 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); |
1585 grabkeys(); | 1594 grabkeys(); |
1586 initrregs(); | 1595 initrregs(); |
1587 selgroup = True; | 1596 seltag = True; |
1588 /* style */ | 1597 /* style */ |
1589 dc.norm[ColBG] = getcolor(NORMBGCOLOR); | 1598 dc.norm[ColBG] = getcolor(NORMBGCOLOR); |
1590 dc.norm[ColFG] = getcolor(NORMFGCOLOR); | 1599 dc.norm[ColFG] = getcolor(NORMFGCOLOR); |
1591 dc.sel[ColBG] = getcolor(SELBGCOLOR); | 1600 dc.sel[ColBG] = getcolor(SELBGCOLOR); |
1592 dc.sel[ColFG] = getcolor(SELFGCOLOR); | 1601 dc.sel[ColFG] = getcolor(SELFGCOLOR); |