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