vx32

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

ltofront.c (1288B)


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