From 2af26b40d7be9e237f0989ceb5a852949f25c524 Mon Sep 17 00:00:00 2001 From: Ivan Kanakarakis Date: Sun, 11 Mar 2012 15:46:39 +0200 Subject: fix no current client when removing prevfocus for example we open an application with a splash screen. the splash screen is the current window until the app is ready, opened, and mapped. once it's ready, the splash screen, which is now prevfocus is destroyed, and thus prevfocus is null. closing the app, called update_current(prevfocus) which resulted in no client being current and highlighted. also the check to remove _NET_ACTIVE_WINDOW is done with head. if there is no head, there is no client. --- monsterwm.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/monsterwm.c b/monsterwm.c index d5d2d80..f5054ed 100644 --- a/monsterwm.c +++ b/monsterwm.c @@ -637,19 +637,20 @@ void quit() { /* remove the specified client * - * notice: the removing client can be on any desktop, + * note, the removing client can be on any desktop, * we must return back to the current focused desktop. - * if the removing client was the current one, current must be set to - * NULL, otherwise prevfocus gets a wrong value by update_current. */ + * if c was the previously focused, prevfocus must be updated + * else if c was the current one, current must be updated. */ void removeclient(client *c) { client **p = NULL; int nd = 0, cd = current_desktop; for (Bool found = False; ndnext); *p = c->next; + if (c == prevfocus) prevfocus = prev_client(current); + if (c == current || !head->next) update_current(prevfocus); free(c); c = NULL; - update_current(prevfocus); - if (cd != nd-1) select_desktop(cd); + if (cd == nd -1) tile(); else select_desktop(cd); } /* main event loop - on receival of an event call the appropriate event handler */ @@ -826,11 +827,11 @@ void unmapnotify(XEvent *e) { * - the window is fullscreen * - the mode is MONOCLE and the window is not floating or transient */ void update_current(client *c) { - if (!c) { + if (!head) { XDeleteProperty(dis, root, netatoms[NET_ACTIVE]); current = prevfocus = NULL; return; - } else if (c == prevfocus) { current = prevfocus; prevfocus = prev_client(current); + } else if (c == prevfocus) { prevfocus = prev_client(current = prevfocus ? prevfocus:head); } else if (c != current) { prevfocus = current; current = c; } XWindowChanges wc; -- cgit v1.3.1