diff --git a/xdemo.c b/xdemo.c new file mode 100644 --- /dev/null +++ b/xdemo.c @@ -0,0 +1,53 @@ +/** + * $Id: xdemo.c,v 1.1.1.1 2008-04-28 17:32:53 mbroeker Exp $ + * $Source: /development/c/demos/xdemo.c,v $ + * + */ + +#include +#include +#include + +int main (int argc, char **argv) +{ + Window w = 0; + Display *dpy = XOpenDisplay (NULL); + XEvent xev; + int active; + + if (dpy == NULL) { + printf ("Error opening localhost:0\n"); + return EXIT_SUCCESS; + } + + XSynchronize (dpy, 1); + w = XCreateSimpleWindow (dpy, DefaultRootWindow (dpy), 0, 0, 640, 480, 1, 1, 1); + + if (w < 0) + return EXIT_SUCCESS; + + printf ("WINDOW-ID: %ld\n", w); + + XRaiseWindow (dpy, w); + XMapWindow (dpy, w); + + printf ("Press any key to quit\n"); + + active = 1; + XSelectInput (dpy, w, KeyPressMask); + + while (active) { + XNextEvent (dpy, &xev); + switch (xev.type) { + case KeyPress: + active = 0; + break; + default: + printf ("Unknown Event: %d\n", xev.type); + } + } + + XDestroyWindow (dpy, w); + XCloseDisplay (dpy); + return 0; +}