Search code examples
c++linuxuser-interfacecursorxorg

Sending Programmatic Mouse Events to X


I am somewhat new to X development on Linux. I'm wondering what are best practices (or links to resources) for programmatically sending cursor events. Moving the cursor to a normalized (X,Y), creating right/left mouse clicks, etc. Ideally this would be something in C/C++.

I have played around with the Qt QCursor but I'd like to know the raw way to accomplish this.


Solution

  • I think you can use XSendEvent. There's some sample code here which uses XQueryPointer to populate most of the event fields.

    If you just want to move the pointer, use XWarpPointer.