summaryrefslogblamecommitdiffstats
path: root/src/x11workaround.cpp
blob: 355496395bb37637316d90848d9dcbdd260ee76f (plain) (tree)
1
2
3
4
5
6
7
8
9
10







                                      

                       








                                                                                                                          
                       





                        
#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);
}