From ba1a2cbf2a04992e05f0168965043d9335b742b9 Mon Sep 17 00:00:00 2001 From: thatlittlegit Date: Sat, 28 Apr 2018 16:51:49 -0400 Subject: [PATCH] Don't quit if not all windows are empty --- config.def.h | 2 ++ dwm.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index a9ac303..9732b02 100644 --- a/config.def.h +++ b/config.def.h @@ -113,3 +113,5 @@ static Button buttons[] = { { ClkTagBar, MODKEY, Button3, toggletag, {0} }, }; +/* quitting */ +static const int EMPTY_WINDOW_COUNT = 2; diff --git a/dwm.c b/dwm.c index c98678d..cc6ae80 100644 --- a/dwm.c +++ b/dwm.c @@ -1248,7 +1248,17 @@ propertynotify(XEvent *e) void quit(const Arg *arg) { - running = 0; + unsigned int n; + Window *junk = malloc(1); + + XQueryTree(dpy, root, junk, junk, &junk, &n); + + if (n == EMPTY_WINDOW_COUNT) + running = 0; + else + printf("[dwm] not exiting (n=%d)\n", n); + + free(junk); } Monitor * -- 2.17.0