#include #include #define BREAK_MODULAR #define ERROR(fmt, args...) do { \ fprintf(stderr, fmt, ##args); \ return -1; \ }while(0); int main() { Display *dpy; int screen; Window root, wnd; XSetWindowAttributes attr; int flags = 0; dpy = XOpenDisplay(NULL); if (!dpy) ERROR("unable to open display"); XSynchronize(dpy, True); screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); if (root == None) ERROR("invalid root window\n"); wnd = XCreateSimpleWindow(dpy, root, 0, 0, 640, 480, 0, BlackPixel(dpy, screen), WhitePixel(dpy, screen)); if (wnd == None) ERROR("invalid window\n"); #ifdef BREAK_MODULAR XSelectInput(dpy, wnd, KeyPressMask); #endif XMapRaised(dpy, wnd); while(1) { XEvent ev; XNextEvent(dpy, &ev); switch(ev.type) { case KeyPress: XCloseDisplay(dpy); return 0; default: break; } }; }