From ad1da50e94819e8e79da1fc0246f247bfdbc99a9 Mon Sep 17 00:00:00 2001 From: sabetts Date: Tue, 5 Oct 2004 03:07:22 +0000 Subject: * src/screen.h (is_a_root_window): new prototype * src/screen.c (is_a_root_window): new function * src/events.c (property_notify): check for ratpoison commands on every root window, not just the default root window. * src/communications.c (send_command): store the root window in a variable, root. and use it whenever the root window is needed. --- src/communications.c | 16 ++++++---------- src/events.c | 2 +- src/screen.c | 11 +++++++++++ src/screen.h | 2 +- 4 files changed, 19 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/communications.c b/src/communications.c index 79af600..4356dfa 100644 --- a/src/communications.c +++ b/src/communications.c @@ -83,7 +83,7 @@ receive_command_result (Window w) int send_command (unsigned char interactive, unsigned char *cmd, int screen_num) { - Window w; + Window w, root; int done = 0; struct sbuf *s; @@ -94,15 +94,11 @@ send_command (unsigned char interactive, unsigned char *cmd, int screen_num) /* If the user specified a specific screen, then send the event to that screen. */ if (screen_num >= 0) - { - w = XCreateSimpleWindow (dpy, RootWindow (dpy, screen_num), - 0, 0, 1, 1, 0, 0, 0); - } + root = RootWindow (dpy, screen_num); else - { - w = XCreateSimpleWindow (dpy, DefaultRootWindow (dpy), - 0, 0, 1, 1, 0, 0, 0); - } + root = DefaultRootWindow (dpy); + + w = XCreateSimpleWindow (dpy, root, 0, 0, 1, 1, 0, 0, 0); /* Select first to avoid race condition */ XSelectInput (dpy, w, PropertyChangeMask); @@ -110,7 +106,7 @@ send_command (unsigned char interactive, unsigned char *cmd, int screen_num) XChangeProperty (dpy, w, rp_command, XA_STRING, 8, PropModeReplace, sbuf_get(s), strlen (cmd) + 2); - XChangeProperty (dpy, DefaultRootWindow (dpy), + XChangeProperty (dpy, root, rp_command_request, XA_WINDOW, 8, PropModeAppend, (unsigned char *)&w, sizeof (Window)); diff --git a/src/events.c b/src/events.c index 001eab6..220e7df 100644 --- a/src/events.c +++ b/src/events.c @@ -561,7 +561,7 @@ property_notify (XEvent *ev) PRINT_DEBUG (("atom: %ld\n", ev->xproperty.atom)); if (ev->xproperty.atom == rp_command_request - && ev->xproperty.window == DefaultRootWindow (dpy) + && is_a_root_window (ev->xproperty.window) && ev->xproperty.state == PropertyNewValue) { PRINT_DEBUG (("ratpoison command\n")); diff --git a/src/screen.c b/src/screen.c index 5d7329d..56aa96e 100644 --- a/src/screen.c +++ b/src/screen.c @@ -146,6 +146,17 @@ find_screen (Window w) return NULL; } +/* Return 1 if w is a root window of any of the screens. */ +int +is_a_root_window (int w) +{ + int i; + for (i=0; i