[hackers] [st] Adding the patch of David Dufberg Töttrup to implement WM_DELETE_WINDOW. Thank you! || Christoph Lohmann

From: <hg_AT_suckless.org>
Date: Fri, 5 Oct 2012 23:01:47 +0200 (CEST)

changeset: 350:8ce150eeab43
tag: tip
user: Christoph Lohmann <20h_AT_r-36.net>
date: Fri Oct 05 22:59:08 2012 +0200
files: st.c
description:
Adding the patch of David Dufberg Töttrup to implement WM_DELETE_WINDOW. Thank you!


diff -r bcc37f1f7f6d -r 8ce150eeab43 st.c
--- a/st.c Fri Oct 05 22:51:08 2012 +0200
+++ b/st.c Fri Oct 05 22:59:08 2012 +0200
_AT_@ -197,7 +197,7 @@
         Colormap cmap;
         Window win;
         XdbeBackBuffer buf;
- Atom xembed;
+ Atom xembed, wmdeletewin;
         XIM xim;
         XIC xic;
         XftDraw *xft_draw;
_AT_@ -850,12 +850,15 @@
 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
_AT_@ -2173,6 +2176,8 @@
                 &(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);
_AT_@ -2475,6 +2480,10 @@
                 } 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);
         }
 }
 
Received on Fri Oct 05 2012 - 23:01:47 CEST

This archive was generated by hypermail 2.3.0 : Fri Oct 05 2012 - 23:12:06 CEST