aboutsummaryrefslogtreecommitdiff
path: root/monsterwm.c
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2012-03-11 15:46:39 +0200
committerIvan Kanakarakis <ivan.kanak@gmail.com>2012-03-11 15:46:42 +0200
commit2af26b40d7be9e237f0989ceb5a852949f25c524 (patch)
treec7b3e158e601a34270d7a9ce86aafb7d0646da6e /monsterwm.c
parent7c48de9a60890747f69ede1b6a6819bd3c26f033 (diff)
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.
Diffstat (limited to 'monsterwm.c')
-rw-r--r--monsterwm.c15
1 files 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; nd<DESKTOPS && !found; nd++)
for (select_desktop(nd), p = &head; *p && !(found = *p == c); p = &(*p)->next);
*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;