From 9b76a0aee06af1e362096631928fb242493ffd17 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 28 Jan 2008 17:58:23 -0500 Subject: [PATCH] Fix some bugs (fancy debugging code vindicated). Add some comments. Shut up ken. --- cmd/wmii/client.c | 35 +++++++++++++++++++++++------------ cmd/wmii/column.c | 7 ++----- cmd/wmii/event.c | 15 ++++++++------- cmd/wmii/ewmh.c | 24 ++++++++++++++---------- cmd/wmii/fns.h | 6 +++++- cmd/wmii/frame.c | 41 ++++++++++++++++++++++++----------------- cmd/wmii/key.c | 7 ++++--- cmd/wmii/main.c | 2 +- cmd/wmii/message.c | 2 +- cmd/wmii/mouse.c | 14 ++++++++------ cmd/wmii/utf.c | 15 +++++++++++---- cmd/wmii/view.c | 2 +- cmd/wmii/x11.c | 10 ++++++++++ cmd/wmii/xdnd.c | 2 +- cmd/wmiir.c | 5 +---- config.mk | 10 +++++++++- include/fmt.h | 31 +++++++++++++++++++------------ include/util.h | 9 +++++++-- include/x11.h | 4 +++- mk/lib.mk | 2 ++ mk/many.mk | 1 + mk/one.mk | 1 + mk/so.mk | 2 ++ rc/rc.wmii.rc | 12 ++++++------ util/compile | 4 +++- 25 files changed, 167 insertions(+), 96 deletions(-) diff --git a/cmd/wmii/client.c b/cmd/wmii/client.c index 7da826d3..fe2e2349 100644 --- a/cmd/wmii/client.c +++ b/cmd/wmii/client.c @@ -17,7 +17,7 @@ enum { | EnterWindowMask | FocusChangeMask, ButtonMask = ButtonPressMask - | ButtonReleaseMask + | ButtonReleaseMask, }; static Group* group; @@ -113,7 +113,6 @@ client_create(XWindow w, XWindowAttributes *wa) { XSetWindowBorderWidth(display, w, 0); XAddToSaveSet(display, w); - XSelectInput(display, c->w.w, ClientMask); fwa.override_redirect = true; fwa.background_pixmap = None; @@ -133,6 +132,8 @@ client_create(XWindow w, XWindowAttributes *wa) { sethandler(c->framewin, &framehandler); sethandler(&c->w, &handlers); + XSelectInput(display, c->w.w, ClientMask); + p.x = def.border; p.y = labelh(def.font); reparentwindow(&c->w, c->framewin, p); @@ -426,6 +427,7 @@ focus(Client *c, bool user) { View *v; Frame *f; + USED(user); f = c->sel; if(!f) return; @@ -442,9 +444,10 @@ focus(Client *c, bool user) { void client_focus(Client *c) { + static long id; flushevents(FocusChangeMask, True); - Dprint(DFocus, "client_focus(%p[%C]) => %s\n", c, c, clientname(c)); + Dprint(DFocus, "client_focus([%C]%s) %ld\n", c, clientname(c), id++); if(c) { if(c->noinput) @@ -453,8 +456,12 @@ client_focus(Client *c) { c->group->client = c; } + sync(); + flushevents(FocusChangeMask, true); + Dprint(DFocus, "client_focus([%C]%s) %ld\n", c, clientname(c), id); if(screen->focus != c) { - Dprint(DFocus, "\t%s => %s\n", clientname(screen->focus), clientname(c)); + Dprint(DFocus, "\t[%C]%s => [%C]%s\n", screen->focus, clientname(screen->focus), + c, clientname(c)); if(c) setfocus(&c->w, RevertToParent); else @@ -462,7 +469,7 @@ client_focus(Client *c) { event("ClientFocus %C\n", c); sync(); - flushevents(FocusChangeMask, True); + flushevents(FocusChangeMask, true); } } @@ -534,13 +541,17 @@ client_configure(Client *c) { sendevent(&c->w, false, StructureNotifyMask, (XEvent*)&e); } +void +client_message(Client *c, char *msg, long l2) { + sendmessage(&c->w, "WM_PROTOCOLS", xatom(msg), xtime, l2, 0, 0); +} + void client_kill(Client *c, bool nice) { if(nice && (c->proto & ProtoDelete)) { - sendmessage(&c->w, "WM_PROTOCOLS", xatom("WM_DELETE_WINDOW"), xtime, 0, 0, 0); + client_message(c, "WM_DELETE_WINDOW", 0); ewmh_pingclient(c); - } - else + }else XKillClient(display, c->w.w); } @@ -799,12 +810,12 @@ enter_event(Window *w, XCrossingEvent *e) { c = w->aux; if(e->detail != NotifyInferior) { if(screen->focus != c) { - Dprint(DGeneric, "enter_notify(c) => %s\n", c->name); + Dprint(DGeneric, "enter_notify([%C]%s)\n", c, c->name); focus(c, false); } client_setcursor(c, cursor[CurNormal]); }else - Dprint(DGeneric, "enter_notify(c[NotifyInferior]) => %s\n", c->name); + Dprint(DGeneric, "enter_notify(%C[NotifyInferior]%s)\n", c, c->name); } static void @@ -813,7 +824,7 @@ focusin_event(Window *w, XFocusChangeEvent *e) { c = w->aux; - print_focus(c, c->name); + print_focus("focusin_event", c, c->name); if(e->mode == NotifyGrab) screen->hasgrab = c; @@ -835,7 +846,7 @@ focusout_event(Window *w, XFocusChangeEvent *e) { if(screen->focus) screen->hasgrab = screen->focus; }else if(screen->focus == c) { - print_focus(&c_magic, ""); + print_focus("focusout_event", &c_magic, ""); screen->focus = &c_magic; if(c->sel) frame_draw(c->sel); diff --git a/cmd/wmii/column.c b/cmd/wmii/column.c index 8eb83b82..c9cafbf6 100644 --- a/cmd/wmii/column.c +++ b/cmd/wmii/column.c @@ -36,12 +36,14 @@ column_new(View *v, Area *pos, uint w) { a = area_create(v, pos, w); return a; +#if 0 if(!a) return nil; view_arrange(v); if(v == screen->sel) view_focus(screen, v); +#endif } void @@ -105,15 +107,10 @@ column_attachrect(Area *a, Frame *f, Rectangle r) { void column_remove(Frame *f) { - Client *c; Frame *pr; Area *a; - View *v; a = f->area; - v = a->view; - c = f->client; - pr = f->aprev; frame_remove(f); diff --git a/cmd/wmii/event.c b/cmd/wmii/event.c index 54c3f694..8f347e8a 100644 --- a/cmd/wmii/event.c +++ b/cmd/wmii/event.c @@ -35,6 +35,7 @@ static Bool findenter(Display *d, XEvent *e, XPointer v) { long *l; + USED(d); l = (long*)v; if(*l) return False; @@ -164,9 +165,9 @@ leavenotify(XEvent *e) { } void -print_focus(Client *c, const char *to) { - Dprint(DFocus, "screen->focus: %p[%C] => %p[%C]\n", - screen->focus, screen->focus, c, c); +print_focus(const char *fn, Client *c, const char *to) { + Dprint(DFocus, "%s() screen->focus:\n", fn); + Dprint(DFocus, "\t%C => %C\n", screen->focus, c); Dprint(DFocus, "\t%s => %s\n", clientname(screen->focus), to); } @@ -179,7 +180,7 @@ focusin(XEvent *e) { ev = &e->xfocus; /* Yes, we're focusing in on nothing, here. */ if(ev->detail == NotifyDetailNone) { - print_focus(&c_magic, ""); + print_focus("focusin", &c_magic, ""); screen->focus = &c_magic; setfocus(screen->barwin, RevertToParent); return; @@ -195,7 +196,7 @@ focusin(XEvent *e) { return; if(ev->window == screen->barwin->w) { - print_focus(nil, ""); + print_focus("focusin", nil, ""); screen->focus = nil; } else if((w = findwin(ev->window))) @@ -205,7 +206,7 @@ focusin(XEvent *e) { screen->hasgrab = &c_root; /* Some unmanaged window has grabbed focus */ else if((c = screen->focus)) { - print_focus(&c_magic, ""); + print_focus("focusin", &c_magic, ""); screen->focus = &c_magic; if(c->sel) frame_draw(c->sel); @@ -231,7 +232,7 @@ focusout(XEvent *e) { if((ev->mode == NotifyGrab) && XCheckMaskEvent(display, KeyPressMask, &me)) - dispatch_event(&me); + dispatch_event(&me); else if((w = findwin(ev->window))) handle(w, focusout, ev); } diff --git a/cmd/wmii/ewmh.c b/cmd/wmii/ewmh.c index 48ff7957..8d483252 100644 --- a/cmd/wmii/ewmh.c +++ b/cmd/wmii/ewmh.c @@ -30,8 +30,10 @@ ewmh_init(void) { changeprop_long(&scr.root, Net("SUPPORTING_WM_CHECK"), "WINDOW", win, 1); changeprop_long(ewmhwin, Net("SUPPORTING_WM_CHECK"), "WINDOW", win, 1); changeprop_string(ewmhwin, Net("WM_NAME"), myname); + + long zz[] = {0, 0}; changeprop_long(&scr.root, Net("DESKTOP_VIEWPORT"), "CARDINAL", - (long[]){0, 0}, 2); + zz, 2); long supported[] = { /* Misc */ @@ -137,6 +139,7 @@ static void pingtimeout(long id, void *v) { Client *c; + USED(id); c = v; event("Unresponsive %C\n", c); c->w.ewmh.ping = 0; @@ -154,7 +157,7 @@ ewmh_pingclient(Client *c) { if(e->ping) return; - sendmessage(&c->w, "WM_PROTOCOLS", NET("WM_PING"), xtime, c->w.w, 0, 0); + client_message(c, Net("WM_PING"), c->w.w); e->ping = xtime++; e->timer = ixp_settimer(&srv, PingTime, pingtimeout, c); } @@ -179,7 +182,7 @@ struct Prop { }; static long -getmask(Prop *props, long *vals, int n) { +getmask(Prop *props, ulong *vals, int n) { Prop *p; long ret; @@ -212,10 +215,10 @@ ewmh_getwintype(Client *c) { {Type("NORMAL"), TypeNormal}, {0, } }; - long *types; + ulong *types; long n, mask; - n = getprop_long(&c->w, Net("WM_WINDOW_TYPE"), "ATOM", + n = getprop_ulong(&c->w, Net("WM_WINDOW_TYPE"), "ATOM", 0L, &types, 16); Dprint(DEwmh, "ewmh_getwintype(%C) n = %ld\n", c, n); mask = getmask(props, types, n); @@ -236,10 +239,10 @@ ewmh_protocols(Window *w) { {Net("WM_PING"), ProtoPing}, {0, } }; - long *protos; + ulong *protos; long n, mask; - n = getprop_long(w, "WM_PROTOCOLS", "ATOM", + n = getprop_ulong(w, "WM_PROTOCOLS", "ATOM", 0L, &protos, 16); Dprint(DEwmh, "ewmh_protocols(%W) n = %ld\n", w, n); mask = getmask(props, protos, n); @@ -299,10 +302,11 @@ int ewmh_clientmessage(XClientMessageEvent *e) { Client *c; View *v; - long *l; - int msg, action, i; + ulong *l; + ulong msg; + int action, i; - l = e->data.l; + l = (ulong*)e->data.l; msg = e->message_type; Dprint(DEwmh, "ClientMessage: %A\n", msg); diff --git a/cmd/wmii/fns.h b/cmd/wmii/fns.h index cc429392..20cc37e3 100644 --- a/cmd/wmii/fns.h +++ b/cmd/wmii/fns.h @@ -3,7 +3,10 @@ */ #ifdef VARARGCK +# pragma varargck argpos debug 2 +# pragma varargck argpos dprint 1 # pragma varargck argpos event 1 +# pragma varargck argpos warning 1 # # pragma varargck type "C" Client* # pragma varargck type "r" void @@ -44,6 +47,7 @@ Frame* client_groupframe(Client*, View*); void client_kill(Client*, bool); void client_manage(Client*); void client_map(Client*); +void client_message(Client*, char*, long); void client_prop(Client*, Atom); void client_reparent(Client*, Window*, Point); void client_resize(Client*, Rectangle); @@ -83,7 +87,7 @@ void check_x_event(IxpConn*); void dispatch_event(XEvent*); uint flushenterevents(void); uint flushevents(long, bool dispatch); -void print_focus(Client*, const char*); +void print_focus(const char*, Client*, const char*); /* ewmh.c */ int ewmh_clientmessage(XClientMessageEvent*); diff --git a/cmd/wmii/frame.c b/cmd/wmii/frame.c index af6266bd..24217169 100644 --- a/cmd/wmii/frame.c +++ b/cmd/wmii/frame.c @@ -136,6 +136,10 @@ frame_restack(Frame *f, Frame *above) { /* Handlers */ static void bup_event(Window *w, XButtonEvent *e) { + if((e->state & def.mod) != def.mod) + XAllowEvents(display, ReplayPointer, e->time); + else + XUngrabPointer(display, e->time); event("ClientClick %C %d\n", w->aux, e->button); } @@ -157,6 +161,7 @@ bdown_event(Window *w, XButtonEvent *e) { frame_restack(f, nil); view_restack(f->view); focus(c, false); + grabpointer(c->framewin, nil, cursor[CurNone], ButtonReleaseMask); break; case Button3: focus(c, false); @@ -166,9 +171,7 @@ bdown_event(Window *w, XButtonEvent *e) { XAllowEvents(display, ReplayPointer, e->time); break; } - if(e->button != Button1) - XUngrabPointer(display, e->time); - }else{ + }else { if(e->button == Button1) { if(!e->subwindow) { frame_restack(f, nil); @@ -293,7 +296,7 @@ void frame_resize(Frame *f, Rectangle r) { Client *c; Rectangle fr, cr; - int collapsed; + int collapsed, dx; if(Dx(r) <= 0 || Dy(r) <= 0) die("Frame rect: %R\n", r); @@ -330,9 +333,11 @@ frame_resize(Frame *f, Rectangle r) { if(f->area->floating) f->r = fr; else { - cr.min.x += ((Dx(fr) - Dx(cr)) - 2 * (cr.min.x - fr.min.x)) - / 2; f->r = r; + dx = Dx(r) - Dx(cr); + dx -= 2 * (cr.min.x - fr.min.x); + cr.min.x += dx / 2; + cr.max.x += dx / 2; } f->crect = rectsubpt(cr, f->r.min); @@ -356,7 +361,9 @@ frame_draw(Frame *f) { return; c = f->client; + fr = rectsetorigin(c->framewin->r, ZP); + /* Pick colors. */ if(c == screen->focus || c == selclient()) col = &def.focuscolor; @@ -368,24 +375,24 @@ frame_draw(Frame *f) { col = &def.focuscolor; break; } - fr = c->framewin->r; - fr = rectsubpt(fr, fr.min); - /* background */ + /* Background/border */ r = fr; fill(screen->ibuf, r, col->bg); border(screen->ibuf, r, 1, col->border); + /* Title border */ r.max.y = r.min.y + labelh(def.font); border(screen->ibuf, r, 1, col->border); f->titlebar = insetrect(r, 3); f->titlebar.max.y += 3; - /* Odd state of focus. */ + /* Odd focus. Ulselected, with keyboard focus. */ + /* Draw a border just inside the titlebar. */ + /* FIXME: Perhaps this should be normcolored? */ if(c != selclient() && col == &def.focuscolor) - border(screen->ibuf, insetrect(r, 1), - 1, def.normcolor.bg); + border(screen->ibuf, insetrect(r, 1), 1, def.normcolor.bg); /* grabbox */ r.min = Pt(2, 2); @@ -397,10 +404,12 @@ frame_draw(Frame *f) { fill(screen->ibuf, r, col->fg); border(screen->ibuf, r, 1, col->border); - /* Odd state of focus. */ + /* Odd focus. Selected, without keyboard focus. */ + /* Draw a border around the grabbox. */ if(c != screen->focus && col == &def.focuscolor) - border(screen->ibuf, insetrect(r, -1), - 1, def.normcolor.bg); + border(screen->ibuf, insetrect(r, -1), 1, def.normcolor.bg); + + /* Draw a border on borderless/titleless selected apps. */ if(c->borderless && c->titleless && c == selclient()) setborder(c->framewin, def.border, def.focuscolor.border); else @@ -513,12 +522,10 @@ move_focus(Frame *old_f, Frame *f) { void frame_focus(Frame *f) { - Client *c; Frame *old_f; View *v; Area *a, *old_a; - c = f->client; v = f->view; a = f->area; old_a = v->sel; diff --git a/cmd/wmii/key.c b/cmd/wmii/key.c index dbf9f9b9..1d0e85d3 100644 --- a/cmd/wmii/key.c +++ b/cmd/wmii/key.c @@ -167,10 +167,11 @@ fake_keypress(ulong mod, KeyCode key) { static Key * match_keys(Key *k, ulong mod, KeyCode keycode, bool seq) { - Key *ret = nil, *next; + Key *ret, *next; + volatile int i; /* shut up ken */ - /* I *hate* GCC 4. */ - for(next = k->tnext; k; (void)((k=next) && (next=k->tnext))) { + ret = nil; + for(next = k->tnext; k; i = (k=next) && (next=k->tnext)) { if(seq) k = k->next; if(k && (k->mod == mod) && (k->key == keycode)) { diff --git a/cmd/wmii/main.c b/cmd/wmii/main.c index 11fd907e..d8149b69 100644 --- a/cmd/wmii/main.c +++ b/cmd/wmii/main.c @@ -286,7 +286,7 @@ doublefork(void) { waitpid(pid, &status, 0); return pid; } - return -1; /* not reached */ + /* NOTREACHED */ } static void diff --git a/cmd/wmii/message.c b/cmd/wmii/message.c index 33ec2ba3..f6751486 100644 --- a/cmd/wmii/message.c +++ b/cmd/wmii/message.c @@ -838,7 +838,7 @@ warning(const char *fmt, ...) { va_end(ap); event("Warning %s\n", s); - fprint(2, "%s: warning: %s\n", s); + fprint(2, "%s: warning: %s\n", argv0, s); free(s); } diff --git a/cmd/wmii/mouse.c b/cmd/wmii/mouse.c index f7946817..3df577c6 100644 --- a/cmd/wmii/mouse.c +++ b/cmd/wmii/mouse.c @@ -705,7 +705,7 @@ mouse_movegrabbox(Client *c) { } # endif -int +static int thcol(Frame *f) { Framewin *fw; Frame *fprev, *fnext; @@ -800,7 +800,7 @@ done: return ret; } -int +static int tvcol(Frame *f) { Framewin *fw; Window *cwin; @@ -858,13 +858,13 @@ done: return ret; } -int +static int tfloat(Frame *f) { Rectangle *rects; Rectangle frect, origin; Point pt, pt1; Client *c; - Align align, grav; + Align align; uint nrect, button; int ret; @@ -885,8 +885,10 @@ tfloat(Frame *f) { pt = querypointer(&scr.root); pt1 = grabboxcenter(f); goto casmotion; +label: for(;;pt1=pt) switch (readmouse(&pt, &button)) { + default: goto label; /* shut up ken */ case MotionNotify: casmotion: origin = rectaddpt(origin, subpt(pt, pt1)); @@ -894,7 +896,7 @@ tfloat(Frame *f) { frect = origin; align = Center; - grav = snap_rect(rects, nrect, &frect, &align, def.snap); + snap_rect(rects, nrect, &frect, &align, def.snap); frect = frame_hints(f, frect, Center); frect = constrain(frect); @@ -922,7 +924,7 @@ done: void grab_button(XWindow w, uint button, ulong mod) { XGrabButton(display, button, mod, w, false, ButtonMask, - GrabModeSync, GrabModeSync, None, None); + GrabModeSync, GrabModeAsync, None, None); if((mod != AnyModifier) && (numlock_mask != 0)) { XGrabButton(display, button, mod | numlock_mask, w, false, ButtonMask, GrabModeSync, GrabModeAsync, None, None); diff --git a/cmd/wmii/utf.c b/cmd/wmii/utf.c index a5e3228f..039b3bc4 100644 --- a/cmd/wmii/utf.c +++ b/cmd/wmii/utf.c @@ -29,21 +29,28 @@ toutf8n(const char *str, size_t nstr) { iconv(cd, nil, nil, nil, nil); - bsize = nstr * 1.25 + 4; + bsize = nstr << 1; buf = emalloc(bsize); pos = buf; nbuf = bsize-1; + /* The (void*) cast is because, while the BSDs declare: + * size_t iconv(iconv_t, const char**, size_t*, char**, size_t*), + * GNU/Linux and POSIX declare: + * size_t iconv(iconv_t, char**, size_t*, char**, size_t*). + * This just happens to be safer than declaring our own + * prototype. + */ while(iconv(cd, (void*)&str, &nstr, &pos, &nbuf) == -1) if(errno == E2BIG) { - bsize *= 1.25 + 4; + bsize <<= 1; nbuf = pos - buf; buf = erealloc(buf, bsize); pos = buf + nbuf; nbuf = bsize - nbuf - 1; }else break; - *pos = '\0'; - return buf; + *pos++ = '\0'; + return erealloc(buf, pos-buf); } char* diff --git a/cmd/wmii/view.c b/cmd/wmii/view.c index c5c8ee65..6f04322c 100644 --- a/cmd/wmii/view.c +++ b/cmd/wmii/view.c @@ -68,7 +68,7 @@ view_create(const char *name) { if(!strcmp(name, v->name)) return v; - v = emallocz(sizeof(View)); + v = emallocz(sizeof *v); v->id = id++; v->r = screen->r; v->r.max.y = screen->barwin->r.min.y; diff --git a/cmd/wmii/x11.c b/cmd/wmii/x11.c index 9da27a31..88f4f22c 100644 --- a/cmd/wmii/x11.c +++ b/cmd/wmii/x11.c @@ -691,6 +691,11 @@ changeprop_long(Window *w, char *prop, char *type, long data[], int len) { changeproperty(w, prop, type, 32, (uchar*)data, len); } +void +changeprop_ulong(Window *w, char *prop, char *type, ulong data[], int len) { + changeproperty(w, prop, type, 32, (uchar*)data, len); +} + void changeprop_textlist(Window *w, char *prop, char *type, char *data[]) { char **p, *s, *t; @@ -761,6 +766,11 @@ getprop_long(Window *w, char *prop, char *type, ulong offset, long **ret, ulong return 0; } +ulong +getprop_ulong(Window *w, char *prop, char *type, ulong offset, ulong **ret, ulong length) { + return getprop_long(w, prop, type, offset, (long**)ret, length); +} + char** strlistdup(char *list[], int n) { char **p, *q; diff --git a/cmd/wmii/xdnd.c b/cmd/wmii/xdnd.c index c814df33..7d962424 100644 --- a/cmd/wmii/xdnd.c +++ b/cmd/wmii/xdnd.c @@ -26,7 +26,7 @@ xdnd_clientmessage(XClientMessageEvent *e) { Rectangle r; Point p; long pos, siz; - int msg; + ulong msg; dnd = nil; msg = e->message_type; diff --git a/cmd/wmiir.c b/cmd/wmiir.c index 6d87f8a7..428f10d5 100644 --- a/cmd/wmiir.c +++ b/cmd/wmiir.c @@ -185,7 +185,6 @@ xcreate(int argc, char *argv[]) { static int xremove(int argc, char *argv[]) { char *file; - int n; ARGBEGIN{ default: @@ -194,10 +193,8 @@ xremove(int argc, char *argv[]) { file = EARGF(usage()); do { - if(ixp_remove(client, file) == 0) { + if(!ixp_remove(client, file)) fprint(2, "%s: Can't remove file '%s': %r\n", argv0, file); - n++; - } }while((file = ARGF())); return 0; } diff --git a/config.mk b/config.mk index 6844f917..2eddf18f 100644 --- a/config.mk +++ b/config.mk @@ -10,7 +10,7 @@ PREFIX = /usr/local # Includes and libs INCPATH = .:$(ROOT)/include:$(INCLUDE):/usr/include -LIBS = -L/usr/lib -lc -L$(ROOT)/lib +LIBS = -L/usr/lib -L$(ROOT)/lib # Flags include $(ROOT)/mk/gcc.mk @@ -36,6 +36,14 @@ LIBIXP = $(LIBDIR)/libixp.a # Operating System Configurations +# KenCC +# Note: wmii *must* always compile under KenCC. It's vital for +# argument checking in formatted IO, and similar diagnostics. +#CFLAGS = -wF +#STATIC = # Implied +#CC=pcc -c +#LD=pcc + # *BSD #LIBICONV = -liconv # +Darwin diff --git a/include/fmt.h b/include/fmt.h index af13eaa6..4b3a98af 100644 --- a/include/fmt.h +++ b/include/fmt.h @@ -55,6 +55,13 @@ enum{ extern int (*fmtdoquote)(int); #ifdef VARARGCK +/* *sigh* */ + typedef unsigned char _fmt_uchar; + typedef unsigned short _fmt_ushort; + typedef unsigned int _fmt_uint; + typedef unsigned long _fmt_ulong; + typedef unsigned long long _fmt_uvlong; + typedef long long _fmt_vlong; # pragma varargck argpos fmtprint 2 # pragma varargck argpos fprint 2 # pragma varargck argpos print 1 @@ -67,26 +74,26 @@ extern int (*fmtdoquote)(int); # pragma varargck argpos snprint 3 # pragma varargck argpos sprint 2 -# pragma varargck type "lld" vlong -# pragma varargck type "llx" vlong -# pragma varargck type "lld" uvlong -# pragma varargck type "llx" uvlong +# pragma varargck type "lld" _fmt_vlong +# pragma varargck type "llx" _fmt_vlong +# pragma varargck type "lld" _fmt_uvlong +# pragma varargck type "llx" _fmt_uvlong # pragma varargck type "ld" long # pragma varargck type "lx" long # pragma varargck type "lb" long -# pragma varargck type "ld" ulong -# pragma varargck type "lx" ulong -# pragma varargck type "lb" ulong +# pragma varargck type "ld" _fmt_ulong +# pragma varargck type "lx" _fmt_ulong +# pragma varargck type "lb" _fmt_ulong # pragma varargck type "d" int # pragma varargck type "x" int # pragma varargck type "c" int # pragma varargck type "C" int # pragma varargck type "b" int -# pragma varargck type "d" uint -# pragma varargck type "x" uint -# pragma varargck type "c" uint -# pragma varargck type "C" uint -# pragma varargck type "b" uint +# pragma varargck type "d" _fmt_uint +# pragma varargck type "x" _fmt_uint +# pragma varargck type "c" _fmt_uint +# pragma varargck type "C" _fmt_uint +# pragma varargck type "b" _fmt_uint # pragma varargck type "f" double # pragma varargck type "e" double # pragma varargck type "g" double diff --git a/include/util.h b/include/util.h index 173af212..ddd577bc 100644 --- a/include/util.h +++ b/include/util.h @@ -23,9 +23,14 @@ typedef unsigned short ushort; typedef unsigned int uint; typedef unsigned long ulong; typedef unsigned long long uvlong; - typedef long long vlong; +#ifdef VARARGCK +# pragma varargck argpos _die 3 +# pragma varargck argpos fatal 1 +# pragma varargck argpos sxprint 1 +#endif + #define strlcat wmii_strlcat /* util.c */ void _die(char*, int, char*, ...); @@ -52,7 +57,7 @@ char *argv0; #undef ARGF #undef EARGF #define ARGBEGIN \ - int _argtmp=0, _inargv=0; char *_argv=nil; \ + int _argtmp=0, _inargv; char *_argv=nil; \ if(!argv0) argv0=*argv; argv++, argc--; \ _inargv=1; USED(_inargv); \ while(argc && argv[0][0] == '-') { \ diff --git a/include/x11.h b/include/x11.h index e85c5fce..c5fb1a64 100644 --- a/include/x11.h +++ b/include/x11.h @@ -144,9 +144,9 @@ struct Screen { #ifdef VARARGCK # pragma varargck type "A" Atom -# pragma varargck type "W" Window* # pragma varargck type "P" Point # pragma varargck type "R" Rectangle +# pragma varargck type "W" Window* #endif Display *display; @@ -181,6 +181,7 @@ void changeprop_long(Window*, char*, char*, long[], int); void changeprop_short(Window*, char*, char*, short[], int); void changeprop_string(Window*, char*, char*); void changeprop_textlist(Window*, char*, char*, char*[]); +void changeprop_ulong(Window*, char*, char*, ulong[], int); void changeproperty(Window*, char*, char*, int width, uchar*, int); void copyimage(Image*, Rectangle, Image*, Point); Window* createwindow(Window *parent, Rectangle, int depth, uint class, WinAttr*, int valuemask); @@ -201,6 +202,7 @@ void freestringlist(char**); ulong getprop_long(Window*, char*, char*, ulong, long**, ulong); char* getprop_string(Window*, char*); int getprop_textlist(Window *w, char *name, char **ret[]); +ulong getprop_ulong(Window*, char*, char*, ulong, ulong**, ulong); ulong getproperty(Window*, char *prop, char *type, Atom *actual, ulong offset, uchar **ret, ulong length); int grabpointer(Window*, Window *confine, Cursor, int mask); void initdisplay(void); diff --git a/mk/lib.mk b/mk/lib.mk index 606d1d55..a557520a 100644 --- a/mk/lib.mk +++ b/mk/lib.mk @@ -11,6 +11,8 @@ depend: ${OBJ:=.depend} libclean: for i in $(LIB) $(OFILES); do \ + [ -e $$i ] && \ + echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \ rm -f $$i; \ done 2>/dev/null || true diff --git a/mk/many.mk b/mk/many.mk index 321b62f5..506e2351 100644 --- a/mk/many.mk +++ b/mk/many.mk @@ -13,6 +13,7 @@ printinstall: manyclean: for i in ${TARG:=.o} ${TARG:=.O} $(OFILES); do \ + [ -e $$i ] && \ echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \ rm -f $$i; \ done 2>/dev/null || true diff --git a/mk/one.mk b/mk/one.mk index 0adb1023..e5ca455e 100644 --- a/mk/one.mk +++ b/mk/one.mk @@ -14,6 +14,7 @@ printinstall: oneclean: for i in $(PROG) $(OFILES); do \ + [ -e $$i ] && \ echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \ rm -f $$i; \ done 2>/dev/null || true diff --git a/mk/so.mk b/mk/so.mk index 10a8a0ed..25cd81de 100644 --- a/mk/so.mk +++ b/mk/so.mk @@ -12,6 +12,8 @@ depend: ${OBJ:=.depend} soclean: for i in $(SO) $(OFILES_PIC); do \ + [ -e $$i ] && \ + echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \ rm -f $$i; \ done 2>/dev/null || true diff --git a/rc/rc.wmii.rc b/rc/rc.wmii.rc index 869513f1..37736f9d 100755 --- a/rc/rc.wmii.rc +++ b/rc/rc.wmii.rc @@ -240,16 +240,16 @@ Action rehash # Tag Bar Setup ifs=$wi_nl{ - oldbars=`{comm -23 <{wmiir ls /lbar} \ + rc -c 'wmiir rm /lbar/^$*' >[2]/dev/null \ + `{comm -23 <{wmiir ls /lbar} \ <{wi_tags}} - if(! ~ $oldbars '') - wmiir rm /lbar/^$oldbars seltag=`{wi_seltag} - for(tag in `{wi_tags}) { + for(tag in `{wi_tags}) {{ if(~ $tag $seltag) - echo $wmiifocuscol $tag | wmiir create /lbar/$tag + echo $wmiifocuscol $tag if not - echo $wmiinormcol $tag | wmiir create /lbar/$tag}} + echo $wmiinormcol $tag + } | wmiir create /lbar/$tag}} wi_eventloop diff --git a/util/compile b/util/compile index 440c3cdd..ecf29a10 100755 --- a/util/compile +++ b/util/compile @@ -9,7 +9,7 @@ xtmp=/tmp/cc.$$.$USER.out echo CC $($bin/cleanname ${BASE}$outfile) [ -n "$noisycc" ] && echo $CC -o $outfile $CFLAGS $@ -$CC -o $outfile $CFLAGS $@ 2>$xtmp +$CC -o $outfile $CFLAGS $@ 2>&1 >$xtmp status=$? base=$(echo $BASE | sed 's/,/\\,/g') @@ -57,6 +57,8 @@ undup() { # GCC is crap. cat $xtmp | sed "s,^$re,$base&,g; s,\([[:space:]]\)$re,\1$base\2,g" | egrep -v ': error: .Each undeclared identifier|: error: for each function it appears|is dangerous, better use|is almost always misused|: In function |: At top level:|support .long long.|use of C99 long long|ISO C forbids conversion' | sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' | + awk '$1 == "warning:"{t=$2" "$1; sub(/^[^ ]+ [^ ]+ /, ""); $0 = t" "$0}; //' | + awk '{sub(/\[/, ": [", $1); print}' | undup 1>&2 rm -f $xtmp