From 493302d38b328795fe787aeb86f9e972b3afc84f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 18 Oct 2019 13:45:02 +0300 Subject: [PATCH] sowm: simpler window add --- sowm.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/sowm.c b/sowm.c index 96f067d..46b0729 100644 --- a/sowm.c +++ b/sowm.c @@ -130,24 +130,21 @@ void button_release() { } void win_add(Window w) { - client *c, *t; + client *c, *t = list; if (!(c = (client *) calloc(1, sizeof(client)))) exit(1); - if (!list) { - c->next = c->prev = 0; - c->w = w; - list = c; + c->w = w; - } else { - for (t=list;t->next;t=t->next); + if (list) { + while (t->next) t = t->next; - c->next = 0; - c->prev = t; - c->w = w; t->next = c; - } + c->prev = t; + + } else + list = c; ws_save(ws); }