aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2012-10-05 22:59:08 +0200
committerChristoph Lohmann <20h@r-36.net>2012-10-05 22:59:08 +0200
commitb9f239abe6a0c52632171e73faa8ff9e6bb86913 (patch)
tree838acb5b4c2d9f2c8772e79dd640bb148a237904
parent2549840ed7e69cddcc020533764ca12881026ffd (diff)
downloadst-b9f239abe6a0c52632171e73faa8ff9e6bb86913.tar.gz
st-b9f239abe6a0c52632171e73faa8ff9e6bb86913.tar.bz2
Adding the patch of David Dufberg Töttrup to implement WM_DELETE_WINDOW. Thank you!
-rw-r--r--st.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/st.c b/st.c
index 7ae9d8c..1ac7fde 100644
--- a/st.c
+++ b/st.c
@@ -197,7 +197,7 @@ typedef struct {
Colormap cmap;
Window win;
XdbeBackBuffer buf;
- Atom xembed;
+ Atom xembed, wmdeletewin;
XIM xim;
XIC xic;
XftDraw *xft_draw;
@@ -850,12 +850,15 @@ execsh(void) {
void
sigchld(int a) {
int stat = 0;
+
if(waitpid(pid, &stat, 0) < 0)
die("Waiting for pid %hd failed: %s\n", pid, SERRNO);
- if(WIFEXITED(stat))
+
+ if(WIFEXITED(stat)) {
exit(WEXITSTATUS(stat));
- else
+ } else {
exit(EXIT_FAILURE);
+ }
}
void
@@ -2173,6 +2176,8 @@ xinit(void) {
&(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000});
xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
+ xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
+ XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1);
xresettitle();
XMapWindow(xw.dpy, xw.win);
@@ -2475,6 +2480,10 @@ cmessage(XEvent *e) {
} else if(e->xclient.data.l[1] == XEMBED_FOCUS_OUT) {
xw.state &= ~WIN_FOCUSED;
}
+ } else if(e->xclient.data.l[0] == xw.wmdeletewin) {
+ /* Send SIGHUP to shell */
+ kill(pid, SIGHUP);
+ exit(EXIT_SUCCESS);
}
}