| It seems like your understanding of save under is correct, except for
one thing: the save under flag is just a flag which means 'Hey Server,
t'would be great if you could save the content of any window I could
obscure'. You don't have any guarantee that the server will follow your
advice; the server could always take your hint in account, sometimes
take it in account, or never take it in account. I'm not 100% positive,
but I believe that our V1 servers just ignore this hint; in other
words, your WINDOW-B will not automagically be repainted, and you need
some code to handle the expose events and do the right thing. Things
may be different in V2, I don't know.
Denis.
|
| And even if it were implemented, your application still cannot rely on the hint
being taken--it must still be prepared to handle exposure events anywhere in its
windows, at any time. The only advantage of specifying the save-under hint is
that, if the hint is taken, you will get fewer (or no) expose events actually
generated and thus things will run more efficiently.
--PSW
|
| The PMAX color server (in UWS2.2 field test at least) claims that it
does save unders. Unfortunately, I haven't been able to get them to
happen. Maybe I'm doing something stupid, it's so late at night...
Sample program follows. The idea is there's one window inside the
other. If you click in the larger window, the smaller one is mapped or
unmapped. Notice that the larger window gets an expose event on each
unmap, in spite of the save unders.
#include <stdio.h>
#include <X11/Xlib.h>
main() {
Display *d;
Window w,w2;
XEvent ev;
XSetWindowAttributes xwa;
int w2_mapped;
d = XOpenDisplay("");
XSynchronize(d,1);
printf(" Does save unders = %d\n",
DoesSaveUnders(DefaultScreenOfDisplay(d)));
w = XCreateSimpleWindow(d,RootWindow(d,0),100,100,300,300,
0,BlackPixel(d,0),WhitePixel(d,0));
xwa.border_pixel = BlackPixel(d,0);
xwa.save_under = 1;
w2 = XCreateWindow(d,w,10,10,100,100,1,CopyFromParent,
CopyFromParent,CopyFromParent,CWBorderPixel|CWSaveUnder,&xwa);
w2_mapped = 0;
XSelectInput(d,w,ButtonPressMask|ExposureMask);
XMapWindow(d,w);
while (1) {
XNextEvent(d,&ev);
if (ev.type == ButtonPress) {
if (w2_mapped) {
XUnmapWindow(d,w2);
w2_mapped = 0;
} else {
XMapWindow(d,w2);
w2_mapped = 1;
}
} else if (ev.type == Expose && ev.xexpose.window == w)
printf("x \n");
}
}
|