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-patched-b9f239abe6a0c52632171e73faa8ff9e6bb86913.tar.bz2
st-patched-b9f239abe6a0c52632171e73faa8ff9e6bb86913.tar.xz
st-patched-b9f239abe6a0c52632171e73faa8ff9e6bb86913.zip
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 {
197 Colormap cmap; 197 Colormap cmap;
198 Window win; 198 Window win;
199 XdbeBackBuffer buf; 199 XdbeBackBuffer buf;
200 Atom xembed; 200 Atom xembed, wmdeletewin;
201 XIM xim; 201 XIM xim;
202 XIC xic; 202 XIC xic;
203 XftDraw *xft_draw; 203 XftDraw *xft_draw;
@@ -850,12 +850,15 @@ execsh(void) {
850void 850void
851sigchld(int a) { 851sigchld(int a) {
852 int stat = 0; 852 int stat = 0;
853
853 if(waitpid(pid, &stat, 0) < 0) 854 if(waitpid(pid, &stat, 0) < 0)
854 die("Waiting for pid %hd failed: %s\n", pid, SERRNO); 855 die("Waiting for pid %hd failed: %s\n", pid, SERRNO);
855 if(WIFEXITED(stat)) 856
857 if(WIFEXITED(stat)) {
856 exit(WEXITSTATUS(stat)); 858 exit(WEXITSTATUS(stat));
857 else 859 } else {
858 exit(EXIT_FAILURE); 860 exit(EXIT_FAILURE);
861 }
859} 862}
860 863
861void 864void
@@ -2173,6 +2176,8 @@ xinit(void) {
2173 &(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000}); 2176 &(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000});
2174 2177
2175 xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False); 2178 xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
2179 xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
2180 XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1);
2176 2181
2177 xresettitle(); 2182 xresettitle();
2178 XMapWindow(xw.dpy, xw.win); 2183 XMapWindow(xw.dpy, xw.win);
@@ -2475,6 +2480,10 @@ cmessage(XEvent *e) {
2475 } else if(e->xclient.data.l[1] == XEMBED_FOCUS_OUT) { 2480 } else if(e->xclient.data.l[1] == XEMBED_FOCUS_OUT) {
2476 xw.state &= ~WIN_FOCUSED; 2481 xw.state &= ~WIN_FOCUSED;
2477 } 2482 }
2483 } else if(e->xclient.data.l[0] == xw.wmdeletewin) {
2484 /* Send SIGHUP to shell */
2485 kill(pid, SIGHUP);
2486 exit(EXIT_SUCCESS);
2478 } 2487 }
2479} 2488}
2480 2489