mirror of
https://github.com/0intro/wmii
synced 2024-11-22 13:52:17 +03:00
57 lines
1.2 KiB
C
57 lines
1.2 KiB
C
/*
|
|
* (C)opyright MMIV-MMV Anselm R. Garbe <garbeam at gmail dot com>
|
|
* See LICENSE file for license details.
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
#include <X11/Xatom.h>
|
|
|
|
static char *version[] = {
|
|
"wmiwarp - window manager improved warp - " VERSION "\n"
|
|
" (C)opyright MMIV-MMV Anselm R. Garbe\n", 0
|
|
};
|
|
|
|
static void
|
|
usage()
|
|
{
|
|
fprintf(stderr,
|
|
"usage: wmiwarp [-v] <x>,<y>\n" " -v version info\n");
|
|
exit(1);
|
|
}
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
Display *dpy;
|
|
int x, y;
|
|
|
|
/* command line args */
|
|
if (argc != 2)
|
|
usage();
|
|
if (!strncmp(argv[1], "-v", 2)) {
|
|
fprintf(stdout, "%s", version[0]);
|
|
exit(0);
|
|
}
|
|
dpy = XOpenDisplay(0);
|
|
if (!dpy) {
|
|
fprintf(stderr, "%s", "wmiwarp: cannot open display\n");
|
|
exit(1);
|
|
}
|
|
if (!strncmp(argv[1], "center", 7)) {
|
|
x = DisplayWidth(dpy, DefaultScreen(dpy)) / 2;
|
|
y = DisplayHeight(dpy, DefaultScreen(dpy)) / 2;
|
|
} else if (sscanf(argv[1], "%d,%d", &x, &y) != 2) {
|
|
XCloseDisplay(dpy);
|
|
usage();
|
|
}
|
|
XWarpPointer(dpy, None, RootWindow(dpy, DefaultScreen(dpy)),
|
|
0, 0, 0, 0, x, y);
|
|
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
|
XCloseDisplay(dpy);
|
|
return 0;
|
|
}
|