Blob


1 /*
2 * Original code posted to comp.sources.x (see printevent.c).
3 * Modifications by Russ Cox <rsc@swtch.com>.
4 */
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <X11/Intrinsic.h>
9 #include "printevent.h"
11 int
12 main(int argc, char **argv)
13 {
14 int screen;
15 Display *dpy;
16 Window window;
17 XEvent event;
19 if (!(dpy = XOpenDisplay(""))) {
20 printf("Failed to open display...\n");
21 exit(1);
22 }
24 screen = DefaultScreen(dpy);
26 window = XCreateSimpleWindow(dpy, RootWindow(dpy, screen), 100, 100,
27 300, 200, 2, BlackPixel(dpy, screen), WhitePixel(dpy, screen));
29 XSelectInput(dpy, window, KeyPressMask | KeyReleaseMask | ButtonPressMask |
30 ButtonReleaseMask | EnterWindowMask | LeaveWindowMask |
31 PointerMotionMask | PointerMotionHintMask | Button1MotionMask |
32 Button2MotionMask | Button3MotionMask | Button4MotionMask |
33 Button5MotionMask | ButtonMotionMask | KeymapStateMask |
34 ExposureMask | VisibilityChangeMask | StructureNotifyMask |
35 SubstructureNotifyMask | SubstructureRedirectMask | FocusChangeMask |
36 PropertyChangeMask | ColormapChangeMask | OwnerGrabButtonMask);
38 XMapWindow(dpy, window);
40 for(;;){
41 XNextEvent(dpy, &event);
42 printevent(&event);
43 }
44 }