#include "x11workaround.h"
void movePointer(int x, int y) {
bool result;
int root_x, root_y, win_x, win_y;
unsigned int mask_return;
Display* dpy = XOpenDisplay(0);
if (dpy == nullptr)
return;
Window root = DefaultRootWindow(dpy);
Window window_returned;
result = XQueryPointer(dpy, root, &window_returned, &window_returned, &root_x, &root_y, &win_x, &win_y, &mask_return);
if (result != true) {
fprintf(stderr, "No mouse found.\n");
return;
}
XWarpPointer(dpy, None,root, 0, 0, 0, 0, root_x - x ,root_y - y);
XFlush(dpy);
XCloseDisplay(dpy);
}
void wiggle() {
movePointer(5, 5);
movePointer(-5, -5);
}