/* XMouseKeys.c
**
** Move the mouse cursor by the specified vector, useful for keyboard
** bindings in pwm and other WMs which don't have this functionality
**
** contact: fluffy at beesbuzz dot biz
** Released into the public domain
**
** Compile with:
**
** cc -o xmousekeys xmousekeys.c -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lXext
*/

#include <stdio.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

int main(int argc, char *argv[])
{
	Display *bob;
	int xoff, yoff;

	if (argc != 3)
	{
		fprintf (stderr, "Usage: %s xoffset yoffset\n", argv[0]);
		return 1;
	}

	xoff = atoi(argv[1]);
	yoff = atoi(argv[2]);

	bob = XOpenDisplay(NULL);
	if (!bob)
	{
		fprintf (stderr, "Could not open display\n");
		return 1;
	}

	XWarpPointer(bob, None, None, 0, 0, 0, 0, xoff, yoff);
	XSync(bob, 0);
	return 0;
}
