#include #include int main (int argc, char **argv) { Display *dpy; Window parent, child; GC gc; XSetWindowAttributes attr; unsigned long bits; XEvent ev; dpy = XOpenDisplay(NULL); if (!dpy) { fprintf(stderr, "Failed to open display\n"); return 1; } attr.background_pixel = WhitePixel(dpy,0); attr.event_mask = ExposureMask|KeyPressMask; bits = CWBackPixel|CWEventMask; parent = XCreateWindow(dpy, RootWindow(dpy,0), 0, 0, 200, 200, 0, DefaultDepth(dpy, 0), CopyFromParent, CopyFromParent, bits, &attr); child = XCreateWindow(dpy, parent, 0, -32760, 200, 32760 + 200, 0, DefaultDepth(dpy, 0), CopyFromParent, CopyFromParent, bits, &attr); gc = XCreateGC(dpy, child, 0, NULL); XSetForeground(dpy, gc, BlackPixel(dpy,0)); XMapWindow(dpy, child); XMapWindow(dpy, parent); for (;;) { XNextEvent(dpy, &ev); switch (ev.type) { case Expose: if (ev.xexpose.window == child) { XDrawLine(dpy, child, gc, 0, 32760, 100, 32760 + 100); } default: continue; case KeyPress: break; } break; } return 0; }