added screen dimensions

This commit is contained in:
kolaente 2019-06-02 17:41:43 +02:00
parent b52460d87c
commit 57f80410fb
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 19 additions and 12 deletions

31
main.c
View File

@ -4,29 +4,36 @@
#include <stdbool.h>
#include <zconf.h>
void moveCursor(int destX, int destY) {
Display *dpy;
Window root_window;
dpy = XOpenDisplay(0);
root_window = XRootWindow(dpy, 0);
XWarpPointer(dpy, None, root_window, 0, 0, 0, 0, destX, destY);
XFlush(dpy);
}
int getRandom(int lower, int upper) {
unsigned int seed = (unsigned int) time(NULL);
srand(seed);
return rand() % (upper - lower + 1) + lower;
}
void moveCursor() {
Display *dpy;
Window root_window;
dpy = XOpenDisplay(0);
Screen *screen = XScreenOfDisplay(dpy, 0);
root_window = XRootWindow(dpy, 0);
int width = XWidthOfScreen(screen);
int height = XHeightOfScreen(screen);
int destX = getRandom(0, width);
int destY = getRandom(0, height);
XWarpPointer(dpy, None, root_window, 0, 0, width, height, destX, destY);
XFlush(dpy);
}
int main() {
while(true) {
sleep(getRandom(60, 600));
sleep(getRandom(0, 10));
if (getRandom(0, 100) > 50) {
continue;
}
moveCursor(getRandom(0, 1920), getRandom(0, 1080));
moveCursor();
}
}