commit 493302d38b328795fe787aeb86f9e972b3afc84f parent f10cec85092f1cc85ca412dfe8cbd271820c4e4b Author: Dylan Araps <dylan.araps@gmail.com> Date: Fri, 18 Oct 2019 13:45:02 +0300 sowm: simpler window add Diffstat:
M | sowm.c | | | 19 | ++++++++----------- |
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git 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); }