ado@elsie.UUCP (Arthur David Olson) (10/24/89)
I'm surprised that in the attached code, the X Server is giving me expose events with x and y values of 100 for a 100x100 window-- but only if backing store is enabled. If you can tell me what I've done wrong, I'd appreciate hearing from you by electronic mail. -- Arthur David Olson ado@alw.nih.gov ADO is a trademark of Ampex. Script started on Mon Oct 23 13:02:09 1989 elsie$ cat try.c #include <stdio.h> #include <X11/Xlib.h> Display * display; int screen_number; GC gc; Window root; Window first; Window second; XEvent xe; static void await_event(type, desc) char * desc; { XSync(display, 0); do { XNextEvent(display, &xe); (void) printf("got event type %d\n", xe.type); } while (xe.type != type); } int main(argc, argv) int argc; char * argv[]; { XSetWindowAttributes xswa; XExposeEvent * xeep; xeep = (XExposeEvent *) &xe; if (argc != 2) return 1; if (argv[1][0] == 'a' || argv[1][0] == 'A') xswa.backing_store = Always; else if (argv[1][0] == 'n' || argv[1][0] == 'N') xswa.backing_store = NotUseful; else if (argv[1][0] == 'w' || argv[1][0] == 'W') xswa.backing_store = WhenMapped; else return 1; display = XOpenDisplay((char *) NULL); screen_number = DefaultScreen(display); gc = DefaultGC(display, screen_number); root = DefaultRootWindow(display); first = XCreateSimpleWindow(display, root, 1, 1, 100, 100, 1, 1, 0); XSelectInput(display, first, ExposureMask); XChangeWindowAttributes(display, first, CWBackingStore, &xswa); XMapWindow(display, first); await_event(Expose, "Expose"); second = XCreateSimpleWindow(display, first, 26, 26, 50, 50, 1, 1, 0); XSelectInput(display, second, ExposureMask); XMapWindow(display, second); await_event(Expose, "Expose"); XFillRectangle(display, first, gc, 0, 0, 100, 100); XSync(display, 0); /* ** So much for preamble. */ XCopyArea(display, first, first, gc, 10, 20, 100, 100, 0, 0); for ( ; ; ) { await_event(GraphicsExpose, "GraphicsExpose"); (void) printf("x\t%d\ty\t%d\twidth\t%d\theight\t%d\n", xeep->x, xeep->y, xeep->width, xeep->height); } } elsie$ cc try.c -lX11 -o try elsie$ try n got event type 12 got event type 12 got event type 13 x 90 y 0 width 10 height 6 got event type 13 x 16 y 6 width 52 height 20 got event type 13 x 90 y 6 width 10 height 20 got event type 13 x 16 y 26 width 10 height 32 got event type 13 x 90 y 26 width 10 height 32 got event type 13 x 90 y 58 width 10 height 22 got event type 13 x 0 y 80 width 100 height 20 ^Celsie$ try a got event type 12 got event type 12 got event type 13 >>>>> x 100 y 20 width 10 height 80 got event type 13 >>>>> x 10 y 100 width 100 height 20 ^Celsie$ exit script done on Mon Oct 23 13:03:06 1989