wmii

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

commit cc572f14f18e16785515cb65ff96f3375f0b29d3
parent 38cb6fdc0dc4eb0c04aaa3f7ab70433fde118249
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Thu, 23 Mar 2006 08:43:26 +0100

implemented event queueing and fixed a bug in rule.c reported by usa


Diffstat:
cmd/wm/event.c | 6+++---
cmd/wm/fs.c | 28+++++++++++++++++++++-------
cmd/wm/kb.c | 4++--
cmd/wm/rule.c | 1+
cmd/wm/tag.c | 8++++----
cmd/wm/wm.h | 2+-
6 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/cmd/wm/event.c b/cmd/wm/event.c @@ -64,7 +64,7 @@ handle_buttonpress(XEvent *e) for(i = 0; i < nlabel; i++) 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); + write_event(buf, True); return; } } @@ -77,7 +77,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); + write_event(buf, True); } } else if((c = win2client(ev->window))) { @@ -104,7 +104,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); + write_event(buf, True); } } diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c @@ -27,6 +27,8 @@ 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 /* @@ -839,6 +841,12 @@ 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); + } return nil; break; case FsFkeys: @@ -1396,7 +1404,7 @@ xwrite(IXPConn *c, Fcall *fcall) if(fcall->count) { memcpy(buf, fcall->data, fcall->count); buf[fcall->count] = 0; - write_event(buf); + write_event(buf, False); } break; default: @@ -1453,28 +1461,34 @@ do_fcall(IXPConn *c) } void -write_event(char *event) +write_event(char *event, Bool enqueue) { - unsigned int i; + unsigned int i, written = 0; + for(i = 0; (i < srv.connsz) && srv.conn[i]; i++) { IXPConn *c = srv.conn[i]; if(c->is_pending) { /* pending reads on /event only, no qid checking */ IXPMap *m = ixp_server_fid2map(c, c->pending.fid); - unsigned char *p = c->pending.data; if(!m) { if(ixp_server_respond_error(c, &c->pending, Enofile)) - break; + return; } else if(qpath_type(m->qid.path) == FsFevent) { + /* pending reads on /event only, no qid checking */ c->pending.count = strlen(event); - memcpy(p, event, c->pending.count); + memcpy(c->pending.data, event, c->pending.count); c->pending.id = RREAD; if(ixp_server_respond_fcall(c, &c->pending)) - break; + return; } + written++; } } + if(!written) { + queue = (char **)cext_array_attach((void **)queue, event, sizeof(char *), &queuesz); + nqueue++; + } } void diff --git a/cmd/wm/kb.c b/cmd/wm/kb.c @@ -220,7 +220,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); + write_event(buf, True); break; } default: @@ -244,7 +244,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); + write_event(buf, True); break; } default: diff --git a/cmd/wm/rule.c b/cmd/wm/rule.c @@ -63,6 +63,7 @@ parse(char *data, unsigned int *n) } else if(*p == '>') { mode = TAGS; + tags[0] = 0; t = tags; } break; diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c @@ -102,7 +102,7 @@ focus_tag(Tag *t) } tags2str(name, sizeof(name), t->tag, t->ntag); snprintf(buf, sizeof(buf), "FocusTag %s\n", name); - write_event(buf); + write_event(buf, True); XSync(dpy, False); XUngrabServer(dpy); } @@ -205,7 +205,7 @@ select_tag(char *arg) sizeof(char *), &ctagsz); nctag++; snprintf(buf, sizeof(buf), "NewTag %s\n", arg); - write_event(buf); + write_event(buf, True); } focus_tag(t); @@ -290,12 +290,12 @@ update_tags() for(i = 0; i < nnewctag; i++) if(!istag(ctag, nctag, newctag[i])) { snprintf(buf, sizeof(buf), "NewTag %s\n", newctag[i]); - write_event(buf); + write_event(buf, True); } for(i = 0; i < nctag; i++) { if(!istag(newctag, nnewctag, ctag[i])) { snprintf(buf, sizeof(buf), "RemoveTag %s\n", ctag[i]); - write_event(buf); + write_event(buf, True); } free(ctag[i]); } diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -264,7 +264,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); +void write_event(char *event, Bool enqueue); void new_ixp_conn(IXPConn *c); /* kb.c */