#include int main() { Display* dpy = XOpenDisplay(0); int scrnum = DefaultScreen(dpy); Window root = RootWindow(dpy, scrnum); long unsigned int white_pixel = WhitePixel(dpy, scrnum); Window win = XCreateSimpleWindow(dpy, root, 0, 0, 100, 100, 0, white_pixel, white_pixel); XMapWindow(dpy, win); XSelectInput(dpy, win, ExposureMask); GC gc = XCreateGC(dpy, win, 0, 0); while(1) { XEvent event; XNextEvent(dpy, &event); if(event.type == Expose) { XDrawLine(dpy, win, gc, 0, 0, 0, 0); // This produces either one black pixel or nothing in 0x0 coordinates of the window. } } }