[Xcb] _XRegisterInternalConnection()

Russell Shaw rjshaw at netspace.net.au
Mon May 11 21:12:14 PDT 2009

I want to monitor the stdin file descriptor so that a callback
function is called, whilest select() is waiting on the X file descriptor.

It seems to no longer work. The old code in
libx11-1.2.1/src/XlibInt.c: _XWaitForReadable(Display *dpy) does:

   result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL);
   for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
     if (FD_ISSET(ilist->fd, &r_mask)) {
       _XProcessInternalConnection(dpy, ilist);     <<< what i want
       did_proc_conni = True;

The new code in libx11-1.2.1/src/xcb_io.c: _XReadEvents(Display *dpy) gets
stuck in xcb_conn.c: select(), where it does not monitor file descriptors
in dpy->im_fd_info provided by _XRegisterInternalConnection():

void _XReadEvents(Display *dpy)
   if(dpy->flags & XlibDisplayIOError)
   _XSend(dpy, NULL, 0);
   if(dpy->xcb->event_owner != XlibOwnsEventQueue)
   check_internal_connections(dpy);         <<< should be called in
                                                process_responses() below
   do {
     process_responses(dpy, 1, NULL, 0);    <<< stuck in xcb_conn.c: select()
   } while (dpy->qlen == 0);

Here's a test case that doesn't work. Every time you press <return> on the
command line while the prog is running (stdin), "fd: 0" should be printed:


static void
cmdproc(Display *display, int fd, XPointer xdata)
     printf("fd: %d\n", fd);

main(int argc, char **argv)
     Display *display = XOpenDisplay(NULL);


//  XSynchronize(display, 1);

     Status res = _XRegisterInternalConnection(display, 0, cmdproc, NULL);


     XEvent event;
     while(1) {
	XNextEvent(display, &event);
     return 0;

More information about the Xcb mailing list