wmii

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

commit b32c8893c066d6569992dcd8b36f5104caef959c
parent a94fc7cf54a4f1eff0776ba2317421003a70a90e
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Mon, 19 Jun 2006 10:38:21 +0200

changed signature of message_view, message_* functions should return an errstr instead of an int


Diffstat:
cmd/wm/client.c | 21+++++++++++----------
cmd/wm/fs2.c | 6+++---
cmd/wm/view.c | 12+++++++-----
cmd/wm/wm.h | 4++--
4 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -683,7 +683,7 @@ size_client(Client *c, char *arg) resize_client(f->client, &new, False); } -int +char * send_client(Frame *f, char *arg) { Area *to, *a; @@ -696,27 +696,28 @@ send_client(Frame *f, char *arg) c = f->client; i = idx_of_area(a); j = idx_of_frame(f); + static char Ebadvalue[] = "bad value"; if((i == -1) || (j == -1)) return 0; if(i && !strncmp(arg, "prev", 5)) { if(a == v->area) - return 0; + return Ebadvalue; 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 0; + return Ebadvalue; send_to_area(to, a, c); } else if(i && !strncmp(arg, "next", 5)) { if(a == v->area) - return 0; + return Ebadvalue; if(!(to = a->next) && (f->anext || f!= a->frame)) to = new_column(v, a, 0); if(!to) - return 0; + return Ebadvalue; send_to_area(to, a, c); } else if(!strncmp(arg, "toggle", 7)) { @@ -731,7 +732,7 @@ send_client(Frame *f, char *arg) else if(i && !strncmp(arg, "up", 3)) { for(tf=a->frame; tf && tf->anext != f; tf=tf->anext); if(!tf) - return 0; + return Ebadvalue; remove_frame(f); insert_frame(tf, f, True); arrange_column(a, False); @@ -739,7 +740,7 @@ send_client(Frame *f, char *arg) } else if(i && !strncmp(arg, "down", 5)) { if(!f->anext) - return 0; + return Ebadvalue; remove_frame(f); insert_frame(f->anext, f, False); arrange_column(a, False); @@ -747,14 +748,14 @@ send_client(Frame *f, char *arg) } else if(i) { if(sscanf(arg, "%d", &j) != 1) - return 0; + return Ebadvalue; for(to=v->area; to && j; to=to->next, j--); send_to_area(to, a, c); } else - return 0; + return Ebadvalue; flush_masked_events(EnterWindowMask); - return 1; + return nil; } void diff --git a/cmd/wm/fs2.c b/cmd/wm/fs2.c @@ -613,7 +613,7 @@ parse_colors(char **buf, int *buflen, BlitzColor *col) { void fs_write(Req *r) { FileId *f; - char *buf; + char *buf, *errstr; unsigned int i; f = r->fid->aux; @@ -670,8 +670,8 @@ fs_write(Req *r) { if(r->ifcall.count == 0) return respond(r, nil); - if(!message_view(f->view, r->ifcall.data)) - return respond(r, Ebadvalue); + if((errstr = message_view(f->view, r->ifcall.data))) + return respond(r, errstr); r->ofcall.count = r->ifcall.count; return respond(r, nil); case FsFRctl: diff --git a/cmd/wm/view.c b/cmd/wm/view.c @@ -369,26 +369,28 @@ view_index(View *v) { } /* XXX: This will need cleanup too */ -int +char * message_view(View *v, char *message) { unsigned int i, n; Frame *f; Client *c; + static char Ebadvalue[] = "bad value"; + if(!strncmp(message, "send ", 5)) { message += 5; if(1 != sscanf(message, "%d %n", &i, &n)) - return 0; + return Ebadvalue; for(c=client; i && c; c=c->next, i--); if(!c) - return 0; + return Ebadvalue; for(f=c->frame; f; f=f->cnext) if(f->area->view == v) break; if(!f) - return 0; + return Ebadvalue; return send_client(f, &message[n]); } - return 0; + return nil; } static Bool diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -243,7 +243,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); -int send_client(Frame *f, char *arg); +char *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); @@ -331,7 +331,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); +char *message_view(View *v, char *message); void restack_view(View *v); View *view_of_name(const char *name); unsigned char * view_index(View *v);