XRecord trouble

Joel Dice dicej at mailsnare.net
Thu Mar 3 07:26:15 PST 2005


Hello all.

I'm having trouble using the XRecord extension in a program, and I 
wondered if anyone on this list might have some insight.

The trouble is that XRecordDisableContext does not seem to have any 
effect, and I've been unable to find any way to stop a thread which has 
begun accepting XRecord events.  The following program illustrates the 
problem - the call to XCloseDisplay never returns:

---- begin testRecord.c ----
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/extensions/record.h>

static void
callback(XPointer p, XRecordInterceptData* data)
{
   fprintf(stderr, "got an XRecord event!\n");

   XRecordFreeData(data);
}

int
main()
{
   fprintf(stderr, "beginning\n");

   Display* display = XOpenDisplay(0);
   if (display == 0) {
     fprintf(stderr, "unable to open display\n");
     exit(-1);
   }

   XRecordClientSpec clients = XRecordAllClients;
   XRecordRange* range = XRecordAllocRange();
   if (range == 0) {
     fprintf(stderr, "unable to allocate XRecordRange\n");
     exit(-1);
   }

   range->device_events.first = KeyPress;
   range->device_events.last = MotionNotify;
   XRecordContext context = XRecordCreateContext
     (display, 0, &clients, 1, &range, 1);
   if (context == 0) {
     fprintf(stderr, "unable to create XRecordContext\n");
     exit(-1);
   }

   XFree(range);

   XRecordEnableContextAsync(display, context, callback, 0);

   XRecordDisableContext(display, context);
   XRecordFreeContext(display, context);
   XCloseDisplay(display);

   fprintf(stderr, "end\n");
   return 0;
}

---- end testRecord.c ----

This will compile it:

gcc -g -L/usr/X11R6/lib -lX11 -lXtst testXRecord.c -o testXRecord

Thanks in advance for any advice.

Sincerely,

Joel Dice



More information about the xorg mailing list