From 23494269d7fb6bec696f305caa79a683ceb4bcbd Mon Sep 17 00:00:00 2001 From: sabetts Date: Mon, 19 Mar 2001 08:35:36 +0000 Subject: * src/main.c (ratpoison_longopts): add --command to recognized command-line options. * src/communications.h (send_command): new function prototype * src/data.h (rp_command): new global variable * src/events.c (receive_command): new function (property_notify): handles rp_command Atoms * src/communications.c (send_command): new function * src/main.c (print_help): prints help for --command (main): handles --command command-line option --- src/events.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/events.c') diff --git a/src/events.c b/src/events.c index ee858d0..f32b4fa 100644 --- a/src/events.c +++ b/src/events.c @@ -382,6 +382,38 @@ key_press (XEvent *ev) } } +void +receive_command() +{ + Atom type_ret; + int format_ret; + unsigned long nitems; + unsigned long bytes_after; + unsigned char *req; + + if (XGetWindowProperty (dpy, DefaultRootWindow (dpy), rp_command, + 0, 0, False, XA_STRING, + &type_ret, &format_ret, &nitems, &bytes_after, + &req) == Success + && + XGetWindowProperty (dpy, DefaultRootWindow (dpy), rp_command, + 0, (bytes_after / 4) + (bytes_after % 4 ? 1 : 0), + True, XA_STRING, &type_ret, &format_ret, &nitems, + &bytes_after, &req) == Success) + { + if (req) + { + PRINT_DEBUG ("command: %s\n", req); + command (req); + } + XFree (req); + } + else + { + PRINT_DEBUG ("Couldn't get RP_COMMAND Property\n"); + } +} + void property_notify (XEvent *ev) { @@ -389,6 +421,13 @@ property_notify (XEvent *ev) PRINT_DEBUG ("atom: %ld\n", ev->xproperty.atom); + if (ev->xproperty.atom == rp_command + && ev->xproperty.window == DefaultRootWindow (dpy)) + { + PRINT_DEBUG ("ratpoison command\n"); + receive_command(); + } + win = find_window (ev->xproperty.window); if (win) -- cgit v1.2.3