aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Stevens <nilix@nilfm.cc>2021-03-09 00:35:05 -0500
committerDerek Stevens <nilix@nilfm.cc>2021-03-09 00:35:05 -0500
commit836136e1533801b6f2abe59fdb77d7cc9f28201f (patch)
treea4068c7b8a40ea2cb7d9eeaf7bd624f7e027a979
parentae878964213b0a86f01c722114729dd4560f2c43 (diff)
fns.h, menu.c, client.c, event.c: more reliably ensure active window on delete and virtswitch
-rw-r--r--client.c5
-rw-r--r--event.c4
-rw-r--r--fns.h1
-rw-r--r--menu.c12
4 files changed, 12 insertions, 10 deletions
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; }