Paste: code
Author: | slava |
Mode: | c |
Date: | Sat, 13 Dec 2008 09:00:48 |
Plain Text |
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
Display *dis;
Window win;
int x11_fd;
fd_set in_fds;
struct timeval tv;
XEvent ev;
int main() {
dis = XOpenDisplay(NULL);
win = XCreateSimpleWindow(dis, RootWindow(dis, 0), 1, 1, 256, 256, \
0, BlackPixel (dis, 0), BlackPixel(dis, 0));
XSelectInput(dis, win,
ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask | StructureNotifyMask
);
XMapWindow(dis, win);
XFlush(dis);
x11_fd = ConnectionNumber(dis);
while(1) {
FD_ZERO(&in_fds);
FD_SET(x11_fd, &in_fds);
tv.tv_usec = 0;
tv.tv_sec = 1;
if (select(x11_fd+1, &in_fds, 0, 0, &tv))
printf("Event Received!\n");
else
printf("Timer Fired!\n");
while(XPending(dis))
XNextEvent(dis, &ev);
}
return(0);
}
New Annotation