wmii/cmd/wmiiwarp.c

55 lines
1.2 KiB
C
Raw Normal View History

2005-11-18 18:54:58 +03:00
/*
* (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>
2005-12-05 01:45:59 +03:00
static char *version[] = {
2005-11-18 18:54:58 +03:00
"wmiwarp - window manager improved warp - " VERSION "\n"
2005-12-05 01:45:59 +03:00
" (C)opyright MMIV-MMV Anselm R. Garbe\n", 0
2005-11-18 18:54:58 +03:00
};
2005-12-05 01:45:59 +03:00
static void usage()
2005-11-18 18:54:58 +03:00
{
fprintf(stderr,
2005-12-05 01:45:59 +03:00
"usage: wmiwarp [-v] <x>,<y>\n" " -v version info\n");
2005-11-18 18:54:58 +03:00
exit(1);
}
2005-12-05 01:45:59 +03:00
int main(int argc, char **argv)
2005-11-18 18:54:58 +03:00
{
2005-12-05 01:45:59 +03:00
Display *dpy;
int x, y;
2005-11-18 18:54:58 +03:00
/* 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)),
2005-12-05 01:45:59 +03:00
0, 0, 0, 0, x, y);
2005-11-18 18:54:58 +03:00
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
XCloseDisplay(dpy);
return 0;
}