wmii/cmd/wmiiwarp.c

58 lines
1.4 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-12-21 18:18:11 +03:00
"wmiiwarp - window manager improved warp - " VERSION "\n"
" (C)opyright MMIV-MMV Anselm R. Garbe\n", 0
2005-11-18 18:54:58 +03:00
};
2005-12-21 18:18:11 +03:00
static void
usage()
2005-11-18 18:54:58 +03:00
{
2005-12-21 18:18:11 +03:00
fprintf(stderr,
"usage: wmiiwarp [-v] <x> <y>\n"
2005-12-21 18:18:11 +03:00
" -v version info\n");
exit(1);
2005-11-18 18:54:58 +03:00
}
2005-12-21 18:18:11 +03:00
int
main(int argc, char **argv)
2005-11-18 18:54:58 +03:00
{
2005-12-21 18:18:11 +03:00
Display *dpy;
int x, y;
2005-11-18 18:54:58 +03:00
2005-12-21 18:18:11 +03:00
/* command line args */
if(argc < 2)
2005-12-21 18:18:11 +03:00
usage();
if(!strncmp(argv[1], "-v", 2)) {
fprintf(stdout, "%s", version[0]);
exit(0);
}
dpy = XOpenDisplay(0);
if(!dpy) {
fprintf(stderr, "%s", "wmiiwarp: cannot open display\n");
exit(1);
}
if((argc == 2) && !strncmp(argv[1], "center", 7)) {
2005-12-21 18:18:11 +03:00
x = DisplayWidth(dpy, DefaultScreen(dpy)) / 2;
y = DisplayHeight(dpy, DefaultScreen(dpy)) / 2;
} else if(argc == 3) {
x = cext_strtonum(argv[1], 0, DisplayWidth(dpy, DefaultScreen(dpy)));
y = cext_strtonum(argv[2], 0, DisplayHeight(dpy, DefaultScreen(dpy)));
2005-12-21 18:18:11 +03:00
}
XWarpPointer(dpy, None, RootWindow(dpy, DefaultScreen(dpy)),
0, 0, 0, 0, x, y);
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
XCloseDisplay(dpy);
return 0;
2005-11-18 18:54:58 +03:00
}