mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
use new thread library
This commit is contained in:
parent
d9f3e89e5e
commit
b20f06ab9c
6 changed files with 20 additions and 17 deletions
|
@ -10,7 +10,7 @@ int _drawdebug;
|
|||
static char deffontname[] = "*default*";
|
||||
Screen *_screen;
|
||||
|
||||
int debuglockdisplay = 0;
|
||||
int debuglockdisplay = 1;
|
||||
|
||||
static void
|
||||
drawshutdown(void)
|
||||
|
@ -34,6 +34,7 @@ initdraw(void (*error)(Display*, char*), char *fontname, char *label)
|
|||
if(display == nil)
|
||||
return -1;
|
||||
|
||||
lockdisplay(display);
|
||||
display->image = display->screenimage;
|
||||
screen = display->screenimage;
|
||||
|
||||
|
@ -113,7 +114,6 @@ closedisplay(Display *disp)
|
|||
free(disp->windir);
|
||||
freeimage(disp->white);
|
||||
freeimage(disp->black);
|
||||
qunlock(&disp->qlock);
|
||||
free(disp);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ Error2:
|
|||
}
|
||||
free(t);
|
||||
kc->c = chancreate(sizeof(Rune), 20);
|
||||
chansetname(kc->c, "kbdc");
|
||||
proccreate(_ioproc, kc, 4096);
|
||||
return kc;
|
||||
}
|
||||
|
|
|
@ -118,7 +118,9 @@ initmouse(char *file, Image *i)
|
|||
free(t);
|
||||
mc->image = i;
|
||||
mc->c = chancreate(sizeof(Mouse), 0);
|
||||
chansetname(mc->c, "mousec");
|
||||
mc->resizec = chancreate(sizeof(int), 2);
|
||||
chansetname(mc->resizec, "resizec");
|
||||
proccreate(_ioproc, mc, 4096);
|
||||
return mc;
|
||||
}
|
||||
|
|
|
@ -23,11 +23,11 @@ memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point sp,
|
|||
|
||||
/* only fetch dst data if we need it */
|
||||
if((par->state&(Simplemask|Fullmask)) != (Simplemask|Fullmask))
|
||||
_xgetxdata(dst, par->r);
|
||||
_xgetxdata(par->dst, par->r);
|
||||
|
||||
/* always fetch source and mask */
|
||||
_xgetxdata(src, par->sr);
|
||||
_xgetxdata(mask, par->mr);
|
||||
_xgetxdata(par->src, par->sr);
|
||||
_xgetxdata(par->mask, par->mr);
|
||||
|
||||
/* now can run memimagedraw on the in-memory bits */
|
||||
_memimagedraw(par);
|
||||
|
@ -36,7 +36,7 @@ memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point sp,
|
|||
return;
|
||||
|
||||
/* put bits back on x server */
|
||||
_xputxdata(dst, par->r);
|
||||
_xputxdata(par->dst, par->r);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -45,9 +45,7 @@ _ioproc(void *arg)
|
|||
fd = XConnectionNumber(_x.kbdcon);
|
||||
XSelectInput(_x.kbdcon, _x.drawable, KeyPressMask);
|
||||
for(;;){
|
||||
while(XCheckWindowEvent(_x.kbdcon, _x.drawable, KeyPressMask, &xevent) == False){
|
||||
threadfdwait(fd, 'r');
|
||||
}
|
||||
XWindowEvent(_x.kbdcon, _x.drawable, KeyPressMask, &xevent);
|
||||
switch(xevent.type){
|
||||
case KeyPress:
|
||||
i = _xtoplan9kbd(&xevent);
|
||||
|
@ -69,12 +67,12 @@ initkeyboard(char *file)
|
|||
{
|
||||
Keyboardctl *kc;
|
||||
|
||||
threadfdwaitsetup();
|
||||
kc = mallocz(sizeof(Keyboardctl), 1);
|
||||
if(kc == nil)
|
||||
return nil;
|
||||
kc->c = chancreate(sizeof(Rune), 20);
|
||||
threadcreate(_ioproc, kc, 32768);
|
||||
chansetname(kc->c, "kbdc");
|
||||
proccreate(_ioproc, kc, 32768);
|
||||
return kc;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ static
|
|||
void
|
||||
_ioproc(void *arg)
|
||||
{
|
||||
int fd, one;
|
||||
int fd, one, buttons;
|
||||
Atom a;
|
||||
ulong mask;
|
||||
Mouse m;
|
||||
|
@ -65,9 +65,8 @@ _ioproc(void *arg)
|
|||
mask = MouseMask|ExposureMask|StructureNotifyMask;
|
||||
XSelectInput(_x.mousecon, _x.drawable, mask);
|
||||
fd = XConnectionNumber(_x.mousecon);
|
||||
buttons = 0;
|
||||
for(;;){
|
||||
while(XPending(_x.mousecon) == False)
|
||||
threadfdwait(fd, 'r');
|
||||
XNextEvent(_x.mousecon, &xevent);
|
||||
switch(xevent.type){
|
||||
case Expose:
|
||||
|
@ -94,14 +93,16 @@ _ioproc(void *arg)
|
|||
case ButtonRelease:
|
||||
case MotionNotify:
|
||||
/* If the motion notifications are backing up, skip over some. */
|
||||
if(xevent.type == MotionNotify){
|
||||
if(0 && xevent.type == MotionNotify){
|
||||
while(XCheckWindowEvent(_x.mousecon, _x.drawable, MouseMask, &xevent)){
|
||||
if(xevent.type != MotionNotify)
|
||||
break;
|
||||
}
|
||||
}
|
||||
m.buttons = buttons;
|
||||
if(_xtoplan9mouse(_x.mousecon, &xevent, &m) < 0)
|
||||
continue;
|
||||
buttons = m.buttons;
|
||||
send(mc->c, &m);
|
||||
/*
|
||||
* mc->Mouse is updated after send so it doesn't have wrong value if we block during send.
|
||||
|
@ -133,13 +134,14 @@ initmouse(char *file, Image *i)
|
|||
{
|
||||
Mousectl *mc;
|
||||
|
||||
threadfdwaitsetup();
|
||||
mc = mallocz(sizeof(Mousectl), 1);
|
||||
if(i)
|
||||
mc->display = i->display;
|
||||
mc->c = chancreate(sizeof(Mouse), 0);
|
||||
chansetname(mc->c, "mousec");
|
||||
mc->resizec = chancreate(sizeof(int), 2);
|
||||
threadcreate(_ioproc, mc, 32768);
|
||||
chansetname(mc->resizec, "resizec");
|
||||
proccreate(_ioproc, mc, 32768);
|
||||
return mc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue