From 642a6a37b1b401e724e3706f3cf7da63a9be3025 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 20 Nov 2021 22:30:00 +0500 Subject: [PATCH] Improve code of func "cleanup" --- src/dwm.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/dwm.c b/src/dwm.c index e78c3d9..f59dca5 100644 --- a/src/dwm.c +++ b/src/dwm.c @@ -459,20 +459,28 @@ void checkotherwm() void cleanup() { Layout foo = { NULL, NULL }; - Monitor *m; - size_t i; - selmon->lt[selmon->sellt] = &foo; - for (m = mons; m; m = m->next) - while (m->stack) + + for (Monitor *m = mons; m; m = m->next) { + while (m->stack) { unmanage(m->stack, 0); + } + } + XUngrabKey(dpy, AnyKey, AnyModifier, root); - while (mons) + + while (mons) { cleanupmon(mons); - for (i = 0; i < CurLast; i++) + } + + for (size_t i = 0; i < CurLast; i++) { drw_cur_free(drw, cursor[i]); - for (i = 0; i < LENGTH(colors); i++) + } + + for (size_t i = 0; i < LENGTH(colors); i++) { free(scheme[i]); + } + atoms_destroy(atoms); XDestroyWindow(dpy, wmcheckwin); drw_free(drw);