dwm-onlyquitonempty-20180428-6.2.diff (1042B)
1 From ba1a2cbf2a04992e05f0168965043d9335b742b9 Mon Sep 17 00:00:00 2001 2 From: thatlittlegit <personal@thatlittlegit.tk> 3 Date: Sat, 28 Apr 2018 16:51:49 -0400 4 Subject: [PATCH] Don't quit if not all windows are empty 5 6 --- 7 config.def.h | 2 ++ 8 dwm.c | 12 +++++++++++- 9 2 files changed, 13 insertions(+), 1 deletion(-) 10 11 diff --git a/config.def.h b/config.def.h 12 index a9ac303..9732b02 100644 13 --- a/config.def.h 14 +++ b/config.def.h 15 @@ -113,3 +113,5 @@ static Button buttons[] = { 16 { ClkTagBar, MODKEY, Button3, toggletag, {0} }, 17 }; 18 19 +/* quitting */ 20 +static const int EMPTY_WINDOW_COUNT = 2; 21 diff --git a/dwm.c b/dwm.c 22 index c98678d..cc6ae80 100644 23 --- a/dwm.c 24 +++ b/dwm.c 25 @@ -1248,7 +1248,17 @@ propertynotify(XEvent *e) 26 void 27 quit(const Arg *arg) 28 { 29 - running = 0; 30 + unsigned int n; 31 + Window *junk = malloc(1); 32 + 33 + XQueryTree(dpy, root, junk, junk, &junk, &n); 34 + 35 + if (n == EMPTY_WINDOW_COUNT) 36 + running = 0; 37 + else 38 + printf("[dwm] not exiting (n=%d)\n", n); 39 + 40 + free(junk); 41 } 42 43 Monitor * 44 -- 45 2.17.0 46