Created
June 29, 2015 06:19
-
-
Save macrat/aa3ef84295f6eed8b225 to your computer and use it in GitHub Desktop.
飛び交うカーソル。
This file contains hidden or 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 <unistd.h> | |
| #include <X11/Xlib.h> | |
| #include <X11/Xutil.h> | |
| int main() | |
| { | |
| Display *dpy = XOpenDisplay(NULL); | |
| int w = WidthOfScreen(XDefaultScreenOfDisplay(dpy)); | |
| int h = HeightOfScreen(XDefaultScreenOfDisplay(dpy)); | |
| int x=0, y=0; | |
| int mx=1, my=1; | |
| while(1) | |
| { | |
| XWarpPointer(dpy, None, DefaultRootWindow(dpy), 0, 0, 0, 0, x, y); | |
| XFlush(dpy); | |
| x += mx; | |
| y += my; | |
| if(x < 0 || w < x) | |
| mx *= -1; | |
| if(y < 0 || h < y) | |
| my *= -1; | |
| usleep(1000); | |
| } | |
| XCloseDisplay(dpy); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment