rio: dont serve /dev/screen from display->image, as its not updated on resize. instead, use screen and omit the file if provided by the enviroment. allow unaligned reads.
parent
c389d96769
commit
25f4840c7e
|
@ -430,9 +430,13 @@ filsyswalk(Filsys *fs, Xfid *x, Fid *f)
|
||||||
dir = dirtab;
|
dir = dirtab;
|
||||||
goto Accept;
|
goto Accept;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* don't serve these if it's provided in the environment */
|
||||||
if(snarffd>=0 && strcmp(x->wname[i], "snarf")==0)
|
if(snarffd>=0 && strcmp(x->wname[i], "snarf")==0)
|
||||||
break; /* don't serve /dev/snarf if it's provided in the environment */
|
break;
|
||||||
|
if(strcmp(x->wname[i], "screen")==0 && access("/dev/screen", AEXIST)==0)
|
||||||
|
break;
|
||||||
|
|
||||||
id = WIN(f->qid);
|
id = WIN(f->qid);
|
||||||
d = dirtab;
|
d = dirtab;
|
||||||
d++; /* skip '.' */
|
d++; /* skip '.' */
|
||||||
|
|
|
@ -567,19 +567,29 @@ xfidwrite(Xfid *x)
|
||||||
int
|
int
|
||||||
readwindow(Image *i, char *t, Rectangle r, int offset, int n)
|
readwindow(Image *i, char *t, Rectangle r, int offset, int n)
|
||||||
{
|
{
|
||||||
int ww, y;
|
int ww, oo, y, m;
|
||||||
|
uchar *tt;
|
||||||
|
|
||||||
offset -= 5*12;
|
|
||||||
ww = bytesperline(r, i->depth);
|
ww = bytesperline(r, i->depth);
|
||||||
r.min.y += offset/ww;
|
r.min.y += offset/ww;
|
||||||
if(r.min.y >= r.max.y)
|
if(r.min.y >= r.max.y)
|
||||||
return 0;
|
return 0;
|
||||||
y = r.min.y + n/ww;
|
y = r.min.y + (n + ww-1)/ww;
|
||||||
if(y < r.max.y)
|
if(y < r.max.y)
|
||||||
r.max.y = y;
|
r.max.y = y;
|
||||||
if(r.max.y <= r.min.y)
|
m = ww * Dy(r);
|
||||||
return 0;
|
oo = offset % ww;
|
||||||
return unloadimage(i, r, (uchar*)t, n);
|
if(oo == 0 && n >= m)
|
||||||
|
return unloadimage(i, r, (uchar*)t, n);
|
||||||
|
if((tt = malloc(m)) == nil)
|
||||||
|
return -1;
|
||||||
|
m = unloadimage(i, r, tt, m) - oo;
|
||||||
|
if(m > 0){
|
||||||
|
if(n < m) m = n;
|
||||||
|
memmove(t, tt + oo, m);
|
||||||
|
}
|
||||||
|
free(tt);
|
||||||
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -798,30 +808,26 @@ xfidread(Xfid *x)
|
||||||
|
|
||||||
case Qwindow:
|
case Qwindow:
|
||||||
i = w->i;
|
i = w->i;
|
||||||
if(i == nil || Dx(w->screenr)<=0){
|
r = w->screenr;
|
||||||
|
if(i == nil || Dx(r)<=0){
|
||||||
filsysrespond(x->fs, x, &fc, Enowindow);
|
filsysrespond(x->fs, x, &fc, Enowindow);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
r = w->screenr;
|
|
||||||
goto caseImage;
|
goto caseImage;
|
||||||
|
|
||||||
case Qscreen:
|
case Qscreen:
|
||||||
i = display->image;
|
i = screen;
|
||||||
if(i == nil){
|
r = screen->r;
|
||||||
filsysrespond(x->fs, x, &fc, "no top-level screen");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
r = i->r;
|
|
||||||
/* fall through */
|
|
||||||
|
|
||||||
caseImage:
|
caseImage:
|
||||||
if(off < 5*12){
|
if(off < 5*12){
|
||||||
n = sprint(buf, "%11s %11d %11d %11d %11d ",
|
n = sprint(buf, "%11s %11d %11d %11d %11d ",
|
||||||
chantostr(cbuf, i->chan),
|
chantostr(cbuf, i->chan),
|
||||||
i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y);
|
r.min.x, r.min.y, r.max.x, r.max.y);
|
||||||
t = estrdup(buf);
|
t = estrdup(buf);
|
||||||
goto Text;
|
goto Text;
|
||||||
}
|
}
|
||||||
|
off -= 5*12;
|
||||||
t = malloc(cnt);
|
t = malloc(cnt);
|
||||||
fc.data = t;
|
fc.data = t;
|
||||||
n = readwindow(i, t, r, off, cnt); /* careful; fc.count is unsigned */
|
n = readwindow(i, t, r, off, cnt); /* careful; fc.count is unsigned */
|
||||||
|
|
Loading…
Reference in New Issue