wmii

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

commit 84ee4cc281bf65f62deb8435a875c3f92907f572
parent 360419c01273787019c32635c97fd7091b77db0f
Author: Kris Maglione <bsdaemon@wmii.de>
Date:   Sun, 18 Jun 2006 16:58:10 -0400

Fixed bad pointer arithmatic in convert.c, added 'send <id> <place>' to /tag/<n>/ctl


Diffstat:
cmd/wm/client.c | 36+++++++++++++++++++++---------------
cmd/wm/fs2.c | 99++++++++++++++++++++++++++++++++++++++++++-------------------------------------
cmd/wm/view.c | 18+++++++++++++++++-
cmd/wm/wm.h | 3++-
libixp/convert.c | 2+-
5 files changed, 94 insertions(+), 64 deletions(-)

diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -683,34 +683,39 @@ size_client(Client *c, char *arg) resize_client(f->client, &new, False); } -void -send_client(Client *c, char *arg) +int +send_client(Frame *f, char *arg) { - Frame *f = c->sel, *tf; - Area *to, *a = f->area; - View *v = a->view; - int i = idx_of_area(a), j = idx_of_frame(f); + Area *to, *a; + Client *c; + Frame *tf; + View *v; + int i = idx_of_area(a), + j = idx_of_frame(f); + a = f->area; + v = a->view; + c = f->client; if((i == -1) || (j == -1)) - return; + return 0; if(i && !strncmp(arg, "prev", 5)) { if(a == v->area) - return; + return 0; for(to=v->area->next; to && a != to->next; to=to->next); if(!to && (f->anext || f != a->frame)) to=new_column(v, v->area, 0); if(!to) - return; + return 0; send_to_area(to, a, c); } else if(i && !strncmp(arg, "next", 5)) { if(a == v->area) - return; + return 0; if(!(to = a->next) && (f->anext || f!= a->frame)) to = new_column(v, a, 0); if(!to) - return; + return 0; send_to_area(to, a, c); } else if(!strncmp(arg, "toggle", 7)) { @@ -725,7 +730,7 @@ send_client(Client *c, char *arg) else if(i && !strncmp(arg, "up", 3)) { for(tf=a->frame; tf && tf->anext != f; tf=tf->anext); if(!tf) - return; + return 0; remove_frame(f); insert_frame(tf, f, True); arrange_column(a, False); @@ -733,7 +738,7 @@ send_client(Client *c, char *arg) } else if(i && !strncmp(arg, "down", 5)) { if(!f->anext) - return; + return 0; remove_frame(f); insert_frame(f->anext, f, False); arrange_column(a, False); @@ -741,13 +746,14 @@ send_client(Client *c, char *arg) } else if(i) { if(sscanf(arg, "%d", &j) != 1) - return; + return 0; for(to=v->area; to && j; to=to->next, j--); send_to_area(to, a, c); } else - return; + return 0; flush_masked_events(EnterWindowMask); + return 1; } void diff --git a/cmd/wm/fs2.c b/cmd/wm/fs2.c @@ -88,56 +88,56 @@ P9Srv p9srv = { /* ad-hoc file tree. Empty names ("") indicate a dynamic entry to be filled * in by lookup_file */ static Dirtab -dirtabroot[]= {{".", QTDIR, FsRoot, 0500|DMDIR }, - {"rbar", QTDIR, FsDBar, 0700|DMDIR }, - {"lbar", QTDIR, FsDBar, 0700|DMDIR }, - {"client", QTDIR, FsDClients, 0500|DMDIR }, - {"tag", QTDIR, FsDTags, 0500|DMDIR }, - {"ctl", QTAPPEND, FsFRctl, 0600|DMAPPEND }, - {"border", QTFILE, FsFBorder, 0600 }, - {"colrules", QTFILE, FsFColRules, 0600 }, - {"event", QTFILE, FsFEvent, 0600 }, - {"font", QTFILE, FsFFont, 0600 }, - {"keys", QTFILE, FsFKeys, 0600 }, - {"normcolors", QTFILE, FsFCNorm, 0600 }, - {"selcolors", QTFILE, FsFCSel, 0600 }, - {"tagrules", QTFILE, FsFTagRules, 0600 }, - {nil}}, -dirtabclients[]={{".", QTDIR, FsDClients, 0500|DMDIR }, - {"", QTDIR, FsDClient, 0500|DMDIR }, - {nil}}, -dirtabclient[]= {{".", QTDIR, FsDClient, 0500|DMDIR }, - {"ctl", QTAPPEND, FsFCctl, 0200|DMAPPEND }, - {"tags", QTFILE, FsFCtags, 0600 }, - {"props", QTFILE, FsFprops, 0400 }, - {nil}}, -dirtabsclient[]={{".", QTDIR, FsDSClient, 0500|DMDIR }, - {"ctl", QTAPPEND, FsFCctl, 0200|DMAPPEND }, - {"index", QTFILE, FsFCindex, 0400 }, - {"tags", QTFILE, FsFCtags, 0600 }, - {"props", QTFILE, FsFprops, 0400 }, - {nil}}, -dirtabbar[]= {{".", QTDIR, FsDBar, 0700|DMDIR }, - {"", QTFILE, FsFBar, 0600 }, - {nil}}, -dirtabtags[]= {{".", QTDIR, FsDTags, 0500|DMDIR }, - {"", QTDIR, FsDTag, 0500|DMDIR }, - {nil}}, -dirtabtag[]= {{".", QTDIR, FsDTag, 0500|DMDIR }, - {"ctl", QTAPPEND, FsFTctl, 0200|DMAPPEND }, - {"index", QTFILE, FsFTindex, 0400 }, - {nil}}; +dirtab_root[]= {{".", QTDIR, FsRoot, 0500|DMDIR }, + {"rbar", QTDIR, FsDBar, 0700|DMDIR }, + {"lbar", QTDIR, FsDBar, 0700|DMDIR }, + {"client", QTDIR, FsDClients, 0500|DMDIR }, + {"tag", QTDIR, FsDTags, 0500|DMDIR }, + {"ctl", QTAPPEND, FsFRctl, 0600|DMAPPEND }, + {"border", QTFILE, FsFBorder, 0600 }, + {"colrules", QTFILE, FsFColRules, 0600 }, + {"event", QTFILE, FsFEvent, 0600 }, + {"font", QTFILE, FsFFont, 0600 }, + {"keys", QTFILE, FsFKeys, 0600 }, + {"normcolors", QTFILE, FsFCNorm, 0600 }, + {"selcolors", QTFILE, FsFCSel, 0600 }, + {"tagrules", QTFILE, FsFTagRules, 0600 }, + {nil}}, +dirtab_clients[]={{".", QTDIR, FsDClients, 0500|DMDIR }, + {"", QTDIR, FsDClient, 0500|DMDIR }, + {nil}}, +dirtab_client[]= {{".", QTDIR, FsDClient, 0500|DMDIR }, + {"ctl", QTAPPEND, FsFCctl, 0200|DMAPPEND }, + {"tags", QTFILE, FsFCtags, 0600 }, + {"props", QTFILE, FsFprops, 0400 }, + {nil}}, +dirtab_sclient[]={{".", QTDIR, FsDSClient, 0500|DMDIR }, + {"ctl", QTAPPEND, FsFCctl, 0200|DMAPPEND }, + {"index", QTFILE, FsFCindex, 0400 }, + {"tags", QTFILE, FsFCtags, 0600 }, + {"props", QTFILE, FsFprops, 0400 }, + {nil}}, +dirtab_bar[]= {{".", QTDIR, FsDBar, 0700|DMDIR }, + {"", QTFILE, FsFBar, 0600 }, + {nil}}, +dirtab_tags[]= {{".", QTDIR, FsDTags, 0500|DMDIR }, + {"", QTDIR, FsDTag, 0500|DMDIR }, + {nil}}, +dirtab_tag[]= {{".", QTDIR, FsDTag, 0500|DMDIR }, + {"ctl", QTAPPEND, FsFTctl, 0200|DMAPPEND }, + {"index", QTFILE, FsFTindex, 0400 }, + {nil}}; /* Writing the lists separately and using an array of their references * removes the need for casting and allows for C90 conformance, * since otherwise we would need to use compound literals */ static Dirtab *dirtab[] = { - [FsRoot] dirtabroot, - [FsDBar] dirtabbar, - [FsDClients] dirtabclients, - [FsDClient] dirtabclient, - [FsDSClient] dirtabsclient, - [FsDTags] dirtabtags, - [FsDTag] dirtabtag + [FsRoot] dirtab_root, + [FsDBar] dirtab_bar, + [FsDClients] dirtab_clients, + [FsDClient] dirtab_client, + [FsDSClient] dirtab_sclient, + [FsDTags] dirtab_tags, + [FsDTag] dirtab_tag }; /* get_file/free_file save and reuse old FileId structs @@ -662,6 +662,13 @@ fs_write(Req *r) { draw_clients(); r->ofcall.count = r->ifcall.count - i; return respond(r, nil); + case FsFTctl: + data_to_cstring(r); + + if(!message_view(f->view, r->ifcall.data)) + return respond(r, Ebadvalue); + r->ofcall.count = r->ifcall.count; + return respond(r, nil); case FsFRctl: data_to_cstring(r); diff --git a/cmd/wm/view.c b/cmd/wm/view.c @@ -370,7 +370,23 @@ view_index(View *v) { /* XXX: This will need cleanup too */ int -view_message(View *v, char *message) { +message_view(View *v, char *message) { + unsigned int i, n; + Frame *f; + Area *a; + if(!strncmp(message, "send", 5)) { + message += 5; + if(2 != sscanf(message, "%d %n", &i, &n)) + return 0; + for(a=v->area; a; a=a->next) + for(f=a->frame; f; f=f->anext) + if(f->client->id == i) + goto found_client; + found_client: + if(!f) + return 0; + return send_client(f, &message[5]); + } return 0; } diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -285,7 +285,7 @@ void resize_client(Client *c, XRectangle *r, Bool ignore_xcall); void select_client(Client *c, char *arg); Client *selected_client(); void match_sizehints(Client *c, XRectangle *r, Bool floating, BlitzAlign sticky); -void send_client(Client *c, char *arg); +int send_client(Frame *f, char *arg); void move_client(Client *c, char *arg); void size_client(Client *c, char *arg); void newcol_client(Client *c, char *arg); @@ -373,6 +373,7 @@ void select_view(const char *arg); void detach_from_view(View *v, Client *c); void attach_to_view(View *v, Client *c); Client *sel_client_of_view(View *v); +int message_view(View *v, char *message); void restack_view(View *v); View *view_of_name(const char *name); unsigned char * view_index(View *v); diff --git a/libixp/convert.c b/libixp/convert.c @@ -129,7 +129,7 @@ ixp_unpack_string(unsigned char **msg, char **string, unsigned short *len) /* XXX we don't really need emallocz here */ *string = cext_emallocz(*len+1); memcpy(*string, *msg, *len); - string[*len] = 0; + (*string)[*len] = 0; *msg += *len; }