Fix some bugs (fancy debugging code vindicated). Add some comments. Shut up ken.

This commit is contained in:
Kris Maglione 2008-01-28 17:58:23 -05:00
parent 19603410f8
commit 9b76a0aee0
25 changed files with 167 additions and 96 deletions

View File

@ -17,7 +17,7 @@ enum {
| EnterWindowMask | EnterWindowMask
| FocusChangeMask, | FocusChangeMask,
ButtonMask = ButtonPressMask ButtonMask = ButtonPressMask
| ButtonReleaseMask | ButtonReleaseMask,
}; };
static Group* group; static Group* group;
@ -113,7 +113,6 @@ client_create(XWindow w, XWindowAttributes *wa) {
XSetWindowBorderWidth(display, w, 0); XSetWindowBorderWidth(display, w, 0);
XAddToSaveSet(display, w); XAddToSaveSet(display, w);
XSelectInput(display, c->w.w, ClientMask);
fwa.override_redirect = true; fwa.override_redirect = true;
fwa.background_pixmap = None; fwa.background_pixmap = None;
@ -133,6 +132,8 @@ client_create(XWindow w, XWindowAttributes *wa) {
sethandler(c->framewin, &framehandler); sethandler(c->framewin, &framehandler);
sethandler(&c->w, &handlers); sethandler(&c->w, &handlers);
XSelectInput(display, c->w.w, ClientMask);
p.x = def.border; p.x = def.border;
p.y = labelh(def.font); p.y = labelh(def.font);
reparentwindow(&c->w, c->framewin, p); reparentwindow(&c->w, c->framewin, p);
@ -426,6 +427,7 @@ focus(Client *c, bool user) {
View *v; View *v;
Frame *f; Frame *f;
USED(user);
f = c->sel; f = c->sel;
if(!f) if(!f)
return; return;
@ -442,9 +444,10 @@ focus(Client *c, bool user) {
void void
client_focus(Client *c) { client_focus(Client *c) {
static long id;
flushevents(FocusChangeMask, True); 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) {
if(c->noinput) if(c->noinput)
@ -453,8 +456,12 @@ client_focus(Client *c) {
c->group->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) { 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) if(c)
setfocus(&c->w, RevertToParent); setfocus(&c->w, RevertToParent);
else else
@ -462,7 +469,7 @@ client_focus(Client *c) {
event("ClientFocus %C\n", c); event("ClientFocus %C\n", c);
sync(); sync();
flushevents(FocusChangeMask, True); flushevents(FocusChangeMask, true);
} }
} }
@ -534,13 +541,17 @@ client_configure(Client *c) {
sendevent(&c->w, false, StructureNotifyMask, (XEvent*)&e); 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 void
client_kill(Client *c, bool nice) { client_kill(Client *c, bool nice) {
if(nice && (c->proto & ProtoDelete)) { 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); ewmh_pingclient(c);
} }else
else
XKillClient(display, c->w.w); XKillClient(display, c->w.w);
} }
@ -799,12 +810,12 @@ enter_event(Window *w, XCrossingEvent *e) {
c = w->aux; c = w->aux;
if(e->detail != NotifyInferior) { if(e->detail != NotifyInferior) {
if(screen->focus != c) { 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); focus(c, false);
} }
client_setcursor(c, cursor[CurNormal]); client_setcursor(c, cursor[CurNormal]);
}else }else
Dprint(DGeneric, "enter_notify(c[NotifyInferior]) => %s\n", c->name); Dprint(DGeneric, "enter_notify(%C[NotifyInferior]%s)\n", c, c->name);
} }
static void static void
@ -813,7 +824,7 @@ focusin_event(Window *w, XFocusChangeEvent *e) {
c = w->aux; c = w->aux;
print_focus(c, c->name); print_focus("focusin_event", c, c->name);
if(e->mode == NotifyGrab) if(e->mode == NotifyGrab)
screen->hasgrab = c; screen->hasgrab = c;
@ -835,7 +846,7 @@ focusout_event(Window *w, XFocusChangeEvent *e) {
if(screen->focus) if(screen->focus)
screen->hasgrab = screen->focus; screen->hasgrab = screen->focus;
}else if(screen->focus == c) { }else if(screen->focus == c) {
print_focus(&c_magic, "<magic>"); print_focus("focusout_event", &c_magic, "<magic>");
screen->focus = &c_magic; screen->focus = &c_magic;
if(c->sel) if(c->sel)
frame_draw(c->sel); frame_draw(c->sel);

View File

@ -36,12 +36,14 @@ column_new(View *v, Area *pos, uint w) {
a = area_create(v, pos, w); a = area_create(v, pos, w);
return a; return a;
#if 0
if(!a) if(!a)
return nil; return nil;
view_arrange(v); view_arrange(v);
if(v == screen->sel) if(v == screen->sel)
view_focus(screen, v); view_focus(screen, v);
#endif
} }
void void
@ -105,15 +107,10 @@ column_attachrect(Area *a, Frame *f, Rectangle r) {
void void
column_remove(Frame *f) { column_remove(Frame *f) {
Client *c;
Frame *pr; Frame *pr;
Area *a; Area *a;
View *v;
a = f->area; a = f->area;
v = a->view;
c = f->client;
pr = f->aprev; pr = f->aprev;
frame_remove(f); frame_remove(f);

View File

@ -35,6 +35,7 @@ static Bool
findenter(Display *d, XEvent *e, XPointer v) { findenter(Display *d, XEvent *e, XPointer v) {
long *l; long *l;
USED(d);
l = (long*)v; l = (long*)v;
if(*l) if(*l)
return False; return False;
@ -164,9 +165,9 @@ leavenotify(XEvent *e) {
} }
void void
print_focus(Client *c, const char *to) { print_focus(const char *fn, Client *c, const char *to) {
Dprint(DFocus, "screen->focus: %p[%C] => %p[%C]\n", Dprint(DFocus, "%s() screen->focus:\n", fn);
screen->focus, screen->focus, c, c); Dprint(DFocus, "\t%C => %C\n", screen->focus, c);
Dprint(DFocus, "\t%s => %s\n", clientname(screen->focus), to); Dprint(DFocus, "\t%s => %s\n", clientname(screen->focus), to);
} }
@ -179,7 +180,7 @@ focusin(XEvent *e) {
ev = &e->xfocus; ev = &e->xfocus;
/* Yes, we're focusing in on nothing, here. */ /* Yes, we're focusing in on nothing, here. */
if(ev->detail == NotifyDetailNone) { if(ev->detail == NotifyDetailNone) {
print_focus(&c_magic, "<magic[none]>"); print_focus("focusin", &c_magic, "<magic[none]>");
screen->focus = &c_magic; screen->focus = &c_magic;
setfocus(screen->barwin, RevertToParent); setfocus(screen->barwin, RevertToParent);
return; return;
@ -195,7 +196,7 @@ focusin(XEvent *e) {
return; return;
if(ev->window == screen->barwin->w) { if(ev->window == screen->barwin->w) {
print_focus(nil, "<nil>"); print_focus("focusin", nil, "<nil>");
screen->focus = nil; screen->focus = nil;
} }
else if((w = findwin(ev->window))) else if((w = findwin(ev->window)))
@ -205,7 +206,7 @@ focusin(XEvent *e) {
screen->hasgrab = &c_root; screen->hasgrab = &c_root;
/* Some unmanaged window has grabbed focus */ /* Some unmanaged window has grabbed focus */
else if((c = screen->focus)) { else if((c = screen->focus)) {
print_focus(&c_magic, "<magic>"); print_focus("focusin", &c_magic, "<magic>");
screen->focus = &c_magic; screen->focus = &c_magic;
if(c->sel) if(c->sel)
frame_draw(c->sel); frame_draw(c->sel);

View File

@ -30,8 +30,10 @@ ewmh_init(void) {
changeprop_long(&scr.root, Net("SUPPORTING_WM_CHECK"), "WINDOW", win, 1); changeprop_long(&scr.root, Net("SUPPORTING_WM_CHECK"), "WINDOW", win, 1);
changeprop_long(ewmhwin, Net("SUPPORTING_WM_CHECK"), "WINDOW", win, 1); changeprop_long(ewmhwin, Net("SUPPORTING_WM_CHECK"), "WINDOW", win, 1);
changeprop_string(ewmhwin, Net("WM_NAME"), myname); changeprop_string(ewmhwin, Net("WM_NAME"), myname);
long zz[] = {0, 0};
changeprop_long(&scr.root, Net("DESKTOP_VIEWPORT"), "CARDINAL", changeprop_long(&scr.root, Net("DESKTOP_VIEWPORT"), "CARDINAL",
(long[]){0, 0}, 2); zz, 2);
long supported[] = { long supported[] = {
/* Misc */ /* Misc */
@ -137,6 +139,7 @@ static void
pingtimeout(long id, void *v) { pingtimeout(long id, void *v) {
Client *c; Client *c;
USED(id);
c = v; c = v;
event("Unresponsive %C\n", c); event("Unresponsive %C\n", c);
c->w.ewmh.ping = 0; c->w.ewmh.ping = 0;
@ -154,7 +157,7 @@ ewmh_pingclient(Client *c) {
if(e->ping) if(e->ping)
return; 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->ping = xtime++;
e->timer = ixp_settimer(&srv, PingTime, pingtimeout, c); e->timer = ixp_settimer(&srv, PingTime, pingtimeout, c);
} }
@ -179,7 +182,7 @@ struct Prop {
}; };
static long static long
getmask(Prop *props, long *vals, int n) { getmask(Prop *props, ulong *vals, int n) {
Prop *p; Prop *p;
long ret; long ret;
@ -212,10 +215,10 @@ ewmh_getwintype(Client *c) {
{Type("NORMAL"), TypeNormal}, {Type("NORMAL"), TypeNormal},
{0, } {0, }
}; };
long *types; ulong *types;
long n, mask; 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); 0L, &types, 16);
Dprint(DEwmh, "ewmh_getwintype(%C) n = %ld\n", c, n); Dprint(DEwmh, "ewmh_getwintype(%C) n = %ld\n", c, n);
mask = getmask(props, types, n); mask = getmask(props, types, n);
@ -236,10 +239,10 @@ ewmh_protocols(Window *w) {
{Net("WM_PING"), ProtoPing}, {Net("WM_PING"), ProtoPing},
{0, } {0, }
}; };
long *protos; ulong *protos;
long n, mask; long n, mask;
n = getprop_long(w, "WM_PROTOCOLS", "ATOM", n = getprop_ulong(w, "WM_PROTOCOLS", "ATOM",
0L, &protos, 16); 0L, &protos, 16);
Dprint(DEwmh, "ewmh_protocols(%W) n = %ld\n", w, n); Dprint(DEwmh, "ewmh_protocols(%W) n = %ld\n", w, n);
mask = getmask(props, protos, n); mask = getmask(props, protos, n);
@ -299,10 +302,11 @@ int
ewmh_clientmessage(XClientMessageEvent *e) { ewmh_clientmessage(XClientMessageEvent *e) {
Client *c; Client *c;
View *v; View *v;
long *l; ulong *l;
int msg, action, i; ulong msg;
int action, i;
l = e->data.l; l = (ulong*)e->data.l;
msg = e->message_type; msg = e->message_type;
Dprint(DEwmh, "ClientMessage: %A\n", msg); Dprint(DEwmh, "ClientMessage: %A\n", msg);

View File

@ -3,7 +3,10 @@
*/ */
#ifdef VARARGCK #ifdef VARARGCK
# pragma varargck argpos debug 2
# pragma varargck argpos dprint 1
# pragma varargck argpos event 1 # pragma varargck argpos event 1
# pragma varargck argpos warning 1
# #
# pragma varargck type "C" Client* # pragma varargck type "C" Client*
# pragma varargck type "r" void # pragma varargck type "r" void
@ -44,6 +47,7 @@ Frame* client_groupframe(Client*, View*);
void client_kill(Client*, bool); void client_kill(Client*, bool);
void client_manage(Client*); void client_manage(Client*);
void client_map(Client*); void client_map(Client*);
void client_message(Client*, char*, long);
void client_prop(Client*, Atom); void client_prop(Client*, Atom);
void client_reparent(Client*, Window*, Point); void client_reparent(Client*, Window*, Point);
void client_resize(Client*, Rectangle); void client_resize(Client*, Rectangle);
@ -83,7 +87,7 @@ void check_x_event(IxpConn*);
void dispatch_event(XEvent*); void dispatch_event(XEvent*);
uint flushenterevents(void); uint flushenterevents(void);
uint flushevents(long, bool dispatch); uint flushevents(long, bool dispatch);
void print_focus(Client*, const char*); void print_focus(const char*, Client*, const char*);
/* ewmh.c */ /* ewmh.c */
int ewmh_clientmessage(XClientMessageEvent*); int ewmh_clientmessage(XClientMessageEvent*);

View File

@ -136,6 +136,10 @@ frame_restack(Frame *f, Frame *above) {
/* Handlers */ /* Handlers */
static void static void
bup_event(Window *w, XButtonEvent *e) { 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); event("ClientClick %C %d\n", w->aux, e->button);
} }
@ -157,6 +161,7 @@ bdown_event(Window *w, XButtonEvent *e) {
frame_restack(f, nil); frame_restack(f, nil);
view_restack(f->view); view_restack(f->view);
focus(c, false); focus(c, false);
grabpointer(c->framewin, nil, cursor[CurNone], ButtonReleaseMask);
break; break;
case Button3: case Button3:
focus(c, false); focus(c, false);
@ -166,9 +171,7 @@ bdown_event(Window *w, XButtonEvent *e) {
XAllowEvents(display, ReplayPointer, e->time); XAllowEvents(display, ReplayPointer, e->time);
break; break;
} }
if(e->button != Button1) }else {
XUngrabPointer(display, e->time);
}else{
if(e->button == Button1) { if(e->button == Button1) {
if(!e->subwindow) { if(!e->subwindow) {
frame_restack(f, nil); frame_restack(f, nil);
@ -293,7 +296,7 @@ void
frame_resize(Frame *f, Rectangle r) { frame_resize(Frame *f, Rectangle r) {
Client *c; Client *c;
Rectangle fr, cr; Rectangle fr, cr;
int collapsed; int collapsed, dx;
if(Dx(r) <= 0 || Dy(r) <= 0) if(Dx(r) <= 0 || Dy(r) <= 0)
die("Frame rect: %R\n", r); die("Frame rect: %R\n", r);
@ -330,9 +333,11 @@ frame_resize(Frame *f, Rectangle r) {
if(f->area->floating) if(f->area->floating)
f->r = fr; f->r = fr;
else { else {
cr.min.x += ((Dx(fr) - Dx(cr)) - 2 * (cr.min.x - fr.min.x))
/ 2;
f->r = r; 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); f->crect = rectsubpt(cr, f->r.min);
@ -356,7 +361,9 @@ frame_draw(Frame *f) {
return; return;
c = f->client; c = f->client;
fr = rectsetorigin(c->framewin->r, ZP);
/* Pick colors. */
if(c == screen->focus if(c == screen->focus
|| c == selclient()) || c == selclient())
col = &def.focuscolor; col = &def.focuscolor;
@ -368,24 +375,24 @@ frame_draw(Frame *f) {
col = &def.focuscolor; col = &def.focuscolor;
break; break;
} }
fr = c->framewin->r;
fr = rectsubpt(fr, fr.min);
/* background */ /* Background/border */
r = fr; r = fr;
fill(screen->ibuf, r, col->bg); fill(screen->ibuf, r, col->bg);
border(screen->ibuf, r, 1, col->border); border(screen->ibuf, r, 1, col->border);
/* Title border */
r.max.y = r.min.y + labelh(def.font); r.max.y = r.min.y + labelh(def.font);
border(screen->ibuf, r, 1, col->border); border(screen->ibuf, r, 1, col->border);
f->titlebar = insetrect(r, 3); f->titlebar = insetrect(r, 3);
f->titlebar.max.y += 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) if(c != selclient() && col == &def.focuscolor)
border(screen->ibuf, insetrect(r, 1), border(screen->ibuf, insetrect(r, 1), 1, def.normcolor.bg);
1, def.normcolor.bg);
/* grabbox */ /* grabbox */
r.min = Pt(2, 2); r.min = Pt(2, 2);
@ -397,10 +404,12 @@ frame_draw(Frame *f) {
fill(screen->ibuf, r, col->fg); fill(screen->ibuf, r, col->fg);
border(screen->ibuf, r, 1, col->border); 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) if(c != screen->focus && col == &def.focuscolor)
border(screen->ibuf, insetrect(r, -1), border(screen->ibuf, insetrect(r, -1), 1, def.normcolor.bg);
1, def.normcolor.bg);
/* Draw a border on borderless/titleless selected apps. */
if(c->borderless && c->titleless && c == selclient()) if(c->borderless && c->titleless && c == selclient())
setborder(c->framewin, def.border, def.focuscolor.border); setborder(c->framewin, def.border, def.focuscolor.border);
else else
@ -513,12 +522,10 @@ move_focus(Frame *old_f, Frame *f) {
void void
frame_focus(Frame *f) { frame_focus(Frame *f) {
Client *c;
Frame *old_f; Frame *old_f;
View *v; View *v;
Area *a, *old_a; Area *a, *old_a;
c = f->client;
v = f->view; v = f->view;
a = f->area; a = f->area;
old_a = v->sel; old_a = v->sel;

View File

@ -167,10 +167,11 @@ fake_keypress(ulong mod, KeyCode key) {
static Key * static Key *
match_keys(Key *k, ulong mod, KeyCode keycode, bool seq) { 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. */ ret = nil;
for(next = k->tnext; k; (void)((k=next) && (next=k->tnext))) { for(next = k->tnext; k; i = (k=next) && (next=k->tnext)) {
if(seq) if(seq)
k = k->next; k = k->next;
if(k && (k->mod == mod) && (k->key == keycode)) { if(k && (k->mod == mod) && (k->key == keycode)) {

View File

@ -286,7 +286,7 @@ doublefork(void) {
waitpid(pid, &status, 0); waitpid(pid, &status, 0);
return pid; return pid;
} }
return -1; /* not reached */ /* NOTREACHED */
} }
static void static void

View File

@ -838,7 +838,7 @@ warning(const char *fmt, ...) {
va_end(ap); va_end(ap);
event("Warning %s\n", s); event("Warning %s\n", s);
fprint(2, "%s: warning: %s\n", s); fprint(2, "%s: warning: %s\n", argv0, s);
free(s); free(s);
} }

View File

@ -705,7 +705,7 @@ mouse_movegrabbox(Client *c) {
} }
# endif # endif
int static int
thcol(Frame *f) { thcol(Frame *f) {
Framewin *fw; Framewin *fw;
Frame *fprev, *fnext; Frame *fprev, *fnext;
@ -800,7 +800,7 @@ done:
return ret; return ret;
} }
int static int
tvcol(Frame *f) { tvcol(Frame *f) {
Framewin *fw; Framewin *fw;
Window *cwin; Window *cwin;
@ -858,13 +858,13 @@ done:
return ret; return ret;
} }
int static int
tfloat(Frame *f) { tfloat(Frame *f) {
Rectangle *rects; Rectangle *rects;
Rectangle frect, origin; Rectangle frect, origin;
Point pt, pt1; Point pt, pt1;
Client *c; Client *c;
Align align, grav; Align align;
uint nrect, button; uint nrect, button;
int ret; int ret;
@ -885,8 +885,10 @@ tfloat(Frame *f) {
pt = querypointer(&scr.root); pt = querypointer(&scr.root);
pt1 = grabboxcenter(f); pt1 = grabboxcenter(f);
goto casmotion; goto casmotion;
label:
for(;;pt1=pt) for(;;pt1=pt)
switch (readmouse(&pt, &button)) { switch (readmouse(&pt, &button)) {
default: goto label; /* shut up ken */
case MotionNotify: case MotionNotify:
casmotion: casmotion:
origin = rectaddpt(origin, subpt(pt, pt1)); origin = rectaddpt(origin, subpt(pt, pt1));
@ -894,7 +896,7 @@ tfloat(Frame *f) {
frect = origin; frect = origin;
align = Center; 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 = frame_hints(f, frect, Center);
frect = constrain(frect); frect = constrain(frect);
@ -922,7 +924,7 @@ done:
void void
grab_button(XWindow w, uint button, ulong mod) { grab_button(XWindow w, uint button, ulong mod) {
XGrabButton(display, button, mod, w, false, ButtonMask, XGrabButton(display, button, mod, w, false, ButtonMask,
GrabModeSync, GrabModeSync, None, None); GrabModeSync, GrabModeAsync, None, None);
if((mod != AnyModifier) && (numlock_mask != 0)) { if((mod != AnyModifier) && (numlock_mask != 0)) {
XGrabButton(display, button, mod | numlock_mask, w, false, ButtonMask, XGrabButton(display, button, mod | numlock_mask, w, false, ButtonMask,
GrabModeSync, GrabModeAsync, None, None); GrabModeSync, GrabModeAsync, None, None);

View File

@ -29,21 +29,28 @@ toutf8n(const char *str, size_t nstr) {
iconv(cd, nil, nil, nil, nil); iconv(cd, nil, nil, nil, nil);
bsize = nstr * 1.25 + 4; bsize = nstr << 1;
buf = emalloc(bsize); buf = emalloc(bsize);
pos = buf; pos = buf;
nbuf = bsize-1; 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) while(iconv(cd, (void*)&str, &nstr, &pos, &nbuf) == -1)
if(errno == E2BIG) { if(errno == E2BIG) {
bsize *= 1.25 + 4; bsize <<= 1;
nbuf = pos - buf; nbuf = pos - buf;
buf = erealloc(buf, bsize); buf = erealloc(buf, bsize);
pos = buf + nbuf; pos = buf + nbuf;
nbuf = bsize - nbuf - 1; nbuf = bsize - nbuf - 1;
}else }else
break; break;
*pos = '\0'; *pos++ = '\0';
return buf; return erealloc(buf, pos-buf);
} }
char* char*

View File

@ -68,7 +68,7 @@ view_create(const char *name) {
if(!strcmp(name, v->name)) if(!strcmp(name, v->name))
return v; return v;
v = emallocz(sizeof(View)); v = emallocz(sizeof *v);
v->id = id++; v->id = id++;
v->r = screen->r; v->r = screen->r;
v->r.max.y = screen->barwin->r.min.y; v->r.max.y = screen->barwin->r.min.y;

View File

@ -691,6 +691,11 @@ changeprop_long(Window *w, char *prop, char *type, long data[], int len) {
changeproperty(w, prop, type, 32, (uchar*)data, 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 void
changeprop_textlist(Window *w, char *prop, char *type, char *data[]) { changeprop_textlist(Window *w, char *prop, char *type, char *data[]) {
char **p, *s, *t; char **p, *s, *t;
@ -761,6 +766,11 @@ getprop_long(Window *w, char *prop, char *type, ulong offset, long **ret, ulong
return 0; 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** char**
strlistdup(char *list[], int n) { strlistdup(char *list[], int n) {
char **p, *q; char **p, *q;

View File

@ -26,7 +26,7 @@ xdnd_clientmessage(XClientMessageEvent *e) {
Rectangle r; Rectangle r;
Point p; Point p;
long pos, siz; long pos, siz;
int msg; ulong msg;
dnd = nil; dnd = nil;
msg = e->message_type; msg = e->message_type;

View File

@ -185,7 +185,6 @@ xcreate(int argc, char *argv[]) {
static int static int
xremove(int argc, char *argv[]) { xremove(int argc, char *argv[]) {
char *file; char *file;
int n;
ARGBEGIN{ ARGBEGIN{
default: default:
@ -194,10 +193,8 @@ xremove(int argc, char *argv[]) {
file = EARGF(usage()); file = EARGF(usage());
do { do {
if(ixp_remove(client, file) == 0) { if(!ixp_remove(client, file))
fprint(2, "%s: Can't remove file '%s': %r\n", argv0, file); fprint(2, "%s: Can't remove file '%s': %r\n", argv0, file);
n++;
}
}while((file = ARGF())); }while((file = ARGF()));
return 0; return 0;
} }

View File

@ -10,7 +10,7 @@ PREFIX = /usr/local
# Includes and libs # Includes and libs
INCPATH = .:$(ROOT)/include:$(INCLUDE):/usr/include INCPATH = .:$(ROOT)/include:$(INCLUDE):/usr/include
LIBS = -L/usr/lib -lc -L$(ROOT)/lib LIBS = -L/usr/lib -L$(ROOT)/lib
# Flags # Flags
include $(ROOT)/mk/gcc.mk include $(ROOT)/mk/gcc.mk
@ -36,6 +36,14 @@ LIBIXP = $(LIBDIR)/libixp.a
# Operating System Configurations # 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 # *BSD
#LIBICONV = -liconv #LIBICONV = -liconv
# +Darwin # +Darwin

View File

@ -55,6 +55,13 @@ enum{
extern int (*fmtdoquote)(int); extern int (*fmtdoquote)(int);
#ifdef VARARGCK #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 fmtprint 2
# pragma varargck argpos fprint 2 # pragma varargck argpos fprint 2
# pragma varargck argpos print 1 # pragma varargck argpos print 1
@ -67,26 +74,26 @@ extern int (*fmtdoquote)(int);
# pragma varargck argpos snprint 3 # pragma varargck argpos snprint 3
# pragma varargck argpos sprint 2 # pragma varargck argpos sprint 2
# pragma varargck type "lld" vlong # pragma varargck type "lld" _fmt_vlong
# pragma varargck type "llx" vlong # pragma varargck type "llx" _fmt_vlong
# pragma varargck type "lld" uvlong # pragma varargck type "lld" _fmt_uvlong
# pragma varargck type "llx" uvlong # pragma varargck type "llx" _fmt_uvlong
# pragma varargck type "ld" long # pragma varargck type "ld" long
# pragma varargck type "lx" long # pragma varargck type "lx" long
# pragma varargck type "lb" long # pragma varargck type "lb" long
# pragma varargck type "ld" ulong # pragma varargck type "ld" _fmt_ulong
# pragma varargck type "lx" ulong # pragma varargck type "lx" _fmt_ulong
# pragma varargck type "lb" ulong # pragma varargck type "lb" _fmt_ulong
# pragma varargck type "d" int # pragma varargck type "d" int
# pragma varargck type "x" int # pragma varargck type "x" int
# pragma varargck type "c" int # pragma varargck type "c" int
# pragma varargck type "C" int # pragma varargck type "C" int
# pragma varargck type "b" int # pragma varargck type "b" int
# pragma varargck type "d" uint # pragma varargck type "d" _fmt_uint
# pragma varargck type "x" uint # pragma varargck type "x" _fmt_uint
# pragma varargck type "c" uint # pragma varargck type "c" _fmt_uint
# pragma varargck type "C" uint # pragma varargck type "C" _fmt_uint
# pragma varargck type "b" uint # pragma varargck type "b" _fmt_uint
# pragma varargck type "f" double # pragma varargck type "f" double
# pragma varargck type "e" double # pragma varargck type "e" double
# pragma varargck type "g" double # pragma varargck type "g" double

View File

@ -23,9 +23,14 @@ typedef unsigned short ushort;
typedef unsigned int uint; typedef unsigned int uint;
typedef unsigned long ulong; typedef unsigned long ulong;
typedef unsigned long long uvlong; typedef unsigned long long uvlong;
typedef long long vlong; 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 #define strlcat wmii_strlcat
/* util.c */ /* util.c */
void _die(char*, int, char*, ...); void _die(char*, int, char*, ...);
@ -52,7 +57,7 @@ char *argv0;
#undef ARGF #undef ARGF
#undef EARGF #undef EARGF
#define ARGBEGIN \ #define ARGBEGIN \
int _argtmp=0, _inargv=0; char *_argv=nil; \ int _argtmp=0, _inargv; char *_argv=nil; \
if(!argv0) argv0=*argv; argv++, argc--; \ if(!argv0) argv0=*argv; argv++, argc--; \
_inargv=1; USED(_inargv); \ _inargv=1; USED(_inargv); \
while(argc && argv[0][0] == '-') { \ while(argc && argv[0][0] == '-') { \

View File

@ -144,9 +144,9 @@ struct Screen {
#ifdef VARARGCK #ifdef VARARGCK
# pragma varargck type "A" Atom # pragma varargck type "A" Atom
# pragma varargck type "W" Window*
# pragma varargck type "P" Point # pragma varargck type "P" Point
# pragma varargck type "R" Rectangle # pragma varargck type "R" Rectangle
# pragma varargck type "W" Window*
#endif #endif
Display *display; Display *display;
@ -181,6 +181,7 @@ void changeprop_long(Window*, char*, char*, long[], int);
void changeprop_short(Window*, char*, char*, short[], int); void changeprop_short(Window*, char*, char*, short[], int);
void changeprop_string(Window*, char*, char*); void changeprop_string(Window*, char*, char*);
void changeprop_textlist(Window*, char*, 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 changeproperty(Window*, char*, char*, int width, uchar*, int);
void copyimage(Image*, Rectangle, Image*, Point); void copyimage(Image*, Rectangle, Image*, Point);
Window* createwindow(Window *parent, Rectangle, int depth, uint class, WinAttr*, int valuemask); 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); ulong getprop_long(Window*, char*, char*, ulong, long**, ulong);
char* getprop_string(Window*, char*); char* getprop_string(Window*, char*);
int getprop_textlist(Window *w, char *name, char **ret[]); 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); ulong getproperty(Window*, char *prop, char *type, Atom *actual, ulong offset, uchar **ret, ulong length);
int grabpointer(Window*, Window *confine, Cursor, int mask); int grabpointer(Window*, Window *confine, Cursor, int mask);
void initdisplay(void); void initdisplay(void);

View File

@ -11,6 +11,8 @@ depend: ${OBJ:=.depend}
libclean: libclean:
for i in $(LIB) $(OFILES); do \ for i in $(LIB) $(OFILES); do \
[ -e $$i ] && \
echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \
rm -f $$i; \ rm -f $$i; \
done 2>/dev/null || true done 2>/dev/null || true

View File

@ -13,6 +13,7 @@ printinstall:
manyclean: manyclean:
for i in ${TARG:=.o} ${TARG:=.O} $(OFILES); do \ for i in ${TARG:=.o} ${TARG:=.O} $(OFILES); do \
[ -e $$i ] && \
echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \ echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \
rm -f $$i; \ rm -f $$i; \
done 2>/dev/null || true done 2>/dev/null || true

View File

@ -14,6 +14,7 @@ printinstall:
oneclean: oneclean:
for i in $(PROG) $(OFILES); do \ for i in $(PROG) $(OFILES); do \
[ -e $$i ] && \
echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \ echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \
rm -f $$i; \ rm -f $$i; \
done 2>/dev/null || true done 2>/dev/null || true

View File

@ -12,6 +12,8 @@ depend: ${OBJ:=.depend}
soclean: soclean:
for i in $(SO) $(OFILES_PIC); do \ for i in $(SO) $(OFILES_PIC); do \
[ -e $$i ] && \
echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \
rm -f $$i; \ rm -f $$i; \
done 2>/dev/null || true done 2>/dev/null || true

View File

@ -240,16 +240,16 @@ Action rehash
# Tag Bar Setup # Tag Bar Setup
ifs=$wi_nl{ ifs=$wi_nl{
oldbars=`{comm -23 <{wmiir ls /lbar} \ rc -c 'wmiir rm /lbar/^$*' >[2]/dev/null \
`{comm -23 <{wmiir ls /lbar} \
<{wi_tags}} <{wi_tags}}
if(! ~ $oldbars '')
wmiir rm /lbar/^$oldbars
seltag=`{wi_seltag} seltag=`{wi_seltag}
for(tag in `{wi_tags}) { for(tag in `{wi_tags}) {{
if(~ $tag $seltag) if(~ $tag $seltag)
echo $wmiifocuscol $tag | wmiir create /lbar/$tag echo $wmiifocuscol $tag
if not if not
echo $wmiinormcol $tag | wmiir create /lbar/$tag}} echo $wmiinormcol $tag
} | wmiir create /lbar/$tag}}
wi_eventloop wi_eventloop

View File

@ -9,7 +9,7 @@ xtmp=/tmp/cc.$$.$USER.out
echo CC $($bin/cleanname ${BASE}$outfile) echo CC $($bin/cleanname ${BASE}$outfile)
[ -n "$noisycc" ] && echo $CC -o $outfile $CFLAGS $@ [ -n "$noisycc" ] && echo $CC -o $outfile $CFLAGS $@
$CC -o $outfile $CFLAGS $@ 2>$xtmp $CC -o $outfile $CFLAGS $@ 2>&1 >$xtmp
status=$? status=$?
base=$(echo $BASE | sed 's/,/\\,/g') 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" | 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' | 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' | 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 undup 1>&2
rm -f $xtmp rm -f $xtmp