1

I'm writing a small program to control a mouse cursor using Xlib. I need to arbitrarily set its location on a multi-display configuration. The OS is linux and the xinerama mode is enabled.

Using the code below, the pointer does not work as I expect.

xdisplay1 = XOpenDisplay(NULL);

root = DefaultRootWindow(xdisplay1);

XWarpPointer(xdisplay1,None,root,0,0,0,x,y);

XFlush(xdisplay1);

The events are generally not flushed, unless I "manually shake" the mouse device. In addition, it only works if I do not warp into another monitor. When this happens, the pointer is stuck at the corresponding edge of warping.

This behavior led me to think that the problem is related to the multi-display configuration. Is there anyone who knows how to solve it quickly?

Thanks!

antrox
  • 68
  • 1
  • 7
  • The mouse cursor is not "visually" updated, but now I am sure it is moving. The mouse events are successfully caught using GLUT. It would be nice, however, to know the reason for this weird behavior. Thanks! – antrox Mar 01 '12 at 00:36

1 Answers1

0

It is not the prettiest solution but calling

  XDefineCursor(display,root_window,XCreateFontCursor(display, XC_circle)); 

seems to be a workaround.

joekr
  • 1,543
  • 1
  • 16
  • 22