5 typedef struct Memimage Memimage;
10 allocscreen(Image *image, Image *fill, int public)
18 if(d != fill->display){
19 werrstr("allocscreen: image and fill on different displays");
22 s = malloc(sizeof(Screen));
26 for(try=0; try<25; try++){
27 /* loop until find a free id */
28 a = bufimage(d, 1+4+4+4+1);
36 BPLONG(a+5, image->id);
37 BPLONG(a+9, fill->id);
39 if(flushimage(d, 0) != -1)
45 assert(s->image && s->image->chan != 0);
52 publicscreen(Display *d, int id, ulong chan)
57 s = malloc(sizeof(Screen));
60 a = bufimage(d, 1+4+4);
69 if(flushimage(d, 0) < 0)
94 * flush(1) because screen is likely holding last reference to
95 * window, and want it to disappear visually.
97 if(flushimage(d, 1) < 0)
104 allocwindow(Screen *s, Rectangle r, int ref, ulong val)
106 return _allocwindow(nil, s, r, ref, val);
110 _allocwindow(Image *i, Screen *s, Rectangle r, int ref, ulong val)
115 i = _allocimage(i, d, r, d->screenimage->chan, 0, val, s->id, ref);
119 i->next = s->display->windows;
120 s->display->windows = i;
126 topbottom(Image **w, int n, int top)
134 fprint(2, "top/bottom: ridiculous number of windows\n");
139 if(n > (w[0]->display->bufsize-100)/4)
142 * this used to check that all images were on the same screen.
143 * we don't know the screen associated with images we acquired
144 * by name. instead, check that all images are on the same display.
145 * the display will check that they are all on the same screen.
149 if(w[i]->display != d){
150 fprint(2, "top/bottom: windows not on same screen\n");
156 b = bufimage(d, 1+1+2+4*n);
161 BPLONG(b+4+4*i, w[i]->id);
165 bottomwindow(Image *w)
181 bottomnwindows(Image **w, int n)
187 topnwindows(Image **w, int n)
193 originwindow(Image *w, Point log, Point scr)
198 flushimage(w->display, 0);
199 b = bufimage(w->display, 1+4+2*4+2*4);
208 if(flushimage(w->display, 1) < 0)
210 delta = subpt(log, w->r.min);
211 w->r = rectaddpt(w->r, delta);
212 w->clipr = rectaddpt(w->clipr, delta);