Skip to content

Instantly share code, notes, and snippets.

@khajavi
Forked from aliva/move-cursor-linux.cpp
Created April 20, 2013 10:59
Show Gist options
  • Save khajavi/5425615 to your computer and use it in GitHub Desktop.
Save khajavi/5425615 to your computer and use it in GitHub Desktop.
#include <X11/Xlib.h>
#include <iostream>
#include <unistd.h>
int main(void) {
Display* dpy = XOpenDisplay(0);
int scr = XDefaultScreen(dpy);
Window root_window = XRootWindow(dpy, scr);
int height = DisplayHeight(dpy, scr);
int width = DisplayWidth(dpy, scr);
std::cout << "Screen size : " << width << "x" << height << std::endl;
float m = (float)height/(float)width;
int j;
for(int i=0; i<width; i++){
j = m*i;
XWarpPointer(dpy, None, root_window, 0, 0, 0, 0, i, j);
XFlush(dpy);
usleep(50);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment