aboutsummaryrefslogtreecommitdiff
path: root/monsterwm.c
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2012-01-06 00:01:00 +0200
committerIvan Kanakarakis <ivan.kanak@gmail.com>2012-01-06 00:33:46 +0200
commitcfff297a82b5d515c668af9730daf71e0fcf4b04 (patch)
tree28ae3146906bb02923f14eaa164b6af5b72b3c97 /monsterwm.c
parentf21fc2c44bfca5d803c96263835ef8fece031fec (diff)
rework removeclient() function
Diffstat (limited to 'monsterwm.c')
-rw-r--r--monsterwm.c14
1 files 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; nd<DESKTOPS && !found; nd++)
- for (select_desktop(nd), p=head; p && !(found = (p == c || p->next == 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);