devdraw.ed (2351B)
1 /^drawgen/ s/char\*, Dirtab\*, int,/char *_, Dirtab *__, int ___,/ 2 ,s/(Memimage\*,/(Memimage *m,/ 3 ,s/(next = ds->next)/(&)/ 4 ,s/(next = d->next)/(&)/ 5 ,s/(next = cs->next)/(&)/ 6 /^makescreenimage/+2i 7 void *X; 8 . 9 /attachscreen/ s/);/, \&X);/ 10 /allocmemimaged/ s/md)/md, X)/ 11 ,s/(r = cl->refresh)/(&)/ 12 /^drawwrite/ s/vlong)/vlong _)/ 13 g/SET(s,q,p)/d 14 g/USED/d 15 g/^ int s;/d 16 /screen.h"/a 17 18 #define blankscreen(x) 19 #define ishwimage(x) (0) 20 . 21 /^drawlookupscreen/;# 22 / return 0/ s/return 0/for(;;)/ 23 g/Edepth/d 24 /l = dimage->image;/d 25 -1i 26 l = dimage->image; 27 dimage->dscreen = nil; /* paranoia */ 28 dimage->image = nil; 29 . 30 /^drawattach/;# 31 /initscreenimage/s/(.*)/(!conf.monitor || !initscreenimage())/ 32 /freememimage(dimage->image);/ s/dimage->image/l/ 33 ,s/dunlock/drawqunlock/g 34 ,s/candlock/drawcanqlock/g 35 ,s/dlock(/drawqlock(/g 36 ,s;MACHP(0)->ticks;msec()/1000;g 37 /^drawqlock/-1 s/static // 38 /^drawqunlock/-1 s/static // 39 /^drawcanqlock/-1 s/static // 40 $a 41 42 /* why is this here? why can't caller use drawqlock himself? */ 43 void 44 drawflushr(Rectangle r) 45 { 46 drawqlock(); 47 flushmemscreen(r); 48 drawqunlock(); 49 } 50 51 void 52 drawreplacescreenimage(Memimage *m) 53 { 54 int i; 55 DImage *di; 56 57 if(screendimage == nil) 58 return; 59 60 /* 61 * Replace the screen image because the screen 62 * was resized. Clients still have references to the 63 * old screen image, so we can't free it just yet. 64 */ 65 drawqlock(); 66 di = allocdimage(m); 67 if(di == nil){ 68 print("no memory to replace screen image\n"); 69 freememimage(m); 70 drawqunlock(); 71 return; 72 } 73 74 /* Replace old screen image in global name lookup. */ 75 for(i=0; i<sdraw.nname; i++){ 76 if(sdraw.name[i].dimage == screendimage) 77 if(sdraw.name[i].client == nil){ 78 sdraw.name[i].dimage = di; 79 break; 80 } 81 } 82 83 drawfreedimage(screendimage); 84 screendimage = di; 85 screenimage = m; 86 87 /* 88 * Every client, when it starts, gets a copy of the 89 * screen image as image 0. Clients only use it 90 * for drawing if there is no /dev/winname, but 91 * this /dev/draw provides a winname (early ones 92 * didn't; winname originated in rio), so the 93 * image only ends up used to find the screen 94 * resolution and pixel format during initialization. 95 * Silently remove the now-outdated image 0s. 96 */ 97 for(i=0; i<sdraw.nclient; i++){ 98 if(sdraw.client[i] && !waserror()){ 99 drawuninstall(sdraw.client[i], 0); 100 poperror(); 101 } 102 } 103 104 drawqunlock(); 105 mouseresize(); 106 } 107 .