fix drawread, add changes from david tolpin

This commit is contained in:
rsc 2004-04-19 05:56:17 +00:00
parent 904f0d0b42
commit e543c475e7
4 changed files with 36 additions and 32 deletions

View file

@ -744,31 +744,28 @@ drawcoord(uchar *p, uchar *maxp, int oldx, int *newx)
int int
_drawmsgread(Display *d, void *a, int n) _drawmsgread(Display *d, void *a, int n)
{ {
int inbuf; Client *cl;
qlock(&sdraw.lk); qlock(&sdraw.lk);
inbuf = d->obufp - d->obuf; cl = client0;
if(n > inbuf) if(cl->readdata == nil){
n = inbuf; werrstr("no draw data");
memmove(a, d->obuf, n); goto err;
inbuf -= n; }
if(inbuf) if(n < cl->nreaddata){
memmove(d->obuf, d->obufp-inbuf, inbuf); werrstr("short read");
d->obufp = d->obuf+inbuf; goto err;
}
n = cl->nreaddata;
memmove(a, cl->readdata, cl->nreaddata);
free(cl->readdata);
cl->readdata = nil;
qunlock(&sdraw.lk); qunlock(&sdraw.lk);
return n; return n;
}
static void err:
drawmsgsquirrel(Display *d, void *a, int n) qunlock(&sdraw.lk);
{ return -1;
uchar *ep;
ep = d->obuf + d->obufsize;
if(d->obufp + n > ep)
abort();
memmove(d->obufp, a, n);
d->obufp += n;
} }
int int
@ -1086,7 +1083,12 @@ _drawmsgwrite(Display *d, void *v, int n)
i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y, i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y,
i->clipr.min.x, i->clipr.min.y, i->clipr.min.x, i->clipr.min.y,
i->clipr.max.x, i->clipr.max.y); i->clipr.max.x, i->clipr.max.y);
drawmsgsquirrel(d, ibuf, ni); free(client->readdata);
client->readdata = malloc(ni);
if(client->readdata == nil)
goto Enomem;
memmove(client->readdata, ibuf, ni);
client->nreaddata = ni;
client->infoid = -1; client->infoid = -1;
continue; continue;

View file

@ -96,6 +96,7 @@ OFILES=\
x11-init.$O\ x11-init.$O\
x11-itrans.$O\ x11-itrans.$O\
x11-keyboard.$O\ x11-keyboard.$O\
x11-keysym2ucs.$O\
x11-load.$O\ x11-load.$O\
x11-mouse.$O\ x11-mouse.$O\
x11-pixelbits.$O\ x11-pixelbits.$O\

View file

@ -9,21 +9,19 @@
#include <cursor.h> #include <cursor.h>
#include <keyboard.h> #include <keyboard.h>
#include "x11-memdraw.h" #include "x11-memdraw.h"
#include "x11-keysym2ucs.h"
#undef time #undef time
static int static KeySym
__xtoplan9kbd(XEvent *e) __xtoplan9kbd(XEvent *e)
{ {
int ind, k, md; KeySym k;
md = e->xkey.state; if(e->xany.type != KeyPress)
ind = 0; return -1;
if(md & ShiftMask) XLookupString((XKeyEvent*)e,NULL,0,&k,NULL);
ind = 1;
k = XKeycodeToKeysym(e->xany.display, (KeyCode)e->xkey.keycode, ind);
if(k == XK_Multi_key || k == NoSymbol) if(k == XK_Multi_key || k == NoSymbol)
return -1; return -1;
@ -101,7 +99,10 @@ __xtoplan9kbd(XEvent *e)
k = Kalt; k = Kalt;
break; break;
default: /* not ISO-1 or tty control */ default: /* not ISO-1 or tty control */
return -1; if(k>0xff) {
k = keysym2ucs(k);
if(k==-1) return -1;
}
} }
} }
@ -116,7 +117,7 @@ __xtoplan9kbd(XEvent *e)
} }
/* BUG: could/should do Alt translation here! */ /* BUG: could/should do Alt translation here! */
return k; return k+0;
} }
static Rune* static Rune*

View file

@ -73,7 +73,7 @@ initkeyboard(char *file)
if(kc == nil) if(kc == nil)
return nil; return nil;
kc->c = chancreate(sizeof(Rune), 20); kc->c = chancreate(sizeof(Rune), 20);
threadcreate(_ioproc, kc, 4096); threadcreate(_ioproc, kc, 16384);
return kc; return kc;
} }