Created
October 2, 2013 11:45
-
-
Save xmisao/6792485 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<X11/Xlib.h> | |
#include<stdio.h> | |
#include<time.h> | |
typedef struct{ | |
int x, y; | |
} Pos; | |
Pos get_pos(Display *dpy, Window root){ | |
Window w; | |
Window root_return, child_return; | |
Pos root_pos; | |
int win_x, win_y; | |
unsigned int mask; | |
XQueryPointer(dpy, root, &root_return, &child_return, &root_pos.x, &root_pos.y, &win_x, &win_y, &mask); | |
return root_pos; | |
} | |
int main(){ | |
Display* dpy; | |
Window root; | |
Pos pos; | |
time_t t; | |
dpy = XOpenDisplay(NULL); | |
root = DefaultRootWindow(dpy); | |
while(1){ | |
time(&t); | |
pos = get_pos(dpy, root); | |
printf("%d,%d,%s", pos.x, pos.y, ctime(&t)); | |
fflush(stdout); | |
sleep(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment