diff options
author | sabetts <sabetts> | 2001-03-19 08:35:36 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2001-03-19 08:35:36 +0000 |
commit | 23494269d7fb6bec696f305caa79a683ceb4bcbd (patch) | |
tree | dda073b707af449b62cf8329c587cac95e419e35 /src/events.c | |
parent | 7604e8eabbcc2e6142f7b3d75d38880044dd63f7 (diff) | |
download | ratpoison-23494269d7fb6bec696f305caa79a683ceb4bcbd.zip |
* 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
Diffstat (limited to 'src/events.c')
-rw-r--r-- | src/events.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/events.c b/src/events.c index ee858d0..f32b4fa 100644 --- a/src/events.c +++ b/src/events.c @@ -383,12 +383,51 @@ 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) { rp_window *win; 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) |