wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 9bc3e63b9a80086090864a65ef52bf4886fa8847
parent 199c419bd8797b47c05774e31aacc4aeb3311ddc
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Thu, 23 Mar 2006 18:08:55 +0100

found a way to remove queueing and to have correct tag info in the bar, which is pretty simple


Diffstat:
cmd/wm/event.c | 4++--
cmd/wm/fs.c | 22+++-------------------
cmd/wm/kb.c | 4++--
cmd/wm/tag.c | 56++++++++++++++++++++------------------------------------
cmd/wm/view.c | 6+++---
cmd/wm/wm.h | 4++--
rc/wmiirc | 27+++++++--------------------
7 files changed, 39 insertions(+), 84 deletions(-)

diff --git a/cmd/wm/event.c b/cmd/wm/event.c @@ -64,7 +64,7 @@ handle_buttonpress(XEvent *e) if(blitz_ispointinrect(ev->x, ev->y, &label[i]->rect)) { snprintf(buf, sizeof(buf), "LabelClick %s %d\n", label[i]->name, ev->button); - write_event(buf, True); + write_event(buf); return; } } @@ -92,7 +92,7 @@ handle_buttonpress(XEvent *e) if(c->nframe) { snprintf(buf, sizeof(buf), "ClientClick %d %d\n", frame2index(c->frame[c->sel]) + 1, ev->button); - write_event(buf, True); + write_event(buf); } } diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c @@ -27,9 +27,6 @@ static char Enofunc[] = "function not supported"; static char Enocommand[] = "command not supported"; static char Ebadvalue[] = "bad value"; -static char **queue = nil; -static unsigned int nqueue = 0, queuesz = 0; - #define WMII_IOUNIT 2048 /* @@ -832,13 +829,6 @@ xread(IXPConn *c, Fcall *fcall) case FsFevent: memcpy(&c->pending, fcall, sizeof(Fcall)); c->is_pending = 1; - if(nqueue) { - char *event = queue[0]; - cext_array_detach((void **)queue, event, &queuesz); - nqueue--; - write_event(event, False); - free(event); - } return nil; break; case FsFkeys: @@ -1373,7 +1363,7 @@ xwrite(IXPConn *c, Fcall *fcall) if(fcall->count) { memcpy(buf, fcall->data, fcall->count); buf[fcall->count] = 0; - write_event(buf, False); + write_event(buf); } break; default: @@ -1430,9 +1420,9 @@ do_fcall(IXPConn *c) } void -write_event(char *event, Bool enqueue) +write_event(char *event) { - unsigned int i, written = 0; + unsigned int i = 0; for(i = 0; (i < srv.connsz) && srv.conn[i]; i++) { IXPConn *c = srv.conn[i]; @@ -1451,14 +1441,8 @@ write_event(char *event, Bool enqueue) if(ixp_server_respond_fcall(c, &c->pending)) return; } - written++; } } - if(enqueue && !written) { - queue = (char **)cext_array_attach((void **)queue, strdup(event), - sizeof(char *), &queuesz); - nqueue++; - } } void diff --git a/cmd/wm/kb.c b/cmd/wm/kb.c @@ -221,7 +221,7 @@ handle_key_seq(Window w, Key **done, unsigned int ndone) case 1: if(!found[0]->next) { snprintf(buf, sizeof(buf), "Key %s\n", found[0]->name); - write_event(buf, True); + write_event(buf); break; } default: @@ -245,7 +245,7 @@ handle_key(Window w, unsigned long mod, KeyCode keycode) case 1: if(!found[0]->next) { snprintf(buf, sizeof(buf), "Key %s\n", found[0]->name); - write_event(buf, True); + write_event(buf); break; } default: diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c @@ -9,11 +9,11 @@ #include "wm.h" Bool -istag(char **tags, unsigned int ntags, char *tag) +istag(char *t) { unsigned int i; - for(i = 0; i < ntags; i++) - if(!strncmp(tags[i], tag, strlen(tag))) + for(i = 0; i < ntag; i++) + if(!strncmp(tag[i], t, strlen(t))) return True; return False; } @@ -48,50 +48,34 @@ void update_tags() { unsigned int i, j; - char buf[256]; - char **newtag = nil; - unsigned int newtagsz = 0, nnewtag = 0; + char buf[1024]; + + for(i = 0; i < ntag; i++) { + free(tag[i]); + tag[i] = nil; + } + ntag = 0; for(i = 0; i < nclient; i++) { for(j = 0; j < client[i]->ntag; j++) { if(!strncmp(client[i]->tag[j], "~", 2)) /* magic floating tag */ continue; - if(!istag(newtag, nnewtag, client[i]->tag[j])) { - newtag = (char **)cext_array_attach((void **)newtag, strdup(client[i]->tag[j]), - sizeof(char *), &newtagsz); - nnewtag++; + if(!istag(client[i]->tag[j])) { + tag = (char **)cext_array_attach((void **)tag, strdup(client[i]->tag[j]), + sizeof(char *), &tagsz); + ntag++; } } } - for(i = 0; i < nview; i++) - if(hasclient(view[i])) { - tags2str(buf, sizeof(buf), view[i]->tag, view[i]->ntag); - if(!istag(newtag, nnewtag, buf)) { - newtag = (char **)cext_array_attach((void **)newtag, strdup(buf), - sizeof(char *), &newtagsz); - nnewtag++; - } - } - - /* propagate tagging events */ - for(i = 0; i < nnewtag; i++) - if(!istag(tag, ntag, newtag[i])) { - snprintf(buf, sizeof(buf), "NewTag %s\n", newtag[i]); - write_event(buf, True); - } + cext_strlcpy(buf, "UpdateTags ", sizeof(buf)); for(i = 0; i < ntag; i++) { - if(!istag(newtag, nnewtag, tag[i])) { - snprintf(buf, sizeof(buf), "RemoveTag %s\n", tag[i]); - write_event(buf, True); - } - free(tag[i]); + cext_strlcat(buf, tag[i], sizeof(buf) - strlen(buf)); + if(i + 1 < ntag) + cext_strlcat(buf, "+", sizeof(buf) - strlen(buf)); } - - free(tag); - tag = newtag; - ntag = nnewtag; - tagsz = newtagsz; + cext_strlcat(buf, "\n", sizeof(buf) - strlen(buf)); + write_event(buf); for(i = 0; nview && (i < nclient); i++) { for(j = 0; j < nview; j++) { diff --git a/cmd/wm/view.c b/cmd/wm/view.c @@ -91,7 +91,7 @@ focus_view(View *v) } tags2str(name, sizeof(name), v->tag, v->ntag); snprintf(buf, sizeof(buf), "FocusTag %s\n", name); - write_event(buf, True); + write_event(buf); XSync(dpy, False); XUngrabServer(dpy); } @@ -188,13 +188,13 @@ select_view(char *arg) if(!v) return; cext_strlcpy(def.tag, arg, sizeof(def.tag)); - if(!istag(tag, ntag, arg)) { + if(!istag(arg)) { char buf[256]; tag = (char **)cext_array_attach((void **)tag, strdup(arg), sizeof(char *), &tagsz); ntag++; snprintf(buf, sizeof(buf), "NewTag %s\n", arg); - write_event(buf, True); + write_event(buf); } focus_view(v); diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -257,7 +257,7 @@ Client *win2clientframe(Window w); /* fs.c */ unsigned long long mkqpath(unsigned char type, unsigned short pg, unsigned short area, unsigned short cl); -void write_event(char *event, Bool enqueue); +void write_event(char *event); void new_ixp_conn(IXPConn *c); /* kb.c */ @@ -280,7 +280,7 @@ void match_tags(Client *c); unsigned int str2tags(char tags[MAX_TAGS][MAX_TAGLEN], const char *stags); void tags2str(char *stags, unsigned int stagsz, char tags[MAX_TAGS][MAX_TAGLEN], unsigned int ntags); -Bool istag(char **tags, unsigned int ntags, char *tag); +Bool istag(char *t); void update_tags(); /* view.c */ diff --git a/rc/wmiirc b/rc/wmiirc @@ -36,6 +36,10 @@ wmiir write /def/rules <<EOF EOF # BAR CONFIGURATION +wmiir create /bar/0tag +xwrite /bar/0tag/colors $WMII_SELCOLORS +wmiir create /bar/0tags +xwrite /bar/0tags/colors $WMII_NORMCOLORS wmiir create /bar/spare xwrite /bar/spare/colors $WMII_SELCOLORS xwrite /bar/expand spare @@ -100,27 +104,10 @@ do then exit fi;; - NewTag) - wmiir create /bar/$1 - if test "X$1" = "X$oldtag" - then - xwrite /bar/$1/colors $WMII_NORMCOLORS - else - xwrite /bar/$1/colors $WMII_SELCOLORS - fi - xwrite /bar/$1/data $1;; - RemoveTag) - wmiir remove /bar/$1;; FocusTag) - if test -n "$oldtag" - then - xwrite /bar/$oldtag/colors $WMII_SELCOLORS - fi - xwrite /bar/$1/data $1 - xwrite /bar/$1/colors $WMII_NORMCOLORS - oldtag=$1;; - LabelClick) - xwrite /ctl view $1;; + xwrite /bar/0tag/data $1;; + UpdateTags) + xwrite /bar/0tags/data $1;; Key) case "$1" in $MODKEY-Control-c)