| @@ -236,8 +236,6 @@ static · 235 unmodified lines |
| 236 | 236 | void |
| 237 | 237 | drawflush(Draw *d) |
| 238 | 238 | { |
| 239 | | − // Rectangle r = d->flushrect; |
| 240 | | − // print("XXX drawflush: %d %d %d %d \n", r.min.x, r.min.y, r.max.x, r.max.y); |
| 241 | 239 | if(d->flushrect.min.x < d->flushrect.max.x) |
| 242 | 240 | xflushmemscreen(d->window, d->flushrect); |
| 243 | 241 | d->flushrect = Rect(10000, 10000, -10000, -10000); |
| @@ -258,13 +256,11 @@ drawlookupname(int n, char *str) · 14 unmodified lines |
| 258 | 256 | { |
| 259 | 257 | DName *name, *ename; |
| 260 | 258 | |
| 261 | | − // print("XXX drawlookupname %d %s\n", n, str); |
| 262 | 259 | name = dname; |
| 263 | 260 | ename = &name[ndname]; |
| 264 | 261 | for(; name<ename; name++) |
| 265 | 262 | if(drawcmp(name->name, str, n) == 0) |
| 266 | 263 | return name; |
| 267 | | − // print("XXX drawlookupname: %s not found\n", str); |
| 268 | 264 | return 0; |
| 269 | 265 | } |
| 270 | 266 | |
| @@ -293,7 +289,6 @@ drawlookup(Client *client, int id, int checkname) · 22 unmodified lines |
| 293 | 289 | { |
| 294 | 290 | DImage *d; |
| 295 | 291 | |
| 296 | | − // print("XXX drawlookup %d in client %p\n", id, client); |
| 297 | 292 | d = client->dimage[id&HASHMASK]; |
| 298 | 293 | while(d){ |
| 299 | 294 | if(d->id == id){ |
| @@ -365,7 +360,6 @@ drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen) · 65 unmodified lines |
| 365 | 360 | { |
| 366 | 361 | DImage *d; |
| 367 | 362 | |
| 368 | | − // print("XXX drawinstall %d (%p) in window %d\n", id, i, client->draw->window->id); |
| 369 | 363 | d = allocdimage(i); |
| 370 | 364 | if(d == 0) |
| 371 | 365 | return 0; |
| @@ -383,7 +377,6 @@ drawinstallscreen(Client *client, DScreen *d, int id, DImage *dimage, DImage *df · 11 unmodified lines |
| 383 | 377 | Memscreen *s; |
| 384 | 378 | CScreen *c; |
| 385 | 379 | |
| 386 | | − // print("XXX drawinstallscreen %d in window %d\n", id, client->draw->window->id); |
| 387 | 380 | c = malloc(sizeof(CScreen)); |
| 388 | 381 | if(dimage && dimage->image && dimage->image->chan == 0) |
| 389 | 382 | fatal("bad image %p in drawinstallscreen", dimage->image); |
| @@ -435,7 +428,6 @@ drawdelname(DName *name) · 45 unmodified lines |
| 435 | 428 | { |
| 436 | 429 | int i; |
| 437 | 430 | |
| 438 | | − // print("XXX drawdelname %s\n", dname->name); |
| 439 | 431 | i = name-dname; |
| 440 | 432 | memmove(name, name+1, (ndname-(i+1))*sizeof(DName)); |
| 441 | 433 | ndname--; |
| @@ -448,7 +440,6 @@ drawfreedscreen(Draw *d, DScreen *this) · 6 unmodified lines |
| 448 | 440 | DScreen *ds, *next; |
| 449 | 441 | |
| 450 | 442 | this->ref--; |
| 451 | | − // print("XXX drawfreedscreen %d from window %d (ref %d)\n", this->id, d->window->id, this->ref); |
| 452 | 443 | if(this->ref < 0) |
| 453 | 444 | fprint(2, "negative ref in drawfreedscreen\n"); |
| 454 | 445 | if(this->ref > 0) |
| @@ -468,7 +459,7 @@ drawfreedscreen(Draw *d, DScreen *this) · 13 unmodified lines |
| 468 | 459 | /* BUG: error(Enodrawimage); */ |
| 469 | 460 | return; |
| 470 | 461 | |
| 471 | | − Found: |
| 462 | +Found: |
| 472 | 463 | if(this->dimage) |
| 473 | 464 | drawfreedimage(d, this->dimage); |
| 474 | 465 | if(this->dfill) |
| @@ -486,7 +477,6 @@ drawfreedimage(Draw *d, DImage *dimage) · 11 unmodified lines |
| 486 | 477 | DScreen *ds; |
| 487 | 478 | |
| 488 | 479 | dimage->ref--; |
| 489 | | − // print("XXX drawfreedimage %d (%p) from window %d (ref %d) with image (%p)\n", dimage->id, dimage, d->window->id, dimage->ref, dimage->image); |
| 490 | 480 | if(dimage->ref < 0) |
| 491 | 481 | fprint(2, "negative ref in drawfreedimage\n"); |
| 492 | 482 | if(dimage->ref > 0) |
| @@ -537,7 +527,6 @@ drawuninstallscreen(Client *client, CScreen *this) · 44 unmodified lines |
| 537 | 527 | { |
| 538 | 528 | CScreen *cs, *next; |
| 539 | 529 | |
| 540 | | − // print("XXX drawuninstallscreen %d from window %d\n", this->dscreen->id, client->draw->window->id); |
| 541 | 530 | cs = client->cscreen; |
| 542 | 531 | if(cs == this){ |
| 543 | 532 | client->cscreen = this->next; |
| @@ -567,7 +556,6 @@ drawuninstall(Client *client, int id) · 23 unmodified lines |
| 567 | 556 | return -1; /* BUG: error(Enodrawimage); */ |
| 568 | 557 | if(d->id == id){ |
| 569 | 558 | client->dimage[id&HASHMASK] = d->next; |
| 570 | | − // print("XXX drawuninstall %d from client %d\n", id, client->draw->window->id); |
| 571 | 559 | drawfreedimage(client->draw, d); |
| 572 | 560 | return 0; |
| 573 | 561 | } |
| @@ -589,7 +577,6 @@ drawaddname(Client *client, DImage *di, int n, char *str, char **err) · 15 unmodified lines |
| 589 | 577 | DName *name, *ename, *new, *t; |
| 590 | 578 | char *ns; |
| 591 | 579 | |
| 592 | | − // print("XXX drawaddname %s\n", str); |
| 593 | 580 | name = dname; |
| 594 | 581 | ename = &name[ndname]; |
| 595 | 582 | for(; name<ename; name++) |
| @@ -671,7 +658,6 @@ drawimage(Client *client, uchar *a) · 75 unmodified lines |
| 671 | 658 | { |
| 672 | 659 | DImage *d; |
| 673 | 660 | |
| 674 | | − // print("XXX drawimage %d\n", BGLONG(a)); |
| 675 | 661 | d = drawlookup(client, BGLONG(a), 1); |
| 676 | 662 | if(d == nil) |
| 677 | 663 | return nil; /* caller must check! */ |
| @@ -850,7 +836,7 @@ drawread(Client *cl, int type, char *data, int count) · 172 unmodified lines |
| 850 | 836 | IOResponse r; |
| 851 | 837 | |
| 852 | 838 | r.data = data; |
| 853 | | − r.count = count; |
| 839 | + r.count = 0; |
| 854 | 840 | r.err = nil; |
| 855 | 841 | switch(type) { |
| 856 | 842 | case FsFCtl: |
| @@ -873,12 +859,14 @@ drawread(Client *cl, int type, char *data, int count) · 16 unmodified lines |
| 873 | 859 | if(count == -1) { |
| 874 | 860 | free(cl->readdata); |
| 875 | 861 | cl->readdata = nil; |
| 862 | + cl->nreaddata = 0; |
| 876 | 863 | return r; |
| 877 | 864 | } |
| 878 | 865 | if(count < cl->nreaddata) { |
| 879 | 866 | r.err = Eshortread; |
| 880 | 867 | return r; |
| 881 | 868 | } |
| 869 | + r.data = cl->readdata; |
| 882 | 870 | r.count = cl->nreaddata; |
| 883 | 871 | break; |
| 884 | 872 | case FsFColormap: |
| @@ -1145,6 +1133,9 @@ drawmesg(Client *client, void *av, int n) · 260 unmodified lines |
| 1145 | 1133 | dst = drawimage(client, a+1); |
| 1146 | 1134 | src = drawimage(client, a+5); |
| 1147 | 1135 | mask = drawimage(client, a+9); |
| 1136 | + /* |
| 1137 | + * TODO: this test fails on rio windows. |
| 1138 | + */ |
| 1148 | 1139 | if(!dst || !src || !mask) |
| 1149 | 1140 | goto Enodrawimage; |
| 1150 | 1141 | drawrectangle(&r, a+13); |
| @@ -1800,19 +1791,21 @@ drawwrite(Client *cl, int type, char *data, int count) · 649 unmodified lines |
| 1800 | 1791 | IOResponse r; |
| 1801 | 1792 | |
| 1802 | 1793 | r.data = data; |
| 1803 | | − r.count = count; |
| 1794 | + r.count = 0; |
| 1804 | 1795 | r.err = nil; |
| 1805 | 1796 | switch(type) { |
| 1806 | 1797 | case FsFData: |
| 1807 | 1798 | drawmesg(cl,data, count); |
| 1799 | + r.count = count; |
| 1808 | 1800 | // drawwakeall(); |
| 1809 | 1801 | break; |
| 1810 | 1802 | case FsFCtl: |
| 1811 | | − if(r.count != 4){ |
| 1803 | + if(count != 4){ |
| 1812 | 1804 | r.err = "unknown draw control request"; |
| 1813 | 1805 | break; |
| 1814 | 1806 | } |
| 1815 | 1807 | cl->infoid = BGLONG((uchar*)data); |
| 1808 | + r.count = count; |
| 1816 | 1809 | break; |
| 1817 | 1810 | case FsFColormap: |
| 1818 | 1811 | r.count = 0; |
| @@ -1931,8 +1924,15 @@ drawdettach(Draw *d) · 112 unmodified lines |
| 1931 | 1924 | freememimage(d->window->screenimage); |
| 1932 | 1925 | free(d->window->name); |
| 1933 | 1926 | d->window->name = nil; |
| 1934 | | − drawfreedscreen(d, d->dscreen); |
| 1935 | | − free(d); |
| 1927 | + if(d->dscreen) |
| 1928 | + drawfreedscreen(d, d->dscreen); |
| 1929 | + /* |
| 1930 | + * TODO: we cannot free d because it is needed |
| 1931 | + * to get the window from a client, and the structures |
| 1932 | + * of the drawing device will be freed after the |
| 1933 | + * window has been deleted. |
| 1934 | + */ |
| 1935 | + // free(d); |
| 1936 | 1936 | } |
| 1937 | 1937 | |
| 1938 | 1938 | Window* |