/*----- Static variables --------------------------------------------------*/
-static Display *display = 0;
+static Display *dpy = 0;
static Window window = None;
/*----- Command implementations -------------------------------------------*/
if (argc != 2)
die(EXIT_FAILURE, "Usage: get PROPERTY");
- if ((p = XInternAtom(display, argv[1], True)) == None ||
- (a = xatom_get(display, window, p)) == None)
+ if ((p = XInternAtom(dpy, argv[1], True)) == None ||
+ (a = xatom_get(dpy, window, p)) == None)
return (0);
- name = XGetAtomName(display, a);
+ name = XGetAtomName(dpy, a);
puts(name);
return (0);
}
if (argc != 3)
die(EXIT_FAILURE, "Usage: set PROPERTY VALUE");
- p = XInternAtom(display, argv[1], False);
- a = XInternAtom(display, argv[2], False);
- xatom_set(display, window, p, a);
+ p = XInternAtom(dpy, argv[1], False);
+ a = XInternAtom(dpy, argv[2], False);
+ xatom_set(dpy, window, p, a);
return (0);
}
if (argc != 2)
die(EXIT_FAILURE, "Usage: delete PROPERTY");
- if ((p = XInternAtom(display, argv[1], True)) == None)
+ if ((p = XInternAtom(dpy, argv[1], True)) == None)
return (0);
- xatom_delete(display, window, p);
+ xatom_delete(dpy, window, p);
return (0);
}
if (argc < 2)
die(EXIT_FAILURE, "Usage: wait PROPERTY [VALUE...]");
- p = XInternAtom(display, argv[1], False);
+ p = XInternAtom(dpy, argv[1], False);
n = argc - 2;
if (n) {
aa = xmalloc(n * sizeof(Atom));
- XInternAtoms(display, argv + 2, n, False, aa);
+ XInternAtoms(dpy, argv + 2, n, False, aa);
}
- a = xatom_wait(display, window, p, aa, n);
+ a = xatom_wait(dpy, window, p, aa, n);
if (n != 1) {
- name = XGetAtomName(display, a);
+ name = XGetAtomName(dpy, a);
puts(name);
XFree(name);
}
static Window choosewindow(void)
{
- Cursor cross = XCreateFontCursor(display, XC_crosshair);
+ Cursor cross = XCreateFontCursor(dpy, XC_crosshair);
XEvent event;
- XGrabPointer(display,
- DefaultRootWindow(display),
+ XGrabPointer(dpy,
+ DefaultRootWindow(dpy),
False,
ButtonPressMask,
GrabModeAsync,
CurrentTime);
for (;;) {
- XNextEvent(display, &event);
+ XNextEvent(dpy, &event);
switch (event.type) {
case ButtonPress:
switch (event.xbutton.button) {
case 3:
- XUngrabPointer(display, event.xbutton.time);
+ XUngrabPointer(dpy, event.xbutton.time);
die(EXIT_FAILURE, "aborted window selection");
break;
case 1:
window = event.xbutton.subwindow;
if (window == None)
window = event.xbutton.window;
- XUngrabPointer(display, event.xbutton.time);
+ XUngrabPointer(dpy, event.xbutton.time);
return (window);
}
break;
int main(int argc, char *argv[])
{
- const char *dpy = 0;
+ const char *display = 0;
const char *win = 0;
unsigned f = 0;
case 'h': help(argv + optind); exit(0);
case 'u': usage(stdout); exit(0);
case 'v': version(); exit(0);
- case 'd': dpy = optarg; break;
+ case 'd': display = optarg; break;
case 'w': win = optarg; break;
default: f |= F_BOGUS; break;
}
/* --- Initialize --- */
autoreap();
- if ((display = XOpenDisplay(dpy)) == 0)
+ if ((dpy = XOpenDisplay(display)) == 0)
die(EXIT_FAILURE, "couldn't open display");
/* --- Select a target window --- */
if (!win)
- window = DefaultRootWindow(display);
+ window = DefaultRootWindow(dpy);
else if (strcmp(win, "choose") == 0)
window = choosewindow();
else