X.Org crash when trying to use XWarpPointer

Joel Feiner jafeiner at gmail.com
Wed Jun 24 06:52:04 PDT 2009



On 06/24/2009 08:55 AM, BlackLight wrote:
> I wrote a software for face detection using OpenCV libraries and X11
> for cursor wrapping. The software I wrote is for disabled people, to
> allow them moving the cursor using head movements and a webcam.
> Anyway, the software works greatly on my laptop computer, while it
> crashes when I run it on the computer where it should be run (a
> computer in my university that should be dedicated to the disabled).
> The X.Org version installed should be the same on both the machines:
>
> #include<stdio.h>
> #include<xorg/xorg-server.h>
> #include<xorg/xorgVersion.h>
>
> main()  {
>         printf ("%d.%d.%d.%d\n",
>                         XORG_VERSION_MAJOR,
>                         XORG_VERSION_MINOR,
>                         XORG_VERSION_PATCH,
>                         XORG_VERSION_SNAP);
> }
>
> This returns 1.4.2.0 on both the systems. I run a pre-compiled version
> of X.Org for Slackware on my laptop (the version available by default
> on Slackware 12.2), and the pre-compiled version for Debian on the
> university computer.
>
> I get a problem on the university computer when I try to move the
> cursor position using XWarpPointer. I should use it to move the cursor
> when the object identified as a "face" moves. This is the method I
> use:
>
> int setPointerPos (int x, int y)  {
>         Display *disp;
>         Window root;
>         Window father, child;
>         int screen;
>         int width = 1024; int height = 768;
>
>         if (!(disp = XOpenDisplay(NULL)))
>                 return -1;
>
>         screen = DefaultScreen(disp);
>         root = RootWindow(disp,screen);
>
>         if (!XWarpPointer(disp, father, child, 0, 0, width, height, x, y))
>                 return -1;
>
>         XCloseDisplay(disp);
>         return 0;
> }
>
> and this is the problem I get when a face is detected and I try to
> move the cursor:
>
> The program 'Smart detection' received an X Window System error.
> This probably reflects a bug in the program.
> The error was 'BadWindow (invalid Window parameter)'.
>   (Details: serial 7 error_code 3 request_code 41 minor_code 0)
>   (Note to programmers: normally, X errors are reported asynchronously;
>    that is, you will receive the error a while after causing it.
>    To debug your program, run it with the --sync command line
>    option to change this behavior. You can then get a meaningful
>    backtrace from your debugger if you break on the gdk_x_error() function.)
>
> What kind of trouble may be behind this?

One thing that is wrong is that "father" and "child" are never 
initialized.  I'm guessing this is where the error is coming from.

Also, is there a reason that you connect and disconnect each time the 
function is called?  Why not just connect once (somewhere else, of 
course) and just call XWarpPointer() in setPointerPos()?



More information about the xorg mailing list