From cfff297a82b5d515c668af9730daf71e0fcf4b04 Mon Sep 17 00:00:00 2001 From: Ivan Kanakarakis Date: Fri, 6 Jan 2012 00:01:00 +0200 Subject: rework removeclient() function --- monsterwm.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/monsterwm.c b/monsterwm.c index 5fd1cfe..7e5c235 100644 --- a/monsterwm.c +++ b/monsterwm.c @@ -485,18 +485,12 @@ void quit(const Arg *arg) { } void removeclient(client *c) { - client *p = NULL; + client **p = NULL; int nd = 0, cd = current_desktop; for (Bool found = False; ndnext == c)); p=p->next); - if (c == head) { - if (head->next) head = head->next; /* more windows on screen */ - else { free(head); head = NULL; } /* head is only window on screen */ - current = head; - } else if (c) { - (current = p)->next = c->next; /* p should be previous of c */ - free(c); - } + for (select_desktop(nd), p = &head; *p && !(found = *p == c); p = &(*p)->next); + current = (*p = c->next) ? *p : head; + free(c); select_desktop(cd); tile(); if (mode == MONOCLE && cd == --nd && current) XMapWindow(dis, current->win); -- cgit v1.3.1