libdraw, screenrc: bind devdraw and devmouse in screenrc instead of handling it in libdraw
libdraw was attempting to bind '#i' and '#m' to /dev when it could not find /dev/mouse or /dev/draw. a library shouldnt be that clever and do namespace manipulations on behalf of the caller. so instead, we setup the graphics environment in screenrc on boot time.
This commit is contained in:
parent
30a9d59070
commit
d1315ade41
3 changed files with 15 additions and 31 deletions
|
@ -35,7 +35,13 @@ if(test -f /dev/vgactl){
|
|||
}
|
||||
}
|
||||
|
||||
if(test -f /dev/mousectl && test -f '#i/winname'){
|
||||
if(! test -d /dev/draw)
|
||||
bind -a '#i' /dev
|
||||
|
||||
if(! test -f /dev/mouse)
|
||||
bind -a '#m' /dev
|
||||
|
||||
if(test -f /dev/mousectl && test -f /dev/winname){
|
||||
ask mouseport ' is (ps2, ps2intellimouse, 0, 1, 2)' ps2
|
||||
switch($mouseport){
|
||||
case ps2 ps2intellimouse 0 1 2
|
||||
|
|
|
@ -44,7 +44,6 @@ geninitdraw(char *devdir, void(*error)(Display*, char*), char *fontname, char *l
|
|||
df = getdefont(display);
|
||||
display->defaultsubfont = df;
|
||||
if(df == nil){
|
||||
fprint(2, "imageinit: can't open default subfont: %r\n");
|
||||
Error:
|
||||
closedisplay(display);
|
||||
display = nil;
|
||||
|
@ -70,17 +69,13 @@ geninitdraw(char *devdir, void(*error)(Display*, char*), char *fontname, char *l
|
|||
df->n-1, deffontname);
|
||||
//BUG: Need something better for this installsubfont("*default*", df);
|
||||
font = buildfont(display, buf, deffontname);
|
||||
if(font == nil){
|
||||
fprint(2, "imageinit: can't open default font: %r\n");
|
||||
if(font == nil)
|
||||
goto Error;
|
||||
}
|
||||
}else{
|
||||
font = openfont(display, fontname); /* BUG: grey fonts */
|
||||
if(font == nil){
|
||||
fprint(2, "imageinit: can't open font %s: %r\n", fontname);
|
||||
if(font == nil)
|
||||
goto Error;
|
||||
}
|
||||
}
|
||||
display->defaultfont = font;
|
||||
|
||||
/*
|
||||
|
@ -112,12 +107,8 @@ geninitdraw(char *devdir, void(*error)(Display*, char*), char *fontname, char *l
|
|||
int
|
||||
initdraw(void(*error)(Display*, char*), char *fontname, char *label)
|
||||
{
|
||||
char *dev = "/dev";
|
||||
static char dev[] = "/dev";
|
||||
|
||||
if(access("/dev/draw/new", AEXIST)<0 && bind("#i", "/dev", MAFTER)<0){
|
||||
fprint(2, "imageinit: can't bind /dev/draw: %r\n");
|
||||
return -1;
|
||||
}
|
||||
return geninitdraw(dev, error, fontname, label, dev, Refnone);
|
||||
}
|
||||
|
||||
|
@ -138,7 +129,6 @@ retry:
|
|||
fd = open(winname, OREAD);
|
||||
if(fd<0 || (n=read(fd, buf, sizeof buf-1))<=0){
|
||||
if((image=d->image) == nil){
|
||||
fprint(2, "gengetwindow: %r\n");
|
||||
*winp = nil;
|
||||
d->screenimage = nil;
|
||||
return -1;
|
||||
|
@ -158,7 +148,6 @@ retry:
|
|||
strcpy(obuf, buf);
|
||||
goto retry;
|
||||
}
|
||||
fprint(2, "namedimage %s failed: %r\n", buf);
|
||||
}
|
||||
if(*winp != nil){
|
||||
_freeimage1(*winp);
|
||||
|
@ -171,7 +160,6 @@ retry:
|
|||
d->screenimage = nil;
|
||||
return -1;
|
||||
}
|
||||
assert(image->chan != 0);
|
||||
}
|
||||
|
||||
d->screenimage = image;
|
||||
|
@ -194,7 +182,6 @@ retry:
|
|||
freeimage(image);
|
||||
return -1;
|
||||
}
|
||||
assert((*winp)->chan != 0);
|
||||
d->screenimage = *winp;
|
||||
return 1;
|
||||
}
|
||||
|
@ -236,14 +223,11 @@ initdisplay(char *dev, char *win, void(*error)(Display*, char*))
|
|||
sprint(buf, "%s/draw/new", dev);
|
||||
ctlfd = open(buf, ORDWR|OCEXEC);
|
||||
if(ctlfd < 0){
|
||||
if(bind("#i", dev, MAFTER) < 0){
|
||||
Error1:
|
||||
free(t);
|
||||
werrstr("initdisplay: %s: %r", buf);
|
||||
return nil;
|
||||
}
|
||||
ctlfd = open(buf, ORDWR|OCEXEC);
|
||||
}
|
||||
if(ctlfd < 0)
|
||||
goto Error1;
|
||||
if((n=read(ctlfd, info, sizeof info)) < 12){
|
||||
|
@ -399,10 +383,8 @@ lockdisplay(Display *disp)
|
|||
{
|
||||
if(debuglockdisplay){
|
||||
/* avoid busy looping; it's rare we collide anyway */
|
||||
while(!canqlock(&disp->qlock)){
|
||||
fprint(1, "proc %d waiting for display lock...\n", getpid());
|
||||
while(!canqlock(&disp->qlock))
|
||||
sleep(1000);
|
||||
}
|
||||
}else
|
||||
qlock(&disp->qlock);
|
||||
}
|
||||
|
|
|
@ -99,10 +99,6 @@ initmouse(char *file, Image *i)
|
|||
file = "/dev/mouse";
|
||||
mc->file = strdup(file);
|
||||
mc->mfd = open(file, ORDWR|OCEXEC);
|
||||
if(mc->mfd<0 && strcmp(file, "/dev/mouse")==0){
|
||||
bind("#m", "/dev", MAFTER);
|
||||
mc->mfd = open(file, ORDWR|OCEXEC);
|
||||
}
|
||||
if(mc->mfd < 0){
|
||||
free(mc);
|
||||
return nil;
|
||||
|
|
Loading…
Reference in a new issue