aboutsummaryrefslogtreecommitdiffstats
path: root/calmwm.c
diff options
context:
space:
mode:
authorokan2014-01-22 21:48:27 +0000
committerokan2014-01-22 21:48:27 +0000
commitd86dc240a824ab0c88be47a7c951517b8a07fdde (patch)
tree817269e43357f67bfcbaab33f728076e706d9484 /calmwm.c
parent129338185f898dfe060a3de1b5b7aba429161b81 (diff)
downloadcwm-d86dc240a824ab0c88be47a7c951517b8a07fdde.tar.gz
Somewhat streamline event loop/restart/quit handling; most notable
change allows a restart to trigger proper teardown first, even though teardown is not (yet) complete. After some discussion with oga@nicotinebsd.org regarding a more complicated version/idea.
Diffstat (limited to 'calmwm.c')
-rw-r--r--calmwm.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/calmwm.c b/calmwm.c
index 8734866..d476aa0 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: calmwm.c,v 1.83 2014/01/21 15:42:44 okan Exp $
+ * $OpenBSD: calmwm.c,v 1.84 2014/01/22 21:48:27 okan Exp $
*/
#include <sys/param.h>
@@ -47,10 +47,12 @@ struct client_ctx_q Clientq = TAILQ_HEAD_INITIALIZER(Clientq);
int HasRandr, Randr_ev;
struct conf Conf;
const char *homedir;
+volatile sig_atomic_t cwm_status;
static void sigchld_cb(int);
static int x_errorhandler(Display *, XErrorEvent *);
static void x_init(const char *);
+static void x_restart(void);
static void x_teardown(void);
static int x_wmerrorhandler(Display *, XErrorEvent *);
@@ -111,8 +113,12 @@ main(int argc, char **argv)
free(conf_path);
x_init(display_name);
- xev_loop();
+ cwm_status = CWM_RUNNING;
+ while (cwm_status == CWM_RUNNING)
+ xev_process();
x_teardown();
+ if (cwm_status == CWM_RESTART)
+ x_restart();
return (0);
}
@@ -141,6 +147,13 @@ x_init(const char *dpyname)
}
static void
+x_restart(void)
+{
+ (void)setsid();
+ (void)execvp(cwm_argv[0], cwm_argv);
+}
+
+static void
x_teardown(void)
{
XCloseDisplay(X_Dpy);