diff options
author | anselm@anselm1 <unknown> | 2008-02-27 21:50:50 +0000 |
---|---|---|
committer | anselm@anselm1 <unknown> | 2008-02-27 21:50:50 +0000 |
commit | 00ca643bd7ccba6efd001cc679525a53a3c75586 (patch) | |
tree | e7950e6f7c6c4bbfbd3ba8e1f97652332a82de36 | |
parent | 0271ac0ed7b422ffac8ff848193deceedb0872da (diff) |
proceeded, though we still miss a real Tag struct
-rw-r--r-- | config.def.h | 6 | ||||
-rw-r--r-- | dwm.c | 58 |
2 files changed, 39 insertions, 25 deletions
diff --git a/config.def.h b/config.def.h index 9be889c5..b7f2db2d 100644 --- a/config.def.h +++ b/config.def.h @@ -12,8 +12,10 @@ #define SELFGCOLOR "#ffffff" /* tagging */ -const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "www" }; -int initags[LENGTH(tags)] = { [0] = 1 }; +const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "nil", "6", "7", "8", "www" }; +unsigned int vtags[LENGTH(tags)] = { 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 }; +Bool initags[LENGTH(tags)] = { [0] = True, [5] = True }; + Rule rules[] = { /* class:instance:title substr tags ref isfloating */ { "Firefox", tags[8], False }, @@ -67,10 +67,10 @@ struct Client { int x, y, w, h; int basew, baseh, incw, inch, maxw, maxh, minw, minh; int minax, maxax, minay, maxay; - int *tags; long flags; unsigned int border, oldborder; Bool isbanned, isfixed, isfloating, isurgent; + Bool *tags; Client *next; Client *prev; Client *snext; @@ -110,8 +110,12 @@ typedef struct { Bool isfloating; } Rule; +typedef struct { + const char name[MAXTAGLEN]; + unsigned int view; +} Tag; + struct View { - int id; int x, y, w, h, wax, way, wah, waw; double mwfact; Layout *layout; @@ -119,6 +123,7 @@ struct View { }; /* function declarations */ +void addtag(Client *c, const char *t); void applyrules(Client *c); void arrange(void); void attach(Client *c); @@ -153,7 +158,7 @@ long getstate(Window w); Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); void grabbuttons(Client *c, Bool focused); void grabkeys(void); -unsigned int idxoftag(const char *tag); +unsigned int idxoftag(const char *t); void initfont(const char *fontstr); Bool isoccupied(unsigned int t); Bool isprotodel(Client *c); @@ -208,8 +213,6 @@ char stext[256], buf[256]; int nviews = 1; View *selview; int screen; -int *seltags; -int *prevtags; int (*xerrorxlib)(Display *, XErrorEvent *); unsigned int bh, bpos; unsigned int blw = 0; @@ -234,6 +237,8 @@ Bool domwfact = True; Bool dozoom = True; Bool otherwm, readin; Bool running = True; +Bool *prevtags; +Bool *seltags; Client *clients = NULL; Client *sel = NULL; Client *stack = NULL; @@ -248,17 +253,24 @@ Window root; /* function implementations */ void +addtag(Client *c, const char *t) { + unsigned int i, tidx = idxoftag(t); + + for(i = 0; i < LENGTH(tags); i++) + if(c->tags[i] && vtags[i] != vtags[tidx]) + return; /* conflict */ + c->tags[tidx] = True; +} + +void applyrules(Client *c) { unsigned int i; - Bool matched_tag = False; + Bool matched = False; Rule *r; XClassHint ch = { 0 }; /* rule matching */ XGetClassHint(dpy, c->win, &ch); - snprintf(buf, sizeof buf, "%s:%s:%s", - ch.res_class ? ch.res_class : "", - ch.res_name ? ch.res_name : "", c->name); for(i = 0; i < LENGTH(rules); i++) { r = &rules[i]; if(strstr(c->name, r->prop) @@ -267,8 +279,8 @@ applyrules(Client *c) { { c->isfloating = r->isfloating; if(r->tag) { - matched_tag = True; - c->tags[idxoftag(r->tag)] = selview->id; + addtag(c, r->tag); + matched = True; } } } @@ -276,7 +288,7 @@ applyrules(Client *c) { XFree(ch.res_class); if(ch.res_name) XFree(ch.res_name); - if(!matched_tag) + if(!matched) memcpy(c->tags, seltags, sizeof initags); } @@ -532,7 +544,7 @@ drawbar(View *v) { for(c = stack; c && (!isvisible(c) || getview(c) != v); c = c->snext); for(i = 0; i < LENGTH(tags); i++) { dc.w = textw(tags[i]); - if(seltags[i] && seltags[i] == v->id) { + if(seltags[i]) { drawtext(v, tags[i], dc.sel, isurgent(i)); drawsquare(v, c && c->tags[i], isoccupied(i), isurgent(i), dc.sel); } @@ -902,10 +914,10 @@ grabkeys(void) { } unsigned int -idxoftag(const char *tag) { +idxoftag(const char *t) { unsigned int i; - for(i = 0; (i < LENGTH(tags)) && (tags[i] != tag); i++); + for(i = 0; (i < LENGTH(tags)) && (tags[i] != t); i++); return (i < LENGTH(tags)) ? i : 0; } @@ -1559,7 +1571,6 @@ nviews = 2; /* aim Xinerama */ for(i = 0; i < nviews; i++) { /* init geometry */ v = &views[i]; - v->id = i + 1; if(nviews != 1 && isxinerama) { @@ -1653,8 +1664,8 @@ tag(const char *arg) { if(!sel) return; for(i = 0; i < LENGTH(tags); i++) - sel->tags[i] = (NULL == arg) ? selview->id : 0; - sel->tags[idxoftag(arg)] = selview->id; + sel->tags[i] = (NULL == arg); + sel->tags[idxoftag(arg)] = True; arrange(); } @@ -1750,7 +1761,7 @@ toggletag(const char *arg) { sel->tags[i] = !sel->tags[i]; for(j = 0; j < LENGTH(tags) && !sel->tags[j]; j++); if(j == LENGTH(tags)) - sel->tags[i] = selview->id; /* at least one tag must be enabled */ + sel->tags[i] = True; /* at least one tag must be enabled */ arrange(); } @@ -1762,7 +1773,7 @@ toggleview(const char *arg) { seltags[i] = !seltags[i]; for(j = 0; j < LENGTH(tags) && !seltags[j]; j++); if(j == LENGTH(tags)) - seltags[i] = selview->id; /* at least one tag must be viewed */ + seltags[i] = True; /* at least one tag must be viewed */ arrange(); } @@ -1903,11 +1914,12 @@ updatewmhints(Client *c) { void view(const char *arg) { unsigned int i; - int tmp[LENGTH(tags)]; + Bool tmp[LENGTH(tags)]; for(i = 0; i < LENGTH(tags); i++) - tmp[i] = (NULL == arg) ? selview->id : 0; - tmp[idxoftag(arg)] = selview->id; + tmp[i] = (NULL == arg); + tmp[idxoftag(arg)] = True; + if(memcmp(seltags, tmp, sizeof initags) != 0) { memcpy(prevtags, seltags, sizeof initags); memcpy(seltags, tmp, sizeof initags); |