2 * /dev/draw simulator -- handles the messages prepared by the draw library.
3 * Includes all the memlayer code even though most programs don't use it.
4 * This whole approach is overkill, but cpu is cheap and it keeps things simple.
14 #define HASHMASK (NHASH-1)
16 extern void flushmemscreen(Rectangle);
18 typedef struct Client Client;
19 typedef struct Draw Draw;
20 typedef struct DImage DImage;
21 typedef struct DScreen DScreen;
22 typedef struct CScreen CScreen;
23 typedef struct FChar FChar;
24 typedef struct Refresh Refresh;
25 typedef struct Refx Refx;
26 typedef struct DName DName;
43 DImage* dimage[NHASH];
80 int minx; /* left edge of bits */
81 int maxx; /* right edge of bits */
82 uchar miny; /* first non-zero scan-line */
83 uchar maxy; /* last non-zero scan-line + 1 */
84 schar left; /* offset of baseline */
85 uchar width; /* width of baseline */
89 * Reference counts in DImages:
90 * one per open by original client
91 * one per screen image or fill
92 * one per image derived from this one by name
104 DScreen* dscreen; /* 0 if not a window */
105 DImage* fromname; /* image this one is derived from, by name */
128 static Client *client0;
129 static Memimage *screenimage;
130 static Rectangle flushrect;
132 static DScreen* dscreen;
133 static int drawuninstall(Client*, int);
134 static Memimage* drawinstall(Client*, int, Memimage*, DScreen*);
135 static void drawfreedimage(DImage*);
138 _initdisplaymemimage(Display *d, Memimage *m)
141 client0 = mallocz(sizeof(Client), 1);
143 fprint(2, "initdraw: allocating client0: out of memory");
147 client0->clientid = ++sdraw.clientid;
148 client0->op = SoverD;
149 sdraw.client[0] = client0;
154 _drawreplacescreenimage(Memimage *m)
157 * Replace the screen image because the screen
160 * In theory there should only be one reference
161 * to the current screen image, and that's through
162 * client0's image 0, installed a few lines above.
163 * Once the client drops the image, the underlying backing
164 * store freed properly. The client is being notified
165 * about the resize through external means, so all we
166 * need to do is this assignment.
173 drawrefreshscreen(DImage *l, Client *client)
175 while(l != nil && l->dscreen == nil)
177 if(l != nil && l->dscreen->owner != client)
178 l->dscreen->owner->refreshme = 1;
183 drawrefresh(Memimage *m, Rectangle r, void *v)
197 for(ref=c->refresh; ref; ref=ref->next)
198 if(ref->dimage == d){
199 combinerect(&ref->r, r);
202 ref = mallocz(sizeof(Refresh), 1);
206 ref->next = c->refresh;
212 addflush(Rectangle r)
217 if(sdraw.softscreen==0 || !rectclip(&r, screenimage->r))
220 if(flushrect.min.x >= flushrect.max.x){
226 combinerect(&nbb, r);
228 abb = Dx(flushrect)*Dy(flushrect);
229 anbb = Dx(nbb)*Dy(nbb);
231 * Area of new waste is area of new bb minus area of old bb,
232 * less the area of the new segment, which we assume is not waste.
233 * This could be negative, but that's OK.
235 waste += anbb-abb - ar;
240 * total area is small
241 * waste is less than half total area
244 if(anbb<=1024 || waste*2<anbb || rectXrect(flushrect, r)){
248 /* emit current state */
249 if(flushrect.min.x < flushrect.max.x)
250 flushmemscreen(flushrect);
257 dstflush(int dstid, Memimage *dst, Rectangle r)
262 combinerect(&flushrect, r);
265 /* how can this happen? -rsc, dec 12 2002 */
267 print("nil dstflush\n");
274 if(l->screen->image->data != screenimage->data)
276 r = rectaddpt(r, l->delta);
277 l = l->screen->image->layer;
286 if(flushrect.min.x < flushrect.max.x)
287 flushmemscreen(flushrect);
288 flushrect = Rect(10000, 10000, -10000, -10000);
293 drawcmp(char *a, char *b, int n)
297 return memcmp(a, b, n);
302 drawlookupname(int n, char *str)
307 ename = &name[sdraw.nname];
308 for(; name<ename; name++)
309 if(drawcmp(name->name, str, n) == 0)
316 drawgoodname(DImage *d)
320 /* if window, validate the screen's own images */
322 if(drawgoodname(d->dscreen->dimage) == 0
323 || drawgoodname(d->dscreen->dfill) == 0)
327 n = drawlookupname(strlen(d->name), d->name);
328 if(n==nil || n->vers!=d->vers)
335 drawlookup(Client *client, int id, int checkname)
339 d = client->dimage[id&HASHMASK];
343 * BUG: should error out but too hard.
346 if(checkname && !drawgoodname(d))
357 drawlookupdscreen(int id)
372 drawlookupscreen(Client *client, int id, CScreen **cs)
378 if(s->dscreen->id == id){
384 /* caller must check! */
390 drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen)
394 d = mallocz(sizeof(DImage), 1);
405 d->dscreen = dscreen;
406 d->next = client->dimage[id&HASHMASK];
407 client->dimage[id&HASHMASK] = d;
413 drawinstallscreen(Client *client, DScreen *d, int id, DImage *dimage, DImage *dfill, int public)
418 c = mallocz(sizeof(CScreen), 1);
419 if(dimage && dimage->image && dimage->image->chan == 0){
420 print("bad image %p in drawinstallscreen", dimage->image);
427 d = mallocz(sizeof(DScreen), 1);
432 s = mallocz(sizeof(Memscreen), 1);
442 s->image = dimage->image;
447 s->fill = dfill->image;
460 c->next = client->cscreen;
467 drawdelname(DName *name)
472 memmove(name, name+1, (sdraw.nname-(i+1))*sizeof(DName));
478 drawfreedscreen(DScreen *this)
484 print("negative ref in drawfreedscreen\n");
489 dscreen = this->next;
492 while(next = ds->next){ /* assign = */
494 ds->next = this->next;
500 * Should signal Enodrawimage, but too hard.
506 drawfreedimage(this->dimage);
508 drawfreedimage(this->dfill);
515 drawfreedimage(DImage *dimage)
523 print("negative ref in drawfreedimage\n");
528 for(i=0; i<sdraw.nname; )
529 if(sdraw.name[i].dimage == dimage)
530 drawdelname(sdraw.name+i);
533 if(dimage->fromname){ /* acquired by name; owned by someone else*/
534 drawfreedimage(dimage->fromname);
537 //if(dimage->image == screenimage) /* don't free the display */
539 ds = dimage->dscreen;
542 if(l->data == screenimage->data)
543 addflush(l->layer->screenr);
544 if(l->layer->refreshfn == drawrefresh) /* else true owner will clean up */
545 free(l->layer->refreshptr);
546 l->layer->refreshptr = nil;
547 if(drawgoodname(dimage))
553 freememimage(dimage->image);
561 drawuninstallscreen(Client *client, CScreen *this)
565 cs = client->cscreen;
567 client->cscreen = this->next;
568 drawfreedscreen(this->dscreen);
572 while(next = cs->next){ /* assign = */
574 cs->next = this->next;
575 drawfreedscreen(this->dscreen);
585 drawuninstall(Client *client, int id)
589 d = client->dimage[id&HASHMASK];
593 client->dimage[id&HASHMASK] = d->next;
597 while(next = d->next){ /* assign = */
599 d->next = next->next;
600 drawfreedimage(next);
610 drawaddname(Client *client, DImage *di, int n, char *str, char **err)
612 DName *name, *ename, *new, *t;
616 ename = &name[sdraw.nname];
617 for(; name<ename; name++)
618 if(drawcmp(name->name, str, n) == 0){
619 *err = "image name in use";
622 t = mallocz((sdraw.nname+1)*sizeof(DName), 1);
624 if(t == nil || ns == nil){
627 *err = "out of memory";
630 memmove(t, sdraw.name, sdraw.nname*sizeof(DName));
633 new = &sdraw.name[sdraw.nname++];
635 memmove(new->name, str, n);
638 new->client = client;
639 new->vers = ++sdraw.vers;
644 drawclientop(Client *cl)
655 drawimage(Client *client, uchar *a)
659 d = drawlookup(client, BGLONG(a), 1);
661 return nil; /* caller must check! */
667 drawrectangle(Rectangle *r, uchar *a)
669 r->min.x = BGLONG(a+0*4);
670 r->min.y = BGLONG(a+1*4);
671 r->max.x = BGLONG(a+2*4);
672 r->max.y = BGLONG(a+3*4);
677 drawpoint(Point *p, uchar *a)
679 p->x = BGLONG(a+0*4);
680 p->y = BGLONG(a+1*4);
685 drawchar(Memimage *dst, Point p, Memimage *src, Point *sp, DImage *font, int index, int op)
691 fc = &font->fchar[index];
692 r.min.x = p.x+fc->left;
693 r.min.y = p.y-(font->ascent-fc->miny);
694 r.max.x = r.min.x+(fc->maxx-fc->minx);
695 r.max.y = r.min.y+(fc->maxy-fc->miny);
696 sp1.x = sp->x+fc->left;
697 sp1.y = sp->y+fc->miny;
698 memdraw(dst, r, src, sp1, font->image, Pt(fc->minx, fc->miny), op);
706 drawcoord(uchar *p, uchar *maxp, int oldx, int *newx)
731 _drawmsgread(Display *d, void *a, int n)
735 inbuf = d->obufp - d->obuf;
738 memmove(a, d->obuf, n);
741 memmove(d->obuf, d->obufp-inbuf, inbuf);
742 d->obufp = d->obuf+inbuf;
747 drawmsgsquirrel(Display *d, void *a, int n)
751 ep = d->obuf + d->obufsize;
752 if(d->obufp + n > ep)
754 memmove(d->obufp, a, n);
759 _drawmsgwrite(Display *d, void *v, int n)
761 char cbuf[40], *err, ibuf[12*12+1], *s;
762 int c, ci, doflush, dstid, e0, e1, esize, j, m;
763 int ni, nw, oesize, oldn, op, ox, oy, repl, scrnid, y;
764 uchar *a, refresh, *u;
768 DImage *di, *ddst, *dsrc, *font, *ll;
772 Memimage *dst, *i, *l, **lp, *mask, *src;
787 //fprint(2, "msgwrite %d(%d)...", n, *a);
790 //fprint(2, "bad command %d\n", *a);
791 err = "bad draw command";
794 /* allocate: 'b' id[4] screenid[4] refresh[1] chan[4] repl[1]
795 R[4*4] clipR[4*4] rrggbbaa[4]
798 m = 1+4+4+1+4+1+4*4+4*4+4;
802 scrnid = BGSHORT(a+5);
806 drawrectangle(&r, a+15);
807 drawrectangle(&clipr, a+31);
808 value = BGLONG(a+47);
809 if(drawlookup(client, dstid, 0))
812 dscrn = drawlookupscreen(client, scrnid, &cs);
815 scrn = dscrn->screen;
816 if(repl || chan!=scrn->image->chan){
817 err = "image parameters incompatibile with screen";
825 reffn = memlnorefresh;
831 err = "unknown refresh method";
834 l = memlalloc(scrn, r, reffn, 0, value);
837 addflush(l->layer->screenr);
839 rectclip(&l->clipr, r);
840 if(drawinstall(client, dstid, l, dscrn) == 0){
847 if(reffn == drawrefresh){
848 refx = mallocz(sizeof(Refx), 1);
850 if(drawuninstall(client, dstid) < 0)
854 refx->client = client;
855 refx->dimage = drawlookup(client, dstid, 1);
857 memlsetrefresh(l, reffn, refx);
861 i = allocmemimage(r, chan);
868 rectclip(&i->clipr, r);
869 if(drawinstall(client, dstid, i, 0) == 0){
873 memfillcolor(i, value);
876 /* allocate screen: 'A' id[4] imageid[4] fillid[4] public[1] */
884 if(drawlookupdscreen(dstid))
886 ddst = drawlookup(client, BGLONG(a+5), 1);
887 dsrc = drawlookup(client, BGLONG(a+9), 1);
888 if(ddst==0 || dsrc==0)
890 if(drawinstallscreen(client, 0, dstid, ddst, dsrc, a[13]) == 0)
894 /* set repl and clip: 'c' dstid[4] repl[1] clipR[4*4] */
899 ddst = drawlookup(client, BGLONG(a+1), 1);
903 err = "can't change repl/clipr of shared image";
909 drawrectangle(&dst->clipr, a+6);
912 /* draw: 'd' dstid[4] srcid[4] maskid[4] R[4*4] P[2*4] P[2*4] */
914 m = 1+4+4+4+4*4+2*4+2*4;
917 dst = drawimage(client, a+1);
919 src = drawimage(client, a+5);
920 mask = drawimage(client, a+9);
921 if(!dst || !src || !mask)
923 drawrectangle(&r, a+13);
926 op = drawclientop(client);
927 memdraw(dst, r, src, p, mask, q, op);
928 dstflush(dstid, dst, r);
931 /* toggle debugging: 'D' val[1] */
939 /* ellipse: 'e' dstid[4] srcid[4] center[2*4] a[4] b[4] thick[4] sp[2*4] alpha[4] phi[4]*/
942 m = 1+4+4+2*4+4+4+4+2*4+2*4;
945 dst = drawimage(client, a+1);
947 src = drawimage(client, a+5);
954 err = "invalid ellipse semidiameter";
959 err = "negative ellipse thickness";
963 drawpoint(&sp, a+29);
969 op = drawclientop(client);
970 /* high bit indicates arc angles are present */
972 if((ox & (1<<30)) == 0)
974 memarc(dst, p, e0, e1, c, src, sp, ox, oy, op);
976 memellipse(dst, p, e0, e1, c, src, sp, op);
977 dstflush(dstid, dst, Rect(p.x-e0-j, p.y-e1-j, p.x+e0+j+1, p.y+e1+j+1));
980 /* free: 'f' id[4] */
985 ll = drawlookup(client, BGLONG(a+1), 0);
986 if(ll && ll->dscreen && ll->dscreen->owner != client)
987 ll->dscreen->owner->refreshme = 1;
988 if(drawuninstall(client, BGLONG(a+1)) < 0)
992 /* free screen: 'F' id[4] */
997 if(!drawlookupscreen(client, BGLONG(a+1), &cs))
999 drawuninstallscreen(client, cs);
1002 /* initialize font: 'i' fontid[4] nchars[4] ascent[1] */
1007 dstid = BGLONG(a+1);
1009 err = "can't use display as font";
1012 font = drawlookup(client, dstid, 1);
1015 if(font->image->layer){
1016 err = "can't use window as font";
1020 if(ni<=0 || ni>4096){
1021 err = "bad font size (4096 chars max)";
1024 free(font->fchar); /* should we complain if non-zero? */
1025 font->fchar = mallocz(ni*sizeof(FChar), 1);
1026 if(font->fchar == 0){
1027 err = "no memory for font";
1030 memset(font->fchar, 0, ni*sizeof(FChar));
1032 font->ascent = a[9];
1035 /* set image 0 to screen image */
1040 drawinstall(client, 0, screenimage, 0);
1044 /* get image info: 'I' */
1049 if(client->infoid < 0)
1051 if(client->infoid == 0){
1056 di = drawlookup(client, client->infoid, 1);
1061 ni = sprint(ibuf, "%11d %11d %11s %11d %11d %11d %11d %11d"
1062 " %11d %11d %11d %11d ",
1065 chantostr(cbuf, i->chan),
1066 (i->flags&Frepl)==Frepl,
1067 i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y,
1068 i->clipr.min.x, i->clipr.min.y,
1069 i->clipr.max.x, i->clipr.max.y);
1070 drawmsgsquirrel(d, ibuf, ni);
1071 client->infoid = -1;
1074 /* load character: 'l' fontid[4] srcid[4] index[2] R[4*4] P[2*4] left[1] width[1] */
1076 m = 1+4+4+2+4*4+2*4+1+1;
1079 font = drawlookup(client, BGLONG(a+1), 1);
1082 if(font->nfchar == 0)
1084 src = drawimage(client, a+5);
1088 if(ci >= font->nfchar)
1090 drawrectangle(&r, a+11);
1091 drawpoint(&p, a+27);
1092 memdraw(font->image, r, src, p, memopaque, p, S);
1093 fc = &font->fchar[ci];
1102 /* draw line: 'L' dstid[4] p0[2*4] p1[2*4] end0[4] end1[4] radius[4] srcid[4] sp[2*4] */
1104 m = 1+4+2*4+2*4+4+4+4+4+2*4;
1107 dst = drawimage(client, a+1);
1108 dstid = BGLONG(a+1);
1110 drawpoint(&q, a+13);
1115 err = "negative line width";
1118 src = drawimage(client, a+33);
1121 drawpoint(&sp, a+37);
1122 op = drawclientop(client);
1123 memline(dst, p, q, e0, e1, j, src, sp, op);
1124 /* avoid memlinebbox if possible */
1125 if(dstid==0 || dst->layer!=nil){
1126 /* BUG: this is terribly inefficient: update maximal containing rect*/
1127 r = memlinebbox(p, q, e0, e1, j);
1128 dstflush(dstid, dst, insetrect(r, -(1+1+j)));
1132 /* create image mask: 'm' newid[4] id[4] */
1143 /* attach to a named image: 'n' dstid[4] j[1] name[j] */
1149 if(j == 0) /* give me a non-empty name please */
1154 dstid = BGLONG(a+1);
1155 if(drawlookup(client, dstid, 0))
1157 dn = drawlookupname(j, (char*)a+6);
1163 if(drawinstall(client, dstid, dn->dimage->image, 0) == 0)
1165 di = drawlookup(client, dstid, 0);
1168 di->vers = dn->vers;
1170 di->fromname = dn->dimage;
1171 di->fromname->ref++;
1172 memmove(di->name, a+6, j);
1174 client->infoid = dstid;
1177 /* name an image: 'N' dstid[4] in[1] j[1] name[j] */
1184 if(j == 0) /* give me a non-empty name please */
1189 di = drawlookup(client, BGLONG(a+1), 0);
1195 if(drawaddname(client, di, j, (char*)a+7, &err) < 0)
1198 dn = drawlookupname(j, (char*)a+7);
1201 if(dn->dimage != di)
1207 /* position window: 'o' id[4] r.min [2*4] screenr.min [2*4] */
1212 dst = drawimage(client, a+1);
1217 drawpoint(&q, a+13);
1218 r = dst->layer->screenr;
1219 ni = memlorigin(dst, p, q);
1221 err = "image origin failed";
1226 addflush(dst->layer->screenr);
1227 ll = drawlookup(client, BGLONG(a+1), 1);
1228 drawrefreshscreen(ll, client);
1233 /* set compositing operator for next draw operation: 'O' op */
1241 /* filled polygon: 'P' dstid[4] n[2] wind[4] ignore[2*4] srcid[4] sp[2*4] p0[2*4] dp[2*2*n] */
1242 /* polygon: 'p' dstid[4] n[2] end0[4] end1[4] radius[4] srcid[4] sp[2*4] p0[2*4] dp[2*2*n] */
1245 m = 1+4+2+4+4+4+4+2*4;
1248 dstid = BGLONG(a+1);
1249 dst = drawimage(client, a+1);
1252 err = "negative cout in polygon";
1261 err = "negative polygon line width";
1265 src = drawimage(client, a+19);
1268 drawpoint(&sp, a+23);
1269 drawpoint(&p, a+31);
1271 pp = mallocz(ni*sizeof(Point), 1);
1275 if(dstid==0 || (dst->layer && dst->layer->screen->image->data == screenimage->data))
1276 doflush = 1; /* simplify test in loop */
1280 for(y=0; y<ni; y++){
1283 u = drawcoord(u, a+n, ox, &p.x);
1286 u = drawcoord(u, a+n, oy, &p.y);
1295 c = memlineendsize(e0);
1300 c = memlineendsize(e1);
1305 if(*a=='P' && e0!=1 && e0 !=~0)
1308 r = Rect(q.x-oesize, q.y-oesize, q.x+oesize+1, q.y+oesize+1);
1309 combinerect(&r, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1));
1311 if(rectclip(&r, dst->clipr)) /* should perhaps be an arg to dstflush */
1312 dstflush(dstid, dst, r);
1317 dstflush(dstid, dst, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1));
1318 op = drawclientop(client);
1320 mempoly(dst, pp, ni, e0, e1, j, src, sp, op);
1322 memfillpoly(dst, pp, ni, e0, src, sp, op);
1327 /* read: 'r' id[4] R[4*4] */
1332 i = drawimage(client, a+1);
1335 drawrectangle(&r, a+5);
1336 if(!rectinrect(r, i->r))
1338 c = bytesperline(r, i->depth);
1340 free(client->readdata);
1341 client->readdata = mallocz(c, 0);
1342 if(client->readdata == nil){
1343 err = "readimage malloc failed";
1346 client->nreaddata = memunload(i, r, client->readdata, c);
1347 if(client->nreaddata < 0){
1348 free(client->readdata);
1349 client->readdata = nil;
1350 err = "bad readimage call";
1355 /* string: 's' dstid[4] srcid[4] fontid[4] P[2*4] clipr[4*4] sp[2*4] ni[2] ni*(index[2]) */
1356 /* stringbg: 'x' dstid[4] srcid[4] fontid[4] P[2*4] clipr[4*4] sp[2*4] ni[2] bgid[4] bgpt[2*4] ni*(index[2]) */
1359 m = 1+4+4+4+2*4+4*4+2*4+2;
1365 dst = drawimage(client, a+1);
1366 dstid = BGLONG(a+1);
1367 src = drawimage(client, a+5);
1370 font = drawlookup(client, BGLONG(a+9), 1);
1373 if(font->nfchar == 0)
1375 drawpoint(&p, a+13);
1376 drawrectangle(&r, a+21);
1377 drawpoint(&sp, a+37);
1385 op = drawclientop(client);
1387 /* paint background */
1388 l = drawimage(client, a+47);
1391 drawpoint(&q, a+51);
1393 r.min.y = p.y-font->ascent;
1395 r.max.y = r.min.y+Dy(font->image->r);
1399 if(ci<0 || ci>=font->nfchar){
1403 r.max.x += font->fchar[ci].width;
1406 memdraw(dst, r, l, q, memopaque, ZP, op);
1412 if(ci<0 || ci>=font->nfchar){
1416 q = drawchar(dst, q, src, &sp, font, ci, op);
1420 p.y -= font->ascent;
1421 dstflush(dstid, dst, Rect(p.x, p.y, q.x, p.y+Dy(font->image->r)));
1424 /* use public screen: 'S' id[4] chan[4] */
1429 dstid = BGLONG(a+1);
1432 dscrn = drawlookupdscreen(dstid);
1433 if(dscrn==0 || (dscrn->public==0 && dscrn->owner!=client))
1435 if(dscrn->screen->image->chan != BGLONG(a+5)){
1436 err = "inconsistent chan";
1439 if(drawinstallscreen(client, dscrn, 0, 0, 0, 0) == 0)
1443 /* top or bottom windows: 't' top[1] nw[2] n*id[4] */
1456 lp = mallocz(nw*sizeof(Memimage*), 1);
1459 for(j=0; j<nw; j++){
1460 lp[j] = drawimage(client, a+1+1+2+j*4);
1466 if(lp[0]->layer == 0){
1467 err = "images are not windows";
1472 if(lp[j]->layer->screen != lp[0]->layer->screen){
1473 err = "images not on same screen";
1478 memltofrontn(lp, nw);
1480 memltorearn(lp, nw);
1481 if(lp[0]->layer->screen->image->data == screenimage->data)
1483 addflush(lp[j]->layer->screenr);
1485 ll = drawlookup(client, BGLONG(a+1+1+2), 1);
1486 drawrefreshscreen(ll, client);
1495 /* write: 'y' id[4] R[4*4] data[x*1] */
1496 /* write from compressed data: 'Y' id[4] R[4*4] data[x*1] */
1502 dstid = BGLONG(a+1);
1503 dst = drawimage(client, a+1);
1506 drawrectangle(&r, a+5);
1507 if(!rectinrect(r, dst->r))
1509 y = memload(dst, r, a+m, n-m, *a=='Y');
1511 err = "bad writeimage call";
1514 dstflush(dstid, dst, r);
1522 err = "unknown id for draw image";
1525 err = "unknown id for draw screen";
1528 err = "short draw message";
1531 err = "draw read too short";
1534 err = "image id in use";
1537 err = "screen id in use";
1540 err = "image memory allocation failed";
1543 err = "readimage outside image";
1546 err = "writeimage outside image";
1549 err = "image not a font";
1552 err = "character index out of range";
1555 err = "no such draw client";
1558 err = "image has bad depth";
1561 err = "image name in use";
1564 err = "no image with that name";
1567 err = "named image no longer valid";
1570 err = "image already has name";
1573 err = "wrong name for image";
1576 err = "out of memory";
1579 err = "bad argument in draw message";
1583 drawerror(display, err);