From af78a4cd2b73800af86db8d999d80b1ef0e9bd75 Mon Sep 17 00:00:00 2001 From: rsc Date: Tue, 2 Mar 2004 23:11:58 +0000 Subject: Little tweaks and documentation. --- src/cmd/9term/9term.c | 4 ++-- src/cmd/acme/look.c | 2 ++ src/cmd/samterm/mesg.c | 6 +----- src/cmd/samterm/mkfile | 2 +- src/cmd/samterm/plan9.c | 34 +++++++++++----------------------- src/libdraw/x11-init.c | 2 ++ src/libdraw/x11-wsys.c | 5 ++++- 7 files changed, 23 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/cmd/9term/9term.c b/src/cmd/9term/9term.c index cfee0013..41a0a2f7 100644 --- a/src/cmd/9term/9term.c +++ b/src/cmd/9term/9term.c @@ -147,7 +147,7 @@ hostproc(void *arg) i = 0; for(;;){ i = 1-i; /* toggle */ - n = read(rcfd[0], rcbuf[i].data, sizeof rcbuf[i].data); + n = threadread(rcfd[0], rcbuf[i].data, sizeof rcbuf[i].data); if(n <= 0){ if(n < 0) fprint(2, "9term: host read error: %r\n"); @@ -163,7 +163,7 @@ void hoststart(void) { hostc = chancreate(sizeof(int), 0); - proccreate(hostproc, hostc, 32*1024); + threadcreate(hostproc, hostc, 32*1024); } void diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c index ca7eba42..6b259288 100644 --- a/src/cmd/acme/look.c +++ b/src/cmd/acme/look.c @@ -196,6 +196,7 @@ plumblook(Plumbmsg *m) openfile(nil, &e); free(e.name); free(e.u.at); + drawtopwindow(); } void @@ -234,6 +235,7 @@ plumbshow(Plumbmsg *m) winsettag(w); textscrdraw(&w->body); textsetselect(&w->tag, w->tag.file->b.nc, w->tag.file->b.nc); + drawtopwindow(); } int diff --git a/src/cmd/samterm/mesg.c b/src/cmd/samterm/mesg.c index 0bffad3d..20528431 100644 --- a/src/cmd/samterm/mesg.c +++ b/src/cmd/samterm/mesg.c @@ -25,7 +25,7 @@ long invlong(int); void hsetdot(int, long, long); void hmoveto(int, long); void hsetsnarf(int); -/* void hplumb(int); */ +void hplumb(int); void clrlock(void); int snarfswap(char*, int, char**); @@ -296,11 +296,9 @@ inmesg(Hmesg type, int count) threadexitsall(nil); break; -/* case Hplumb: hplumb(m); break; -*/ } } @@ -668,7 +666,6 @@ hsetsnarf(int nc) setcursor(mousectl, cursor); } -/* void hplumb(int nc) { @@ -687,7 +684,6 @@ hplumb(int nc) } free(s); } -*/ void hgrow(int m, long a, long new, int req) diff --git a/src/cmd/samterm/mkfile b/src/cmd/samterm/mkfile index 67997f39..facc78d2 100644 --- a/src/cmd/samterm/mkfile +++ b/src/cmd/samterm/mkfile @@ -23,6 +23,6 @@ HFILES=\ CFLAGS=$CFLAGS -I../sam LDFLAGS=$LDFLAGS -L$X11/lib -lX11 -lm -SHORTLIB=frame draw thread regexp9 bio 9 +SHORTLIB=frame draw plumb fs mux thread regexp9 bio 9 <$PLAN9/src/mkone diff --git a/src/cmd/samterm/plan9.c b/src/cmd/samterm/plan9.c index 60ef5c0e..7c4ed39b 100644 --- a/src/cmd/samterm/plan9.c +++ b/src/cmd/samterm/plan9.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "flayer.h" #include "samterm.h" @@ -170,20 +171,15 @@ extstart(void) atexit(removeextern); } -#if 0 int -plumbformat(int i) +plumbformat(Plumbmsg *m, int i) { - Plumbmsg *m; char *addr, *data, *act; int n; data = (char*)plumbbuf[i].data; - m = plumbunpack(data, plumbbuf[i].n); - if(m == nil) - return 0; n = m->ndata; - if(n == 0){ + if(n == 0 || 2+n+2 >= READBUFSIZE){ plumbfree(m); return 0; } @@ -219,8 +215,9 @@ void plumbproc(void *argv) { Channel *c; - int i, n, which, *fdp; + int i, *fdp; void **arg; + Plumbmsg *m; arg = argv; c = arg[0]; @@ -229,16 +226,14 @@ plumbproc(void *argv) i = 0; threadfdnoblock(*fdp); for(;;){ - i = 1-i; /* toggle */ - n = threadread(*fdp, plumbbuf[i].data, READBUFSIZE); - if(n <= 0){ + m = threadplumbrecv(*fdp); + if(m == nil){ fprint(2, "samterm: plumb read error: %r\n"); threadexits("plumb"); /* not a fatal error */ } - plumbbuf[i].n = n; - if(plumbformat(i)){ - which = i; - send(c, &which); + if(plumbformat(m, i)){ + send(c, &i); + i = 1-i; /* toggle */ } } } @@ -258,18 +253,11 @@ plumbstart(void) close(fd); return -1; } - arg[0] =plumbc; + arg[0] = plumbc; arg[1] = &fd; threadcreate(plumbproc, arg, STACK); return 1; } -#endif - -int -plumbstart(void) -{ - return -1; -} void hostproc(void *arg) diff --git a/src/libdraw/x11-init.c b/src/libdraw/x11-init.c index fb6a9144..1283f430 100644 --- a/src/libdraw/x11-init.c +++ b/src/libdraw/x11-init.c @@ -124,6 +124,8 @@ xerror(XDisplay *d, XErrorEvent *e) { char buf[200]; + if(e->request_code == 42) /* XSetInputFocus */ + return 0; print("X error: error_code=%d, request_code=%d, minor=%d disp=%p\n", e->error_code, e->request_code, e->minor_code, d); XGetErrorText(d, e->error_code, buf, sizeof buf); diff --git a/src/libdraw/x11-wsys.c b/src/libdraw/x11-wsys.c index ac4aa40c..e27202f5 100644 --- a/src/libdraw/x11-wsys.c +++ b/src/libdraw/x11-wsys.c @@ -8,7 +8,10 @@ void drawtopwindow(void) { - XRaiseWindow(_x.display, _x.drawable); + XMapRaised(_x.display, _x.drawable); + XFlush(_x.display); + XSetInputFocus(_x.display, _x.drawable, RevertToPointerRoot, + CurrentTime); XFlush(_x.display); } -- cgit v1.2.3