summaryrefslogtreecommitdiffstats
path: root/src/x11workaround.cpp
blob: c093362a328dee37302aebd401d3dc726cabb1ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#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);
    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);
}

void wiggle() {
    movePointer(5, 5);
    movePointer(-5, -5);
}