diff --git a/client.c b/client.c index 594ec77..b73ac41 100644 --- a/client.c +++ b/client.c @@ -336,3 +336,8 @@ int isautostick(Client* c) { return 0; } #endif + +void ensureactive() { + if (!current) + shuffle(0); +} diff --git a/event.c b/event.c index 1c4f214..f7a2fc1 100644 --- a/event.c +++ b/event.c @@ -306,9 +306,7 @@ void destroy(Window w) { currents[i] = 0; rmclient(c); - //if (v == virt) { - // shuffle(0); - //} + ensureactive(); /* flush any errors generated by the window's sudden demise */ ignore_badwindow = 1; diff --git a/fns.h b/fns.h index 89f8769..cced2bf 100644 --- a/fns.h +++ b/fns.h @@ -97,6 +97,7 @@ void dump_revert(); void dump_clients(); void shuffle(int); int isautostick(Client* c); +void ensureactive(); /* grab.c */ int menuhit(); diff --git a/menu.c b/menu.c index b9b727b..aef0f2e 100644 --- a/menu.c +++ b/menu.c @@ -298,14 +298,11 @@ void delete (Client* c, int shift) { if (c == 0) return; //v = c->virt; - if ((c->proto & Pdelete) && !shift) { + if ((c->proto & Pdelete) && !shift) sendcmessage(c->window, wm_protocols, wm_delete, 0, 0); - if (!current) { - shuffle(0); - } - } else XKillClient(dpy, c->window); /* let event clean up */ + ensureactive(); } void hide(Client* c) { @@ -469,7 +466,9 @@ void switch_to(int n) { switch_to_c(n, clients); current = currents[virt]; + ensureactive(); top(current); +#ifdef VIRTNOTIFY if (fork() == 0) { close(ConnectionNumber(dpy)); if (dpy != '\0') @@ -477,7 +476,6 @@ void switch_to(int n) { signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); signal(SIGHUP, SIG_DFL); -#ifdef VIRTNOTIFY sprintf(virtmsg, VIRTMSG, b2items[virt]); execlp( "notify-send", @@ -487,8 +485,8 @@ void switch_to(int n) { VIRTHEADER, virtmsg, (char*)0); -#endif } +#endif } void initb2menu(int n) { b2items[n] = 0; }