vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

ltorear.c (1061B)


      1 #include "u.h"
      2 #include "lib.h"
      3 #include "draw.h"
      4 #include "memdraw.h"
      5 #include "memlayer.h"
      6 
      7 void
      8 _memltorear(Memimage *i, Memimage *rear)
      9 {
     10 	Memlayer *l;
     11 	Memscreen *s;
     12 	Memimage *f, *r, *rr;
     13 	Rectangle x;
     14 	int overlap;
     15 
     16 	l = i->layer;
     17 	s = l->screen;
     18 	while(l->rear != rear){
     19 		r = l->rear;
     20 		x = l->screenr;
     21 		overlap = rectclip(&x, r->layer->screenr);
     22 		if(overlap){
     23 			memlhide(i, x);
     24 			l->clear = 0;
     25 		}
     26 		/* swap l and r in screen's list */
     27 		rr = r->layer->rear;
     28 		f = l->front;
     29 		if(rr == nil)
     30 			s->rearmost = i;
     31 		else
     32 			rr->layer->front = i;
     33 		if(f == nil)
     34 			s->frontmost = r;
     35 		else
     36 			f->layer->rear = r;
     37 		l->rear = rr;
     38 		l->front = r;
     39 		r->layer->rear = i;
     40 		r->layer->front = f;
     41 		if(overlap)
     42 			memlexpose(r, x);
     43 	}
     44 }
     45 
     46 void
     47 memltorear(Memimage *i)
     48 {
     49 	_memltorear(i, nil);
     50 	_memlsetclear(i->layer->screen);
     51 }
     52 
     53 void
     54 memltorearn(Memimage **ip, int n)
     55 {
     56 	Memimage *i, *rear;
     57 	Memscreen *s;
     58 
     59 	if(n == 0)
     60 		return;
     61 	rear = nil;
     62 	while(--n >= 0){
     63 		i = *ip++;
     64 		_memltorear(i, rear);
     65 		rear = i;
     66 	}
     67 	s = rear->layer->screen;
     68 	_memlsetclear(s);
     69 }