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