From 47c3a7c2bed43e9c73c87be8283af1bd4f216e82 Mon Sep 17 00:00:00 2001 From: sabetts Date: Sat, 15 Jan 2005 17:03:34 +0000 Subject: * src/globals.h (rp_exec_newwm): new extern. * src/globals.c (rp_exec_newwm): new global. * src/actions.c (cmd_newwm): set rp_exec_newwm to the new wm. * src/events.c (listen_for_events): call XSync after delegate_event. (handle_signals): exec newwm if its not NULL. Report X11 errors (moved from listen_for_events). --- src/actions.c | 9 ++------- src/events.c | 31 +++++++++++++++++++++++-------- src/globals.c | 2 ++ src/globals.h | 6 ++++++ 4 files changed, 33 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/actions.c b/src/actions.c index 8d301c6..0e80fbb 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2408,13 +2408,8 @@ spawn(char *cmd) cmdret * cmd_newwm(int interactive, struct cmdarg **args) { - PRINT_DEBUG (("Switching to %s\n", ARG_STRING(0))); - - putenv(current_screen()->display_string); - execlp(ARG_STRING(0), ARG_STRING(0), 0); - - PRINT_ERROR (("exec %s ", ARG_STRING(0))); - perror(" failed"); + /* in the event loop, this will switch WMs. */ + rp_exec_newwm = xstrdup (ARG_STRING(0)); return cmdret_new (NULL, RET_SUCCESS); } diff --git a/src/events.c b/src/events.c index a207de7..5921244 100644 --- a/src/events.c +++ b/src/events.c @@ -886,6 +886,20 @@ handle_signals () chld_signalled = 0; } + if (rp_exec_newwm) + { + PRINT_DEBUG (("Switching to %s\n", rp_exec_newwm)); + + putenv(current_screen()->display_string); + execlp(rp_exec_newwm, rp_exec_newwm, 0); + + /* Failed. Clean up. */ + PRINT_ERROR (("exec %s ", rp_exec_newwm)); + perror(" failed"); + free (rp_exec_newwm); + rp_exec_newwm = NULL; + } + if (hup_signalled > 0) { PRINT_DEBUG (("Restarting\n")); @@ -901,6 +915,14 @@ handle_signals () clean_up (); exit (EXIT_SUCCESS); } + + /* Report any X11 errors that have occurred. */ + if (rp_error_msg) + { + marked_message_printf (0, 6, "ERROR: %s", rp_error_msg); + free (rp_error_msg); + rp_error_msg = NULL; + } } /* The main loop. */ @@ -918,14 +940,6 @@ listen_for_events () { handle_signals (); - /* Report any X11 errors that have occurred. */ - if (rp_error_msg) - { - marked_message_printf (0, 6, "ERROR: %s", rp_error_msg); - free (rp_error_msg); - rp_error_msg = NULL; - } - /* Handle the next event. */ FD_SET (x_fd, &fds); XFlush(dpy); @@ -935,6 +949,7 @@ listen_for_events () { XNextEvent (dpy, &rp_current_event); delegate_event (&rp_current_event); + XSync(dpy, False); } } } diff --git a/src/globals.c b/src/globals.c index a76f220..6a5f1b3 100644 --- a/src/globals.c +++ b/src/globals.c @@ -30,6 +30,8 @@ int rat_x; int rat_y; int rat_visible = 1; /* rat is visible by default */ +char *rp_exec_newwm = NULL; + Atom wm_name; Atom wm_state; Atom wm_change_state; diff --git a/src/globals.h b/src/globals.h index a1665fb..f6d43a8 100644 --- a/src/globals.h +++ b/src/globals.h @@ -121,6 +121,12 @@ extern int kill_signalled; extern int hup_signalled; extern int chld_signalled; +/* When set to a string, ratpoison should exec the command. The reason + this variable is needed and why it is not exec'd in cmd_newwm is + because if called with ratpoison -c, the rp -c process never + returns. */ +extern char *rp_exec_newwm; + /* rudeness levels */ extern int rp_honour_transient_raise; extern int rp_honour_normal_raise; -- cgit v1.2.3