fix drawread, add changes from david tolpin
This commit is contained in:
parent
904f0d0b42
commit
e543c475e7
4 changed files with 36 additions and 32 deletions
|
|
@ -744,31 +744,28 @@ drawcoord(uchar *p, uchar *maxp, int oldx, int *newx)
|
|||
int
|
||||
_drawmsgread(Display *d, void *a, int n)
|
||||
{
|
||||
int inbuf;
|
||||
Client *cl;
|
||||
|
||||
qlock(&sdraw.lk);
|
||||
inbuf = d->obufp - d->obuf;
|
||||
if(n > inbuf)
|
||||
n = inbuf;
|
||||
memmove(a, d->obuf, n);
|
||||
inbuf -= n;
|
||||
if(inbuf)
|
||||
memmove(d->obuf, d->obufp-inbuf, inbuf);
|
||||
d->obufp = d->obuf+inbuf;
|
||||
cl = client0;
|
||||
if(cl->readdata == nil){
|
||||
werrstr("no draw data");
|
||||
goto err;
|
||||
}
|
||||
if(n < cl->nreaddata){
|
||||
werrstr("short read");
|
||||
goto err;
|
||||
}
|
||||
n = cl->nreaddata;
|
||||
memmove(a, cl->readdata, cl->nreaddata);
|
||||
free(cl->readdata);
|
||||
cl->readdata = nil;
|
||||
qunlock(&sdraw.lk);
|
||||
return n;
|
||||
}
|
||||
|
||||
static void
|
||||
drawmsgsquirrel(Display *d, void *a, int n)
|
||||
{
|
||||
uchar *ep;
|
||||
|
||||
ep = d->obuf + d->obufsize;
|
||||
if(d->obufp + n > ep)
|
||||
abort();
|
||||
memmove(d->obufp, a, n);
|
||||
d->obufp += n;
|
||||
err:
|
||||
qunlock(&sdraw.lk);
|
||||
return -1;
|
||||
}
|
||||
|
||||
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->clipr.min.x, i->clipr.min.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;
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ OFILES=\
|
|||
x11-init.$O\
|
||||
x11-itrans.$O\
|
||||
x11-keyboard.$O\
|
||||
x11-keysym2ucs.$O\
|
||||
x11-load.$O\
|
||||
x11-mouse.$O\
|
||||
x11-pixelbits.$O\
|
||||
|
|
|
|||
|
|
@ -9,21 +9,19 @@
|
|||
#include <cursor.h>
|
||||
#include <keyboard.h>
|
||||
#include "x11-memdraw.h"
|
||||
#include "x11-keysym2ucs.h"
|
||||
|
||||
#undef time
|
||||
|
||||
|
||||
static int
|
||||
static KeySym
|
||||
__xtoplan9kbd(XEvent *e)
|
||||
{
|
||||
int ind, k, md;
|
||||
KeySym k;
|
||||
|
||||
md = e->xkey.state;
|
||||
ind = 0;
|
||||
if(md & ShiftMask)
|
||||
ind = 1;
|
||||
|
||||
k = XKeycodeToKeysym(e->xany.display, (KeyCode)e->xkey.keycode, ind);
|
||||
if(e->xany.type != KeyPress)
|
||||
return -1;
|
||||
XLookupString((XKeyEvent*)e,NULL,0,&k,NULL);
|
||||
if(k == XK_Multi_key || k == NoSymbol)
|
||||
return -1;
|
||||
|
||||
|
|
@ -101,7 +99,10 @@ __xtoplan9kbd(XEvent *e)
|
|||
k = Kalt;
|
||||
break;
|
||||
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! */
|
||||
return k;
|
||||
return k+0;
|
||||
}
|
||||
|
||||
static Rune*
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ initkeyboard(char *file)
|
|||
if(kc == nil)
|
||||
return nil;
|
||||
kc->c = chancreate(sizeof(Rune), 20);
|
||||
threadcreate(_ioproc, kc, 4096);
|
||||
threadcreate(_ioproc, kc, 16384);
|
||||
return kc;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue