ref: 06ded18ce9088df6aa259598454f804df3f44ff3
dir: /hidpi-2fs.patch/
diff 8076b346fc51790964070d39e65c0afaaad49a0f uncommitted r--- a/sys/src/9/port/devdraw.c +++ b/sys/src/9/port/devdraw.c @@ -15,6 +15,7 @@ enum { Qtopdir = 0, + Qgeom, Qnew, Qwinname, Q3rd, @@ -262,14 +263,22 @@ */ switch(t){ case Q2nd: - if(s == 0){ + if(s == 0 || s == 1){ case Qnew: - mkqid(&q, Qnew, 0, QTFILE); - devdir(c, q, "new", 0, eve, 0666, dp); - return 1; + if (s == 0) { + mkqid(&q, Qnew, 0, QTFILE); + devdir(c, q, "new", 0, eve, 0666, dp); + return 1; + } + case Qgeom: + if (s == 1) { + mkqid(&q, Qgeom, 0, QTFILE); + devdir(c, q, "geom", 0, eve, 0666, dp); + return 1; + } } - if(s <= sdraw.nclient){ - cl = sdraw.client[s-1]; + if(s <= sdraw.nclient+1){ + cl = sdraw.client[s-2]; if(cl == nil) return 0; sprint(up->genbuf, "%d", cl->clientid); @@ -812,9 +821,9 @@ int slot; slot = CLIENTPATH(path); - if(slot == 0) + if(slot < 2) return nil; - cl = sdraw.client[slot-1]; + cl = sdraw.client[slot-2]; if(cl==0 || cl->clientid==0) return nil; return cl; @@ -1024,7 +1033,7 @@ cl = drawnewclient(); if(cl == 0) error(Enodev); - c->qid.path = Qctl|((cl->slot+1)<<QSHIFT); + c->qid.path = Qctl|((cl->slot+2)<<QSHIFT); } switch(QID(c->qid)){ @@ -1031,6 +1040,9 @@ case Qwinname: break; + case Qgeom: + break; + case Qnew: break; @@ -1124,7 +1136,7 @@ long drawread(Chan *c, void *a, long n, vlong off) { - int index, m; + int dpi, index, m; ulong red, green, blue; Client *cl; uchar *p; @@ -1139,7 +1151,8 @@ if(QID(c->qid) == Qwinname) return readstr(off, a, n, screenname); - cl = drawclient(c); + if(QID(c->qid) != Qgeom) + cl = drawclient(c); dlock(); if(waserror()){ dunlock(); @@ -1146,6 +1159,21 @@ nexterror(); } switch(QID(c->qid)){ + case Qgeom: + i = screenimage; + if(i == nil) + error(Enodrawimage); + if((p = (uchar*)getconf("dpi")) == nil || (dpi = atoi((char*)p)) == 0){ + dpi=100; + } + p = malloc(6*12+1); + if(p == 0) + error(Enomem); + sprint((char*)p, "%11d %11d %11d %11d %11d %11d\n", i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y, dpi, dpi); + n = readstr(offset, a, n, (char*)p); + free(p); + break; + case Qctl: if(n < 12*12) error(Eshortread); @@ -1253,13 +1281,14 @@ static long drawwrite(Chan *c, void *a, long n, vlong) { - char buf[128], *fields[4], *q; + char buf[128], *fields[6], *q; Client *cl; int i, m, red, green, blue, x; if(c->qid.type & QTDIR) error(Eisdir); - cl = drawclient(c); + if(QID(c->qid) != Qgeom) + cl = drawclient(c); dlock(); if(waserror()){ drawwakeall(); @@ -1267,6 +1296,12 @@ nexterror(); } switch(QID(c->qid)){ + case Qgeom: + if(tokenize(a, fields, nelem(fields)) != 6) + error(Ebadarg); + n = strlen(a); + break; + case Qctl: if(n != 4) error("unknown draw control request");